journal: render markdown content + title metadata
this has a really basic template and whatnot at the moment, so styling/etc isn't done, but this is maybe the last major piece before I could actually see pushing this onto the site
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
"""Journal functionality."""
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, abort, current_app as app
|
||||
import markdown
|
||||
from flask import Blueprint, Markup, abort, current_app as app, render_template
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
bp = Blueprint('journal', __name__, url_prefix='/')
|
||||
md = markdown.Markdown(extensions=['meta'])
|
||||
|
||||
|
||||
@bp.route('/', defaults={'path': 'index'})
|
||||
@@ -17,13 +19,15 @@ def display_journal_entry(path):
|
||||
try:
|
||||
with app.open_instance_resource(resolved_path, 'r') as entry_file:
|
||||
logger.debug("file '%s' found", resolved_path)
|
||||
entry = entry_file.read()
|
||||
except FileNotFoundError:
|
||||
logger.warning("requested path '%s' (resolved path '%s') not found!", path, resolved_path)
|
||||
abort(404)
|
||||
else:
|
||||
return "OK"
|
||||
|
||||
return resolved_path
|
||||
content = Markup(md.convert(entry))
|
||||
logger.debug("file metadata: %s", md.Meta)
|
||||
title = " ".join(md.Meta.get('title')) if md.Meta.get('title') else ""
|
||||
return render_template('base.html', title=title, content=content)
|
||||
|
||||
|
||||
def journal_file_resolver(path):
|
||||
|
||||
5
incorporealcms/templates/base.html
Normal file
5
incorporealcms/templates/base.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<!doctype html>
|
||||
<title>{{ title }}{% if title %} - {% endif %}incorporeal.org</title>
|
||||
<section class="content">
|
||||
{{ content }}
|
||||
</section>
|
||||
Reference in New Issue
Block a user