Source

hgblog / rename_files.patch

Full commit
# HG changeset patch
# Parent 14ea69c060081944edea66ca8e111172d806fa63

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -14,3 +14,4 @@
 ^env/
 \.DS_Store$
 ~$
+.*\.swp
diff --git a/README b/README
--- a/README
+++ b/README
@@ -9,8 +9,8 @@
 
 Use ``setup.py``::
 
-   python setup.py build
-   sudo python setup.py install
+    python setup.py build
+    sudo python setup.py install
 
 
 Reading the docs
@@ -18,15 +18,16 @@
 
 After installing::
 
-   cd doc
-   sphinx-build . _build/html
+    cd doc
+    sphinx-build . _build/html
 
 Then, direct your browser to ``_build/html/index.html``.
 
-Or read them online at <http://sphinx.pocoo.org/>.
+Or read them online at <http://sphinx.pocoo.org>.
 
 
 Contributing
 ============
 
 Send wishes, comments, patches, etc. to sphinx-dev@googlegroups.com.
+
diff --git a/README.rst b/README.rst
new file mode 120000
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,1 @@
+README
\ No newline at end of file
diff --git a/hgblog/__init__.py b/hgblog/__init__.py
new file mode 100644
--- /dev/null
+++ b/hgblog/__init__.py
@@ -0,0 +1,4 @@
+from server import serve
+
+__version__ = '0.2'
+
diff --git a/hgblog/refresh.py b/hgblog/refresh.py
new file mode 100644
--- /dev/null
+++ b/hgblog/refresh.py
@@ -0,0 +1,26 @@
+from mercurial.match import match
+from mercurial.ui import ui
+from sphinx.cmdline import main as sphinxify
+import os
+
+from hgblog.utils import get_repo
+
+def refresh(repo=None):
+    """Calls on Sphinx to turn our .rst files into pretty HTML"""
+
+    if repo is None:
+        repo = get_repo()
+
+    # find all .rst files that Mercurial is currently tracking
+    m = match(repo.root, repo.getcwd(), ('*.rst',))
+    files_to_consider = repo[None].walk(m)
+
+    # tell Sphinx to HTML-ize the .rst files we found
+    args = [
+        '-bdirhtml',
+        '-d%s' % os.path.join(repo.root, 'build', 'doctrees'),
+        os.path.join(repo.root, 'source'),
+        os.path.join(repo.root, 'build', 'html'),
+    ] + files_to_consider
+    sphinxify(args)
+
diff --git a/hgblog/server.py b/hgblog/server.py
new file mode 100755
--- /dev/null
+++ b/hgblog/server.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from BaseHTTPServer import HTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
+from optparse import OptionParser
+import os
+
+from hgblog.utils import get_repo
+
+def serve():
+    """Begins a static HTML web server for an HgBlog"""
+
+    # determine the port on which to listen for traffic
+    parser = OptionParser()
+    parser.add_option('-p', '--port', dest='port', default=8000,
+            help="The port to serve your blog on")
+    options, args = parser.parse_args()
+    port = int(options.port)
+
+    # get the root directory for the HgBlog repo
+    repo = get_repo()
+    html_path = os.path.join(repo.root, 'build', 'html')
+    os.chdir(html_path)
+
+    try:
+        server = HTTPServer(('', port), SimpleHTTPRequestHandler)
+        print 'Serving HTML in %s on port %s...' % (html_path, port)
+        server.serve_forever()
+    except KeyboardInterrupt:
+        server.socket.close()
+
+if __name__ == '__main__':
+    serve()
+
diff --git a/hgblog/utils.py b/hgblog/utils.py
new file mode 100644
--- /dev/null
+++ b/hgblog/utils.py
@@ -0,0 +1,13 @@
+from mercurial.cmdutil import findrepo
+from mercurial import hg
+from mercurial.ui import ui
+import os
+
+def get_repo(path=None):
+    if path is None:
+        path = os.getcwd()
+
+    repo_root = findrepo(path)
+    repo = hg.repository(ui(), path=repo_root)
+    return repo
+
diff --git a/setup.cfg b/setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [egg_info]
-tag_build = dev
-tag_date = true
+tag_build = 
+tag_date = false
 
 [aliases]
 release = egg_info -RDb ''
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@
 from setuptools import setup, find_packages
 from distutils import log
 
+import hgblog
 import sphinx
 
 long_desc = '''
@@ -156,15 +157,15 @@
 
 
 setup(
-    name='Sphinx',
-    version=sphinx.__version__,
-    url='http://sphinx.pocoo.org/',
-    download_url='http://pypi.python.org/pypi/Sphinx',
+    name='hgblog',
+    version=hgblog.__version__,
+    url='http://bitbucket.org/codekoala/hgblog/',
+    download_url='http://pypi.python.org/pypi/hgblog',
     license='BSD',
-    author='Georg Brandl',
-    author_email='georg@python.org',
-    description='Python documentation generator',
-    long_description=long_desc,
+    author='Josh VanderLinden',
+    author_email='codekoala@gmail.com',
+    description='Sphinx-based blogging engine',
+    long_description=open('README').read(),
     zip_safe=False,
     classifiers=[
         'Development Status :: 4 - Beta',
@@ -182,12 +183,14 @@
     include_package_data=True,
     entry_points={
         'console_scripts': [
-            'sphinx-build = sphinx:main',
-            'sphinx-quickstart = sphinx.quickstart:main',
-            'sphinx-autogen = sphinx.ext.autosummary.generate:main',
+            'hgblog-build = sphinx:main',
+            'hgblog-quickstart = sphinx.quickstart:main',
+            'hgblog-autogen = sphinx.ext.autosummary.generate:main',
+            'hgblog-serve = hgblog.server:serve',
+            'hgblog-refresh = hgblog.refresh:refresh',
         ],
         'distutils.commands': [
-            'build_sphinx = sphinx.setup_command:BuildDoc',
+            'build_hgblog = sphinx.setup_command:BuildDoc',
         ],
     },
     install_requires=requires,