I'm confident enough that this is what I want to do for resolving content, at least at the moment
25 lines
630 B
Python
25 lines
630 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'{path}.md'
|
|
return path
|