Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Add new parsed variable: author
Browse files Browse the repository at this point in the history
  • Loading branch information
mythmon committed Feb 18, 2011
1 parent a268d44 commit 2834874
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wok.py
Expand Up @@ -5,6 +5,8 @@
import markdown
import jinja2
import yaml
from collections import namedtuple
import re

import util

Expand Down Expand Up @@ -43,6 +45,12 @@ def build_meta(self):
elif self.meta['slug'] != util.slugify(self.meta['slug']):
util.out.warn('metadata', 'Your slug should probably be all lower case, and match the regex "[a-z0-9-]*"')

if 'author' in self.meta:
Author = namedtuple('Author', ['raw', 'name', 'email'])
# Grab a name and maybe an email
parsed = re.match(r'([^<>]*)( +<(.*@.*)>)$', self.meta['author'])
self.meta['author'] = Author(self.meta['author'], parsed.group(1), parsed.group(3))

def render(self):
type = self.meta.get('type', 'default')
template = Page.tmpl_env.get_template(type + '.html')
Expand Down

0 comments on commit 2834874

Please sign in to comment.