# HG changeset patch # User Oben Sonne # Date 1436818965 -7200 # Mon Jul 13 22:22:45 2015 +0200 # Branch py3 # Node ID e222f89920146b0785469030ba85587931ccf5e5 # Parent 8a5d3f55becb5f4baeec35a77d8d939b8bcc6ca3 # Parent 956181ca54ce7de9dd2cd1efda709f21262319cd Merge in default diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,10 +1,11 @@ -syntax: glob -tests/actual -tests/errors.diff -*.pyc -*~ -.project -.pydevproject -box -SNAPSHOT* -.settings +syntax: glob +tests/actual +tests/errors.diff +*.pyc +*~ +.project +.pydevproject +box +SNAPSHOT* +.settings +.idea/ \ No newline at end of file diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ **You** should know Markdown and optionally Python if you want to use Poole's dirty content generation capability. -**Your system** should have installed Python ≥ 2.5 and [python-markdown][pymd]. +**Your system** should have installed Python ≥ 2.7 and [python-markdown][pymd]. Poole has been tested on Linux but should also work on other Unix systems and Windows (in theory, [report an issue][issues] if it fails). @@ -78,7 +78,8 @@ Poole takes files from a project's `input` directory and copies them to the `output` directory. In this process files ending with *md*, *mkd*, *mdown* or -*markdown* get converted to HTML using the project's `page.html` as a skeleton. +*markdown* get converted to HTML using the project's `page.html` as a template +(unless a custom template is set on an individual page). Additionally Poole expands any macros used in a page. Don't care about that for now .. @@ -128,6 +129,16 @@ site. For more information read [this blog post with step-by-step instructions][pimp]. +In case you need special templates for individual pages, you can add the +property `tempalte` in the front matter of each page: + + title: This looks different + template: a-special-page-template.html + --- + +In that case the given file is used as the page template instead of the default +`page.html` file. + [pimp]: http://obensonne.bitbucket.org/blog/20091122-using-a-free-css-templates-in-poole.html ## Content Generation diff --git a/poole.py b/poole.py --- a/poole.py +++ b/poole.py @@ -617,16 +617,23 @@ # ------------------------------------------------------------------------- with open(opj(project, "page.html"), 'r', encoding=UTF8) as fp: - skeleton = fp.read() + default_template = fp.read() for page in pages: + if 'template' in page: + fname = opj(project, page['template']) + with open(fname, 'r', opts.input_enc) as fp: + template = fp.read() + else: + template = default_template + print("info : render %s" % page.url) # replace expressions and statements in page.html macros["page"] = page macros["__content__"] = page.html - out = regx_eval.sub(repl_eval, skeleton) + out = regx_eval.sub(repl_eval, template) out = regx_exec.sub(repl_exec, out) # un-escape escaped python code blocks