23 lines
700 B
Python
23 lines
700 B
Python
from pyramid.httpexceptions import HTTPFound
|
|
from pyramid.traversal import (find_root, find_resource)
|
|
|
|
from flatfilecms.models import (YAML, Markdown)
|
|
|
|
def redirect(self, url):
|
|
return HTTPFound(location=url)
|
|
|
|
|
|
def set_content_type(self, content_type):
|
|
self.request.response.content_type = content_type
|
|
|
|
|
|
def blog(self, options):
|
|
path = options.get('base', '/')
|
|
root = find_root(self.context)
|
|
tree = find_resource(root, path)
|
|
postlist = []
|
|
for name, item in tree.walk():
|
|
if isinstance(item, (YAML, Markdown)) and 'published' in item.page:
|
|
postlist.append((f"{path}/{name}", item))
|
|
self.pages = sorted(postlist, key=lambda t: t[1].page['published'])
|