Permalink
Browse files

Apparently page's did not have a guranteed datetime field yet. Oops!

  • Loading branch information...
mythmon committed May 7, 2011
1 parent a3bb6aa commit d5654a07f033168b5e4d637f43197bac16caf7a7
Showing with 17 additions and 3 deletions.
  1. +1 −1 setup.py
  2. +16 −2 wok/page.py
View
@@ -7,7 +7,7 @@
setup(name='wok',
version=version.encode("utf8"),
description='Static site generator',
- requires=['yaml', 'markdown', 'docutils', 'jinja2'],
+ requires=['yaml', 'markdown', 'docutils', 'jinja2', 'isodate'],
author='Mike Cooper',
author_email='mythmon@gmail.com',
url='https://www.github.com/mythmon/wok',
View
@@ -1,9 +1,11 @@
import os
+from collections import namedtuple
+from datetime import datetime
+
import jinja2
import yaml
-from collections import namedtuple
import re
-from datetime import datetime
+import isodate
import util
import renderers
@@ -85,6 +87,8 @@ def build_meta(self):
`page.slug` - will exist.
`page.author` - will exist, and contain fields `name` and `email`.
`page.category` - will exist, and be a list.
+ `page.published` - will exist
+ `page.datetime` - will exist
"""
if not 'title' in self.meta:
@@ -123,6 +127,16 @@ def build_meta(self):
self.meta['published'] = True
# Gurantee: published exists
+ datetime_name=None
+ for name in ['time', 'date', 'datetime']:
+ if name in self.meta:
+ datetime_name = 'date'
+ if datetime_name:
+ self.meta['datetime'] = isodate.parse_datetime(self.meta[datetime_name])
+ else:
+ self.meta['datetime'] = datetime.now()
+ # Gurantee: datetime exists
+
def render(self):
"""
Renders the page to full html.

0 comments on commit d5654a0

Please sign in to comment.