2020-03-06 18:08:24 -06:00
|
|
|
"""Journal functionality."""
|
|
|
|
from flask import Blueprint
|
|
|
|
|
2020-03-07 09:42:07 -06:00
|
|
|
bp = Blueprint('journal', __name__, url_prefix='/')
|
2020-03-06 18:08:24 -06:00
|
|
|
|
|
|
|
|
2020-03-07 08:37:38 -06:00
|
|
|
@bp.route('/', defaults={'path': 'index'})
|
2020-03-06 18:08:24 -06:00
|
|
|
@bp.route('/<path:path>')
|
|
|
|
def display_journal_entry(path):
|
|
|
|
return path
|
2020-03-07 08:37:38 -06:00
|
|
|
|
|
|
|
|
|
|
|
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'
|
2020-03-07 09:50:03 -06:00
|
|
|
path = f'journal/{path}.md'
|
2020-03-07 08:37:38 -06:00
|
|
|
return path
|