From e78117b9cbff7c7633a1ed997fbfd511c0934774 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Fri, 28 Aug 2020 18:24:39 +0200 Subject: [PATCH] load impressum from content --- README.md | 3 +++ {templates => content.example}/impressum.html | 2 +- .../impressum_text.html | 0 server.py | 15 ++++++++++++++- templates/stub.html | 2 ++ 5 files changed, 20 insertions(+), 2 deletions(-) rename {templates => content.example}/impressum.html (96%) rename {templates => content.example}/impressum_text.html (100%) create mode 100644 templates/stub.html diff --git a/README.md b/README.md index cf0f7f2..b306fc2 100644 --- a/README.md +++ b/README.md @@ -73,4 +73,7 @@ You can add new subpages in the *content*-location via a *subpages.json* file de "identifiert-2" : "html-template-2.html" } +# Contact Page +Templates for the contact information and legal page can be found in the example content directory. It can be edited freely and is just a suggestion. + The templates referenced here must be located in a *subpages/* directory and will be made availiable at */content?id=identifier*. diff --git a/templates/impressum.html b/content.example/impressum.html similarity index 96% rename from templates/impressum.html rename to content.example/impressum.html index e3b909c..b44401b 100644 --- a/templates/impressum.html +++ b/content.example/impressum.html @@ -39,7 +39,7 @@
- {% include 'impressum_text.html' %} + {{ text }}
diff --git a/templates/impressum_text.html b/content.example/impressum_text.html similarity index 100% rename from templates/impressum_text.html rename to content.example/impressum_text.html diff --git a/server.py b/server.py index 846d62b..ac8fce2 100755 --- a/server.py +++ b/server.py @@ -156,7 +156,20 @@ def root(): @app.route("/impressum") def impressum(): - return flask.render_template("impressum.html", conf=app.config) + + impressumPath = os.path.join(app.config["CONTENT_DIR"], "impressum.html") + impressumTextPath = os.path.join(app.config["CONTENT_DIR"], "impressum_text.html") + + impressumText = None + impressumFull = None + + with open(impressumTextPath) as f: + impressumText = flask.Markup(f.read()) + + #impressumText = flask.Markup(impressumTextPath) + with open(impressumPath) as f: + impressumFull = flask.render_template_string(f.read(), conf=app.config, text=impressumText) + return flask.render_template("stub.html", content=impressumFull) @app.route("/people") def people(): diff --git a/templates/stub.html b/templates/stub.html new file mode 100644 index 0000000..da46145 --- /dev/null +++ b/templates/stub.html @@ -0,0 +1,2 @@ +{# this is is an inclusion stub to bypass the flask limitation of only having one template directory #} +{{ content | safe }}