aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-22 14:49:37 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-22 14:54:42 +0200
commit44c09ab27ce8407f4fc5c75df9cdf309df8463eb (patch)
tree648f2b53456f9886b5e243a1734073342d8ab154 /src
parent59a4b477dd922d2f839a717fe199501e7cb71e6e (diff)
downloadhaketilo-hydrilla-44c09ab27ce8407f4fc5c75df9cdf309df8463eb.tar.gz
haketilo-hydrilla-44c09ab27ce8407f4fc5c75df9cdf309df8463eb.zip
[proxy] extract potentially reusable HTML jinja templates into a separate directory
Diffstat (limited to 'src')
-rw-r--r--src/hydrilla/common_jinja_templates.py16
-rw-r--r--src/hydrilla/common_jinja_templates/base.html.jinja (renamed from src/hydrilla/proxy/web_ui/templates/base.html.jinja)9
-rw-r--r--src/hydrilla/common_jinja_templates/import/checkbox_tricks.html.jinja (renamed from src/hydrilla/proxy/web_ui/templates/import/checkbox_tricks.html.jinja)0
-rw-r--r--src/hydrilla/common_jinja_templates/include/checkbox_tricks_style.css.jinja (renamed from src/hydrilla/proxy/web_ui/templates/include/checkbox_tricks_style.css.jinja)0
-rw-r--r--src/hydrilla/common_jinja_templates/include/item_list_style.css.jinja (renamed from src/hydrilla/proxy/web_ui/templates/include/item_list_style.css.jinja)0
-rw-r--r--src/hydrilla/proxy/web_ui/root.py6
-rw-r--r--src/hydrilla/proxy/web_ui/templates/hkt_mitm_it_base.html.jinja2
-rw-r--r--src/hydrilla/proxy/web_ui/templates/landing.html.jinja2
-rw-r--r--src/hydrilla/proxy/web_ui/templates/web_ui_base.html.jinja22
9 files changed, 47 insertions, 10 deletions
diff --git a/src/hydrilla/common_jinja_templates.py b/src/hydrilla/common_jinja_templates.py
new file mode 100644
index 0000000..732db41
--- /dev/null
+++ b/src/hydrilla/common_jinja_templates.py
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: CC0-1.0
+
+# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
+#
+# Available under the terms of Creative Commons Zero v1.0 Universal.
+
+import typing as t
+
+from jinja2 import PackageLoader, ChoiceLoader, BaseLoader
+
+
+def loader() -> BaseLoader:
+ return PackageLoader(__package__, package_path='common_jinja_templates')
+
+def combine_with_loaders(loaders: t.Iterable[BaseLoader]) -> BaseLoader:
+ return ChoiceLoader([loader(), *loaders])
diff --git a/src/hydrilla/proxy/web_ui/templates/base.html.jinja b/src/hydrilla/common_jinja_templates/base.html.jinja
index f89b39a..08178b3 100644
--- a/src/hydrilla/proxy/web_ui/templates/base.html.jinja
+++ b/src/hydrilla/common_jinja_templates/base.html.jinja
@@ -1,7 +1,7 @@
{#
SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0
-Proxy web UI base page template.
+Hydrilla&Haketilo reusable base page template.
This file is part of Hydrilla&Haketilo.
@@ -93,11 +93,6 @@ code in a proprietary work, I am not going to enforce this in court.
<html>
<head>
{% block head %}
- <title>
- {% block title required %}{% endblock %}
- -
- {{ _('web_ui.base.title.haketilo_proxy') }}
- </title>
<style>
{% block style %}
body {
@@ -222,7 +217,7 @@ code in a proprietary work, I am not going to enforce this in court.
display: none !important;
}
{% endblock style %}
- </style>
+ </style>
{% endblock head %}
</head>
<body>
diff --git a/src/hydrilla/proxy/web_ui/templates/import/checkbox_tricks.html.jinja b/src/hydrilla/common_jinja_templates/import/checkbox_tricks.html.jinja
index 4ad9ca1..4ad9ca1 100644
--- a/src/hydrilla/proxy/web_ui/templates/import/checkbox_tricks.html.jinja
+++ b/src/hydrilla/common_jinja_templates/import/checkbox_tricks.html.jinja
diff --git a/src/hydrilla/proxy/web_ui/templates/include/checkbox_tricks_style.css.jinja b/src/hydrilla/common_jinja_templates/include/checkbox_tricks_style.css.jinja
index a47a438..a47a438 100644
--- a/src/hydrilla/proxy/web_ui/templates/include/checkbox_tricks_style.css.jinja
+++ b/src/hydrilla/common_jinja_templates/include/checkbox_tricks_style.css.jinja
diff --git a/src/hydrilla/proxy/web_ui/templates/include/item_list_style.css.jinja b/src/hydrilla/common_jinja_templates/include/item_list_style.css.jinja
index 063cd01..063cd01 100644
--- a/src/hydrilla/proxy/web_ui/templates/include/item_list_style.css.jinja
+++ b/src/hydrilla/common_jinja_templates/include/item_list_style.css.jinja
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index d775730..4430bb6 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -48,6 +48,7 @@ import werkzeug
from ...translations import translation as make_translation
from ... import versions
from ... import item_infos
+from ... import common_jinja_templates
from .. import state as st
from .. import http_messages
from . import rules
@@ -93,9 +94,12 @@ class WebUIAppImpl(_app.WebUIApp):
self._haketilo_app_lock = Lock()
+ loader = jinja2.PackageLoader(__package__)
+ combined_loader = common_jinja_templates.combine_with_loaders([loader])
+
self.jinja_options = {
**self.jinja_options,
- 'loader': jinja2.PackageLoader(__package__),
+ 'loader': combined_loader,
'autoescape': jinja2.select_autoescape(['html.jinja']),
'lstrip_blocks': True,
'extensions': [
diff --git a/src/hydrilla/proxy/web_ui/templates/hkt_mitm_it_base.html.jinja b/src/hydrilla/proxy/web_ui/templates/hkt_mitm_it_base.html.jinja
index 6a6de99..a83d3e8 100644
--- a/src/hydrilla/proxy/web_ui/templates/hkt_mitm_it_base.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/hkt_mitm_it_base.html.jinja
@@ -18,7 +18,7 @@ I, Wojtek Kosior, thereby promise not to sue for violation of this
file's licenses. Although I request that you do not make use of this
code in a proprietary work, I am not going to enforce this in court.
#}
-{% extends "base.html.jinja" %}
+{% extends "web_ui_base.html.jinja" %}
{% set settings = get_settings() %}
diff --git a/src/hydrilla/proxy/web_ui/templates/landing.html.jinja b/src/hydrilla/proxy/web_ui/templates/landing.html.jinja
index 6314cfd..9e40ac0 100644
--- a/src/hydrilla/proxy/web_ui/templates/landing.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/landing.html.jinja
@@ -18,7 +18,7 @@ I, Wojtek Kosior, thereby promise not to sue for violation of this
file's licenses. Although I request that you do not make use of this
code in a proprietary work, I am not going to enforce this in court.
#}
-{% extends "base.html.jinja" %}
+{% extends "web_ui_base.html.jinja" %}
{% block title %} {{ _('web_ui.landing.title') }} {% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/web_ui_base.html.jinja b/src/hydrilla/proxy/web_ui/templates/web_ui_base.html.jinja
new file mode 100644
index 0000000..0d5d582
--- /dev/null
+++ b/src/hydrilla/proxy/web_ui/templates/web_ui_base.html.jinja
@@ -0,0 +1,22 @@
+{#
+SPDX-License-Identifier: CC0-1.0
+
+Proxy web UI base page template.
+
+This file is part of Hydrilla&Haketilo.
+
+Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
+
+Available under the terms of Creative Commons Zero v1.0 Universal.
+#}
+{% extends "base.html.jinja" %}
+
+{% block head %}
+ {{ super() }}
+
+ <title>
+ {% block title required %}{% endblock %}
+ -
+ {{ _('web_ui.base.title.haketilo_proxy') }}
+ </title>
+{% endblock head %}