<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>templates/archive.html</filename>
    </added>
    <added>
      <filename>templates/base.html</filename>
    </added>
    <added>
      <filename>templates/detail.html</filename>
    </added>
    <added>
      <filename>templates/home.html</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -0,0 +1,115 @@
+#!/usr/bin/python
+
+# Chisel
+# David Zhou
+# 
+# Requires:
+# jinja2
+
+import sys, re, time, os
+import jinja2, markdown
+
+#Settings
+SOURCE = &quot;./blog/&quot; #end with slash
+DESTINATION = &quot;./export/&quot; #end with slash
+HOME_SHOW = 15 #numer of entries to show on homepage
+TEMPLATE_PATH = &quot;./templates/&quot;
+TEMPLATE_OPTIONS = {}
+TEMPLATES = {
+    'home': &quot;home.html&quot;,
+    'detail': &quot;detail.html&quot;,
+    'archive': &quot;archive.html&quot;,
+}
+TIME_FORMAT = &quot;%B %d, %Y - %I:%M %p&quot;
+
+#FORMAT should be a callable that takes in text
+#and returns formatted text
+FORMAT = lambda text: markdown.markdown(text, ['footnotes',]) 
+#########
+
+
+STEPS = []
+
+def step(func):
+    def wrapper(*args, **kwargs):
+        print &quot;Starting &quot; + func.__name__ + &quot;...&quot;,
+        func(*args, **kwargs)
+        print &quot;Done.&quot;
+    STEPS.append(wrapper)
+    return wrapper
+
+def get_tree(source):
+    files = []
+    for root, ds, fs in os.walk(source):
+        for name in fs:
+            path = os.path.join(root, name)
+            epoch = os.path.getmtime(path)
+            date = time.localtime(epoch)
+            year, month, day = map(int, date[:3])
+            f = open(path, &quot;r&quot;)
+            files.append({
+                'title': f.readline(),
+                'content': FORMAT(''.join(f.readlines()[1:])),
+                'url': '/'.join([str(year), &quot;%.2d&quot; % month, &quot;%.2d&quot; % day, os.path.splitext(name)[0] + &quot;.html&quot;]),
+                'date': time.strftime(TIME_FORMAT, date),
+                'epoch': epoch,
+                'year': year,
+                'month': month,
+                'day': day,
+            })
+            f.close()
+    return files
+
+def write_file(url, data):
+    path = DESTINATION + url
+    dirs = os.path.dirname(path)
+    if not os.path.isdir(dirs):
+        os.makedirs(dirs)
+    file = open(path, &quot;w&quot;)
+    file.write(data)
+    file.close()
+
+@step
+def generate_homepage(f, e):
+    &quot;&quot;&quot;Generate homepage&quot;&quot;&quot;
+    template = e.get_template(TEMPLATES['home'])
+    write_file(&quot;index.html&quot;, template.render(entries=f[:HOME_SHOW]))
+
+@step
+def master_archive(f, e):
+    &quot;&quot;&quot;Generate master archive list of all entries&quot;&quot;&quot;
+    template = e.get_template(TEMPLATES['archive'])
+    write_file(&quot;archives.html&quot;, template.render(entries=f))
+
+@step
+def detail_pages(f, e):
+    &quot;&quot;&quot;Generate detail pages of individual posts&quot;&quot;&quot;
+    template = e.get_template(TEMPLATES['detail'])
+    for file in f:
+        write_file(file['url'], template.render(file))
+
+@step
+def date_indices(f, e):
+    &quot;&quot;&quot;
+    Generate date indices for all year, month, days
+    permutations. Example: &quot;/2009/02/&quot;
+    &quot;&quot;&quot;
+    pass
+
+
+def main():
+    print &quot;Chiseling...&quot;
+    print &quot;\tReading files...&quot;,
+    files = sorted(get_tree(SOURCE), lambda x,y: not cmp(x['epoch'], y['epoch']))
+    env = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATE_PATH), **TEMPLATE_OPTIONS)
+    print &quot;Done.&quot;
+
+    print &quot;\tRunning steps...&quot;
+    for step in STEPS:
+        print &quot;\t\t&quot;,
+        step(files, env)
+    print &quot;\tDone.&quot;
+    print &quot;Done.&quot;
+
+if __name__ == &quot;__main__&quot;:
+    sys.exit(main())</diff>
      <filename>chisel.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b9c0f75a8e70313cf0422ede170c0c1bed367cc3</id>
    </parent>
  </parents>
  <author>
    <name>David Zhou</name>
    <email>david@nodnod.net</email>
  </author>
  <url>http://github.com/dz/chisel/commit/16e92ef8798a7e1082759fea267f83cfc5ff9f52</url>
  <id>16e92ef8798a7e1082759fea267f83cfc5ff9f52</id>
  <committed-date>2009-03-02T18:11:42-08:00</committed-date>
  <authored-date>2009-03-02T18:11:42-08:00</authored-date>
  <message>initial version</message>
  <tree>5390eee236d6fedb31553e1b1491cbbc30d90120</tree>
  <committer>
    <name>David Zhou</name>
    <email>david@nodnod.net</email>
  </committer>
</commit>
