aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-26 14:30:28 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-26 14:31:42 +0200
commit01834fe901117809490fbf59b104833bdd88ea20 (patch)
tree1b3c2d7e2099cab404275fb774f9ad6f631c5bc0 /src/hydrilla/proxy/web_ui
parent9efa3c0fcc55d0998b648c69d1918f1779c4c6e9 (diff)
downloadhaketilo-hydrilla-01834fe901117809490fbf59b104833bdd88ea20.tar.gz
haketilo-hydrilla-01834fe901117809490fbf59b104833bdd88ea20.zip
[proxy] add documentation page describing URL patterns in Haketilo
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
-rw-r--r--src/hydrilla/proxy/web_ui/root.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index 4430bb6..917c063 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -51,6 +51,7 @@ from ... import item_infos
from ... import common_jinja_templates
from .. import state as st
from .. import http_messages
+from .. import self_doc
from . import rules
from . import repos
from . import items
@@ -94,13 +95,13 @@ class WebUIAppImpl(_app.WebUIApp):
self._haketilo_app_lock = Lock()
- loader = jinja2.PackageLoader(__package__)
- combined_loader = common_jinja_templates.combine_with_loaders([loader])
+ loaders = [jinja2.PackageLoader(__package__), self_doc.loader]
+ combined_loader = common_jinja_templates.combine_with_loaders(loaders)
self.jinja_options = {
**self.jinja_options,
'loader': combined_loader,
- 'autoescape': jinja2.select_autoescape(['html.jinja']),
+ 'autoescape': jinja2.select_autoescape(['.jinja']),
'lstrip_blocks': True,
'extensions': [
*self.jinja_options.get('extensions', []),
@@ -118,6 +119,7 @@ class WebUIAppImpl(_app.WebUIApp):
self.jinja_env.globals['ItemType'] = item_infos.ItemType
self.jinja_env.globals['MappingUseMode'] = st.MappingUseMode
self.jinja_env.globals['versions'] = versions
+ self.jinja_env.globals['doc_base_filename'] = 'doc_base.html.jinja'
self.before_request(authenticate_by_referrer)
@@ -181,6 +183,16 @@ def home_post() -> werkzeug.Response:
return flask.redirect(flask.url_for('.home'), 303)
+@home_bp.route('/doc/<path:page>', methods=['GET'])
+def home_doc(page: str) -> str:
+ if page not in self_doc.page_names:
+ flask.abort(404)
+
+ return flask.render_template(
+ f'{page}.html.jinja',
+ doc_output = 'html_hkt_mitm_it'
+ )
+
blueprints_main = \
(rules.bp, repos.bp, items.bp, items_import.bp, prompts.bp, home_bp)