From f78ae614702a79d43a6083f3d8880ac9cb026f05 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 26 Oct 2022 16:05:49 +0200 Subject: [proxy] Make some improvements to the URL patterns doc page internationalization and make it accessible from items import page --- .../common_jinja_templates/base.html.jinja | 41 ++++++++++++++++++++-- src/hydrilla/locales/en_US/LC_MESSAGES/messages.po | 32 ++++++++++------- src/hydrilla/proxy/self_doc/doc_base.html.jinja | 4 +-- .../proxy/self_doc/url_patterns.html.jinja | 18 +++++----- .../web_ui/templates/hkt_mitm_it_base.html.jinja | 5 +++ .../proxy/web_ui/templates/import.html.jinja | 4 ++- 6 files changed, 77 insertions(+), 27 deletions(-) (limited to 'src/hydrilla') diff --git a/src/hydrilla/common_jinja_templates/base.html.jinja b/src/hydrilla/common_jinja_templates/base.html.jinja index f8a5200..cdaffe3 100644 --- a/src/hydrilla/common_jinja_templates/base.html.jinja +++ b/src/hydrilla/common_jinja_templates/base.html.jinja @@ -63,7 +63,10 @@ code in a proprietary work, I am not going to enforce this in court. {% macro label(label_text, label_name=none) %} {% set for_attr = label_name and (label_name + "_field") %} {% endmacro %} @@ -116,6 +119,10 @@ code in a proprietary work, I am not going to enforce this in court. {% endmacro %} +{% macro doc_link(doc_url) %} + +{% endmacro %} + {% block head %} @@ -165,7 +172,7 @@ code in a proprietary work, I am not going to enforce this in court. margin: 0 0 10px 0; } - .section-label { + .section-label > span:first-child { font-style: italic; text-decoration: underline #ccc; } @@ -242,6 +249,36 @@ code in a proprietary work, I am not going to enforce this in court. border-radius: 0; } + .doc-link { + display: inline-block; + width: 1.2em; + height: 1em; + } + + .doc-link::after { + content: "?"; + position:absolute; + display: inline-block; + width:1.2em; + height:1.2em; + line-height: 1.2em; + border: 2px solid #ffffff88; + border-radius: 1em; + transform: translate(1px, calc(-0.1em - 1px)); + background-color: #4caf50; + color:white; + text-align: center; + font-style: normal; + font-family: initial; + font-size: 90%; + font-weight:bold; + } + + .doc-link:hover::after { + color: #ffffffaa; + border-color: #4caf50; + } + code > pre { overflow-x: auto; background-color: #f0f0f0; diff --git a/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po b/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po index 35e4646..2b922ed 100644 --- a/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po +++ b/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: hydrilla 2.0\n" "Report-Msgid-Bugs-To: koszko@koszko.org\n" -"POT-Creation-Date: 2022-10-26 14:26+0200\n" +"POT-Creation-Date: 2022-10-26 16:03+0200\n" "PO-Revision-Date: 2022-02-12 00:00+0000\n" "Last-Translator: Wojtek Kosior \n" "Language: en_US\n" @@ -319,6 +319,14 @@ msgstr "Requested file could not be found." msgid "api.resource_not_enabled_for_access" msgstr "Requested resource is not enabled for access." +#: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:23 +msgid "doc.url_patterns.title" +msgstr "URL patterns" + +#: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:26 +msgid "doc.url_patterns.h_big" +msgstr "URL patterns" + #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:30 msgid "doc.url_patterns.html.intro" msgstr "" @@ -333,7 +341,7 @@ msgstr "" "somethingelse." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:35 -msgid "doc.url_patterns.heading.employed_solution" +msgid "doc.url_patterns.h_medium.employed_solution" msgstr "Employed solution" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:38 @@ -353,7 +361,7 @@ msgstr "" "types of wildcards are handled separately." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:47 -msgid "doc.url_patterns.label.domain_wildcards" +msgid "doc.url_patterns.h_small.domain_wildcards" msgstr "Domain wildcards" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:50 @@ -399,7 +407,7 @@ msgstr "" "iliketrains.example.com or example.com)" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:70 -msgid "doc.url_patterns.label.path_wildcards" +msgid "doc.url_patterns.h_small.path_wildcards" msgstr "Path wildcards" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:73 @@ -476,7 +484,7 @@ msgstr "" " asterisks is being considered." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:105 -msgid "doc.url_patterns.label.protocol_wildcards" +msgid "doc.url_patterns.h_small.protocol_wildcards" msgstr "URL scheme wildcard" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:108 @@ -503,7 +511,7 @@ msgstr "" "behavior is likely to change in the future versions of Haketilo." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:117 -msgid "doc.url_patterns.label.wildcard_priorities" +msgid "doc.url_patterns.h_small.wildcard_priorities" msgstr "Wildcard pattern priorities and querying" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:120 @@ -565,7 +573,7 @@ msgstr "" "starting with http*:// have been once again omitted." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:286 -msgid "doc.url_patterns.label.limits" +msgid "doc.url_patterns.h_small.limits" msgstr "Limits" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:289 @@ -576,7 +584,7 @@ msgstr "" "processed URLs. This is no longer the case." #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:294 -msgid "doc.url_patterns.heading.alt_solution" +msgid "doc.url_patterns.h_medium.alt_solution" msgstr "Alternative solution idea: mimicking web server mechanics" #: src/hydrilla/proxy/self_doc/url_patterns.html.jinja:297 @@ -705,19 +713,19 @@ msgstr "Description (optional)" msgid "web_ui.import.patterns_field_label" msgstr "URL patterns (each on its own line)" -#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:104 +#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:106 msgid "web_ui.err.invalid_ad_hoc_patterns" msgstr "Chosen patterns are not valid." -#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:108 +#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:110 msgid "web_ui.import.script_text_field_label" msgstr "JavaScript to execute on pages that match one of the patterns" -#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:111 +#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:113 msgid "web_ui.import.lic_text_field_label" msgstr "Package license text (optional)" -#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:116 +#: src/hydrilla/proxy/web_ui/templates/import.html.jinja:118 msgid "web_ui.import.install_ad_hoc_button" msgstr "Add new package" diff --git a/src/hydrilla/proxy/self_doc/doc_base.html.jinja b/src/hydrilla/proxy/self_doc/doc_base.html.jinja index cef1abb..7982142 100644 --- a/src/hydrilla/proxy/self_doc/doc_base.html.jinja +++ b/src/hydrilla/proxy/self_doc/doc_base.html.jinja @@ -59,7 +59,5 @@ code in a proprietary work, I am not going to enforce this in court. {% endmacro %} {% macro small_heading(text) %} - + {{ label(text) }} {% endmacro %} diff --git a/src/hydrilla/proxy/self_doc/url_patterns.html.jinja b/src/hydrilla/proxy/self_doc/url_patterns.html.jinja index 45a0db3..7d2718f 100644 --- a/src/hydrilla/proxy/self_doc/url_patterns.html.jinja +++ b/src/hydrilla/proxy/self_doc/url_patterns.html.jinja @@ -20,10 +20,10 @@ code in a proprietary work, I am not going to enforce this in court. #} {% extends "doc_base.html.jinja" %} -{% block title %}URL patterns{% endblock %} +{% block title %}{{ _('doc.url_patterns.title') }}{% endblock %} {% block main %} - {{ big_heading('URL patterns') }} + {{ big_heading(_('doc.url_patterns.h_big')) }} {% call section() %} {% call paragraph() %} @@ -32,7 +32,7 @@ code in a proprietary work, I am not going to enforce this in court. {% endcall %} {% call section() %} - {{ medium_heading(_('doc.url_patterns.heading.employed_solution')) }} + {{ medium_heading(_('doc.url_patterns.h_medium.employed_solution')) }} {% call paragraph() %} {{ _('doc.url_patterns.html.wildcards_intro')|safe }} @@ -44,7 +44,7 @@ code in a proprietary work, I am not going to enforce this in court. {% endcall %} {% call section() %} - {{ small_heading(_('doc.url_patterns.label.domain_wildcards')) }} + {{ small_heading(_('doc.url_patterns.h_small.domain_wildcards')) }} {% call paragraph() %} {{ _('doc.url_patterns.html.domain_wildcards_intro')|safe }} @@ -67,7 +67,7 @@ code in a proprietary work, I am not going to enforce this in court. {% endcall %} {% call section() %} - {{ small_heading(_('doc.url_patterns.label.path_wildcards')) }} + {{ small_heading(_('doc.url_patterns.h_small.path_wildcards')) }} {% call paragraph() %} {{ _('doc.url_patterns.html.path_wildcards_intro')|safe }} @@ -102,7 +102,7 @@ code in a proprietary work, I am not going to enforce this in court. {% endcall %} {% call section() %} - {{ small_heading(_('doc.url_patterns.label.protocol_wildcards')) }} + {{ small_heading(_('doc.url_patterns.h_small.protocol_wildcards')) }} {% call paragraph() %} {{ _('doc.url_patterns.html.protocol_wildcards')|safe }} @@ -114,7 +114,7 @@ code in a proprietary work, I am not going to enforce this in court. {% endcall %} {% call section() %} - {{ small_heading(_('doc.url_patterns.label.wildcard_priorities')) }} + {{ small_heading(_('doc.url_patterns.h_small.wildcard_priorities')) }} {% call paragraph() %} {{ _('doc.url_patterns.priorities_intro') }} @@ -283,7 +283,7 @@ https://***.example.com/*** {% endcall %} {% call section() %} - {{ small_heading(_('doc.url_patterns.label.limits')) }} + {{ small_heading(_('doc.url_patterns.h_small.limits')) }} {% call paragraph() %} {{ _('doc.url_patterns.limits')|safe }} @@ -291,7 +291,7 @@ https://***.example.com/*** {% endcall %} {% call section() %} - {{ medium_heading(_('doc.url_patterns.heading.alt_solution')) }} + {{ medium_heading(_('doc.url_patterns.h_medium.alt_solution')) }} {% call paragraph() %} {{ _('doc.url_patterns.url_pattern_drawbacks') }} 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 a83d3e8..79d85df 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 @@ -114,3 +114,8 @@ code in a proprietary work, I am not going to enforce this in court. {{ super() }} {% endblock body %} + +{% macro hkt_doc_link(page_name) %} + {% set doc_url = url_for('home.home_doc', page=page_name) %} + {{ doc_link(doc_url) }} +{% endmacro %} diff --git a/src/hydrilla/proxy/web_ui/templates/import.html.jinja b/src/hydrilla/proxy/web_ui/templates/import.html.jinja index 7f3be50..afeb5a2 100644 --- a/src/hydrilla/proxy/web_ui/templates/import.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/import.html.jinja @@ -99,7 +99,9 @@ code in a proprietary work, I am not going to enforce this in court. {{ label(_('web_ui.import.description_field_label'), 'description') }} {{ form_field('description', required=false, height=3) }} - {{ label(_('web_ui.import.patterns_field_label'), 'patterns') }} + {% call label(_('web_ui.import.patterns_field_label'), 'patterns') %} + {{ hkt_doc_link('url_patterns') }} + {% endcall %} {% if invalid_ad_hoc_patterns is defined %} {{ error_note(_('web_ui.err.invalid_ad_hoc_patterns')) }} {% endif %} -- cgit v1.2.3