From 01834fe901117809490fbf59b104833bdd88ea20 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 26 Oct 2022 14:30:28 +0200 Subject: [proxy] add documentation page describing URL patterns in Haketilo --- src/hydrilla/proxy/web_ui/root.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/hydrilla/proxy/web_ui') 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/', 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) -- cgit v1.2.3