From b37c6f5aa5bfe30b36b5de509a1f0413f5a4783f Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Fri, 12 Jul 2013 19:06:55 -0400 Subject: [PATCH] moved in code to help render --- latex-like-layout.tmpl | 47 +++++++++++++++++++ latex-like.css | 31 ++++++++++++ render_templates.py | 39 +++++++++++++++ ...o_fork.html => to_fork_or_not_to_fork.tmpl | 0 4 files changed, 117 insertions(+) create mode 100644 latex-like-layout.tmpl create mode 100644 latex-like.css create mode 100755 render_templates.py rename to_fork_or_not_to_fork.html => to_fork_or_not_to_fork.tmpl (100%) diff --git a/latex-like-layout.tmpl b/latex-like-layout.tmpl new file mode 100644 index 0000000..1170994 --- /dev/null +++ b/latex-like-layout.tmpl @@ -0,0 +1,47 @@ +{%- set base_url = "http://mako.cc/" -%} + + + + + + + {{ page_title }}{% if page_title %} :: {% endif %}Benjamin Mako Hill + + + + + +

{{page_title}}

+

Benjamin Mako Hill
+ mako@atdot.cc

+ + {% block content_box %} + {% endblock %} + + + + + + + + + diff --git a/latex-like.css b/latex-like.css new file mode 100644 index 0000000..998d1d5 --- /dev/null +++ b/latex-like.css @@ -0,0 +1,31 @@ +body { + margin-left: 1in; + margin-right: 1in; + +} +h1 { + font-style: italic; + font-size: 2em; +} + +a { + text-decoration: none; +} + +.author { + font-size: 1.4em; +} + +.date { + font-size: 1em; +} + + +p,blockquote,li { + line-height: 170%; +} + +#footer { + font-size: 1em; + text-align: right; +} diff --git a/render_templates.py b/render_templates.py new file mode 100755 index 0000000..fb2abb4 --- /dev/null +++ b/render_templates.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +import os +import re +import codecs +from time import ctime +from os.path import walk, getctime + +root = os.path.dirname(__file__) + +from jinja import Environment, FileSystemLoader +jinja_env = Environment(loader=FileSystemLoader(root)) + +def render_walk(arg=None, dirname='', filenames=[]): + for filename in filenames: + match = re.match(r'(.*)\.tmpl$', filename) + if match: + filename_base = match.group(1) + + # skip if this is the layout file + if filename_base == 'layout': continue + if filename_base == 'latex-like-layout': continue + + vars = { 'last_modified' : + unicode(ctime(getctime(os.path.join(dirname, filename)))) } + + # remove the root from the dirname + dirname = re.sub(re.escape(root) + r'/?(.*)$', r'\1', dirname) + + tmpl = jinja_env.get_template(os.path.join(dirname, filename)) + tmpl.render(vars) + + output_file = codecs.open(os.path.join(dirname, filename_base + '.html'), 'w', 'utf-8') + print >>output_file, tmpl.render(vars) + output_file.close() + +walk(root, render_walk, None) + + diff --git a/to_fork_or_not_to_fork.html b/to_fork_or_not_to_fork.tmpl similarity index 100% rename from to_fork_or_not_to_fork.html rename to to_fork_or_not_to_fork.tmpl -- 2.30.2