'month': m.group('month'), 'day': m.group('day'), 'slug': m.group('slug'), 'path': os.path.join(path, file_name), 'created': date(int(m.group('year')), int(m.group('month')), int(m.group('day'))) })) return sorted(posts, key=attrgetter('created'), reverse=True) def populate_post(self, post): post_content = open(post.path, 'r').read() match = re.match('^\s*---\s*(.*)---\s*(.*)', post_content, re.DOTALL) if match is not None: content = markdown.markdown(match.groups()[1], ['codehilite']) post.content = content front_matter = yaml.load(match.groups()[0]) if front_matter.get('title', None) is not None: post.title = front_matter.get('title') else: return False blueprint = Blueprint('blog', __name__, template_folder='templates') blueprint.discoverable_route = types.MethodType(discoverable_route, blueprint, Blueprint) blueprint.fetch_posts = types.MethodType(fetch_posts, blueprint, Blueprint) blueprint.populate_post = types.MethodType(populate_post, blueprint, Blueprint)