incorporeal-cms/incorporealcms/journal.py

25 lines
638 B
Python

"""Journal functionality."""
from flask import Blueprint
bp = Blueprint('journal', __name__, url_prefix='/')
@bp.route('/', defaults={'path': 'index'})
@bp.route('/<path:path>')
def display_journal_entry(path):
return path
def journal_file_resolver(path):
"""Manipulate the request path to find appropriate journal files.
* convert dir requests to index files
Worth noting, Flask already does stuff like convert '/foo/../../../bar' to
'/bar', so we don't need to take care around file access here.
"""
if path.endswith('/'):
path = f'{path}index'
path = f'journal/{path}.md'
return path