| @@ -11,7 +11,7 @@ also take a look at the [cloudpanic source][cp] for a reference implementation. | |||
| [Here](http://groups.google.com/group/hyde-dev/browse_thread/thread/2a143bd2081b3322) is | |||
| the initial announcement of the project. | |||
| # Installation | |||
| ## Installation | |||
| Hyde supports both python 2.7 and 2.6. | |||
| @@ -28,7 +28,7 @@ You can choose to install hyde by running | |||
| python setup.py install | |||
| # Creating a new hyde site | |||
| ## Creating a new hyde site | |||
| The new version of Hyde uses the `argparse` module and hence support subcommands. | |||
| @@ -38,12 +38,12 @@ The new version of Hyde uses the `argparse` module and hence support subcommands | |||
| will create a new hyde site using the test layout. | |||
| # Generating the hyde site | |||
| ## Generating the hyde site | |||
| cd ~/test_site | |||
| hyde gen | |||
| # Serving the website | |||
| ## Serving the website | |||
| cd ~/test_site | |||
| hyde serve | |||
| @@ -54,7 +54,7 @@ The server also regenerates on demand. As long as the server is running, | |||
| you can make changes to your source and refresh the browser to view the changes. | |||
| # A brief list of features | |||
| ## A brief list of features | |||
| 1. Support for multiple templates (although only `Jinja2` is currently implemented) | |||
| @@ -69,7 +69,7 @@ you can make changes to your source and refresh the browser to view the changes. | |||
| now provide additional syntactic sugar to make the content more readable. See | |||
| `blockdown` and `autoextend` plugin for examples. | |||
| # Next Steps | |||
| ## Next Steps | |||
| 1. Documentation | |||
| 2. Default Layouts | |||
| @@ -63,6 +63,28 @@ class Markdown(Extension): | |||
| output = caller().strip() | |||
| return markdown(self.environment, output) | |||
| class IncludeText(Extension): | |||
| tags = set(['includetext']) | |||
| def parse(self, parser): | |||
| node = parser.parse_include() | |||
| return nodes.CallBlock( | |||
| self.call_method('_render_include_text', [], [], None, None), | |||
| [], [], [node] | |||
| ).set_lineno(node.lineno) | |||
| def _render_include_text(self, caller=None): | |||
| if not caller: | |||
| return '' | |||
| output = caller().strip() | |||
| output = markdown(self.environment, output) | |||
| if 'typogrify' in self.environment.filters: | |||
| typo = self.environment.filters['typogrify'] | |||
| output = typo(output) | |||
| return output | |||
| class HydeLoader(FileSystemLoader): | |||
| def __init__(self, sitepath, site, preprocessor=None): | |||
| @@ -108,7 +130,8 @@ class Jinja2Template(Template): | |||
| self.env = Environment(loader=self.loader, | |||
| undefined=SilentUndefined, | |||
| trim_blocks=True, | |||
| extensions=[Markdown, | |||
| extensions=[IncludeText, | |||
| Markdown, | |||
| 'jinja2.ext.do', | |||
| 'jinja2.ext.loopcontrols', | |||
| 'jinja2.ext.with_']) | |||
| @@ -151,6 +151,25 @@ def create_test_site(): | |||
| def delete_test_site(): | |||
| TEST_SITE.delete() | |||
| @nottest | |||
| def assert_markdown_typogrify_processed_well(include_text, includer_text): | |||
| site = Site(TEST_SITE) | |||
| site.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin'] | |||
| inc = File(TEST_SITE.child('content/inc.md')) | |||
| inc.write(include_text) | |||
| site.load() | |||
| gen = Generator(site) | |||
| gen.load_template_if_needed() | |||
| template = gen.template | |||
| html = template.render(includer_text, {}).strip() | |||
| assert html | |||
| q = PyQuery(html) | |||
| assert "is_processable" not in html | |||
| assert "This is a" in q("h1").text() | |||
| assert "heading" in q("h1").text() | |||
| assert q(".amp").length == 1 | |||
| @with_setup(create_test_site, delete_test_site) | |||
| def test_can_include_templates_with_processing(): | |||
| text = """ | |||
| @@ -172,25 +191,10 @@ Hyde & Jinja. | |||
| {% include "inc.md" %} | |||
| """ | |||
| site = Site(TEST_SITE) | |||
| site.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin'] | |||
| inc = File(TEST_SITE.child('content/inc.md')) | |||
| inc.write(text) | |||
| site.load() | |||
| gen = Generator(site) | |||
| gen.load_template_if_needed() | |||
| template = gen.template | |||
| html = template.render(text2, {}).strip() | |||
| assert html | |||
| q = PyQuery(html) | |||
| assert "is_processable" not in html | |||
| assert "This is a" in q("h1").text() | |||
| assert "heading" in q("h1").text() | |||
| assert q(".amp").length == 1 | |||
| assert_markdown_typogrify_processed_well(text, text2) | |||
| #@with_setup(create_test_site, delete_test_site) | |||
| @nottest | |||
| @with_setup(create_test_site, delete_test_site) | |||
| def test_includetext(): | |||
| text = """ | |||
| === | |||
| @@ -200,24 +204,12 @@ is_processable: False | |||
| This is a heading | |||
| ================= | |||
| An "&". | |||
| Hyde & Jinja. | |||
| """ | |||
| text2 = """ | |||
| {% includetext inc.md %} | |||
| {% includetext "inc.md" %} | |||
| """ | |||
| site = Site(TEST_SITE) | |||
| inc = File(TEST_SITE.child('content/inc.md')) | |||
| inc.write(text) | |||
| site.load() | |||
| gen = Generator(site) | |||
| gen.load_template_if_needed() | |||
| template = gen.template | |||
| html = template.render(text2, {}).strip() | |||
| assert html | |||
| q = PyQuery(html) | |||
| assert q("h1").length == 1 | |||
| assert q(".amp").length == 1 | |||
| assert_markdown_typogrify_processed_well(text, text2) | |||