]> projects.mako.cc - to_fork_or_not/commitdiff
moved in code to help render
authorBenjamin Mako Hill <mako@atdot.cc>
Fri, 12 Jul 2013 23:06:55 +0000 (19:06 -0400)
committerBenjamin Mako Hill <mako@atdot.cc>
Fri, 12 Jul 2013 23:06:55 +0000 (19:06 -0400)
latex-like-layout.tmpl [new file with mode: 0644]
latex-like.css [new file with mode: 0644]
render_templates.py [new file with mode: 0755]
to_fork_or_not_to_fork.tmpl [moved from to_fork_or_not_to_fork.html with 100% similarity]

diff --git a/latex-like-layout.tmpl b/latex-like-layout.tmpl
new file mode 100644 (file)
index 0000000..1170994
--- /dev/null
@@ -0,0 +1,47 @@
+{%- set base_url = "http://mako.cc/" -%}
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xml:lang="en" lang="en">
+  <head>
+    <meta charset="UTF-8">
+    <title>{{ page_title }}{% if page_title %} :: {% endif %}Benjamin Mako Hill</title>
+    <link rel="stylesheet" type="text/css" href="{{base_url}}/latex-like.css" />
+    <link rel="shortcut icon" href="http://mako.cc/favicon.ico" />
+  </head>
+
+  <body>
+    <h1>{{page_title}}</h1>
+    <h2 class="author"><a href="http://mako.cc">Benjamin Mako Hill</a><br />
+       <span style="font-size: 0.9em;">mako@atdot.cc</span></h2>
+
+   {% block content_box %}
+   {% endblock %}
+
+  <div id="footer">
+  <hr />
+  © 1999-2013 <a href="/">Benjamin Mako Hill</a><br />
+  Licensed under the <a rel="license"
+  href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative
+  Commons Attribution-Share Alike 3.0 United States License</a>.<br />
+  More permissive licensing may be available on request.<br />
+
+  Last modified: {{last_modified}}
+  </div>
+
+<!-- Piwik -->
+<script type="text/javascript">
+var pkBaseURL = (("https:" == document.location.protocol) ? "https://analytics.mako.cc/" : "http://analytics.mako.cc/");
+document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
+</script><script type="text/javascript">
+try {
+var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
+piwikTracker.trackPageView();
+piwikTracker.enableLinkTracking();
+} catch( err ) {}
+</script><noscript><p><img src="http://analytics.mako.cc/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
+<!-- End Piwik Tracking Code -->
+  </body>
+</html>
+
diff --git a/latex-like.css b/latex-like.css
new file mode 100644 (file)
index 0000000..998d1d5
--- /dev/null
@@ -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 (executable)
index 0000000..fb2abb4
--- /dev/null
@@ -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)
+
+

Benjamin Mako Hill || Want to submit a patch?