Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit d5654a07f033168b5e4d637f43197bac16caf7a7 1 parent a3bb6aa
@mythmon authored
Showing with 17 additions and 3 deletions.
  1. +1 −1  setup.py
  2. +16 −2 wok/page.py
View
2  setup.py
@@ -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
18 wok/page.py
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.