aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui/templates
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-09-28 12:48:45 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-29 12:53:36 +0200
commitffe6e681b281eef2c1e62bbc6feefb0b85d040ca (patch)
tree0aa141073403beae9590135fd047d7a2ebd8fe76 /src/hydrilla/proxy/web_ui/templates
parent1a1f750ccdc1d52a7b1bd648b2188fa6e7c1a4b8 (diff)
downloadhaketilo-hydrilla-ffe6e681b281eef2c1e62bbc6feefb0b85d040ca.tar.gz
haketilo-hydrilla-ffe6e681b281eef2c1e62bbc6feefb0b85d040ca.zip
[proxy] make it possible to create "ad hoc" packages through the web UI
Diffstat (limited to 'src/hydrilla/proxy/web_ui/templates')
-rw-r--r--src/hydrilla/proxy/web_ui/templates/base.html.jinja36
-rw-r--r--src/hydrilla/proxy/web_ui/templates/import.html.jinja120
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/load_from_disk.html.jinja68
-rw-r--r--src/hydrilla/proxy/web_ui/templates/repos/add.html.jinja25
4 files changed, 159 insertions, 90 deletions
diff --git a/src/hydrilla/proxy/web_ui/templates/base.html.jinja b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
index c0eecce..eb9cb57 100644
--- a/src/hydrilla/proxy/web_ui/templates/base.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
@@ -62,6 +62,36 @@ code in a proprietary work, I am not going to enforce this in court.
</aside>
{% endmacro %}
+{% macro form_label(label_text, label_name=none) %}
+ {% set for_attr = label_name and (label_name + "_field") %}
+ <label {{ {'for': for_attr, 'class': 'block-with-bottom-margin'}|xmlattr }}>
+ {{ label_text }}
+ </label>
+{% endmacro %}
+
+{% macro form_field(field_name, required=true, sep_after=true, height=none) %}
+ <div class="flex-row">
+ {%
+ set attrs = {
+ 'id': field_name + '_field',
+ 'name': field_name,
+ 'required': '' if required else none,
+ 'rows': height
+ }
+ %}
+
+ {% if height is none %}
+ <input{{ attrs|xmlattr }}>
+ {% else %}
+ <textarea{{ attrs|xmlattr }}></textarea>
+ {% endif %}
+ </div>
+
+ {% if sep_after %}
+ <div class="horizontal-separator"></div>
+ {% endif %}
+{% endmacro %}
+
<html>
<head>
{% block head %}
@@ -134,6 +164,10 @@ code in a proprietary work, I am not going to enforce this in court.
margin: 0 0 10px 0;
}
+ textarea {
+ resize: none;
+ }
+
.green-button, .red-button, .blue-button {
border: none;
border-radius: 2px;
@@ -243,7 +277,7 @@ code in a proprietary work, I am not going to enforce this in court.
('items.packages', _('web_ui.base.nav.packages'), false),
('items.libraries', _('web_ui.base.nav.libraries'), true),
('repos.repos', _('web_ui.base.nav.repos'), false),
- ('items.load_from_disk', _('web_ui.base.nav.load'), false)
+ ('import.items_import', _('web_ui.base.nav.import'), false)
]
%}
<ul id="nav">
diff --git a/src/hydrilla/proxy/web_ui/templates/import.html.jinja b/src/hydrilla/proxy/web_ui/templates/import.html.jinja
new file mode 100644
index 0000000..a8f16a4
--- /dev/null
+++ b/src/hydrilla/proxy/web_ui/templates/import.html.jinja
@@ -0,0 +1,120 @@
+{#
+SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0
+
+Proxy web UI item loading page.
+
+This file is part of Hydrilla&Haketilo.
+
+Copyright (C) 2022 Wojtek Kosior
+
+Dual licensed under
+* GNU General Public License v3.0 or later and
+* Creative Commons Attribution Share Alike 4.0 International.
+
+You can choose to use either of these licenses or both.
+
+
+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" %}
+
+{% block title %} {{ _('web_ui.import.title') }} {% endblock %}
+
+{% block style %}
+ {{ super() }}
+
+ input[type="file"]::-webkit-file-selector-button,
+ input[type="file"]::file-selector-button {
+ display: none;
+ }
+
+ input[type="file"] {
+ display: block;
+ font-size: inherit;
+ font-style: inherit;
+ }
+{% endblock %}
+
+{% block main %}
+ <h3>{{ _('web_ui.import.heading') }}</h3>
+
+ <h4>{{ _('web_ui.import.heading_import_from_file') }}</h4>
+
+ <form method="POST" enctype="multipart/form-data">
+ <input name="action" type="hidden" value="import_from_file">
+
+ {% if uploaded_file_not_zip is defined %}
+ {{ error_note(_('web_ui.err.uploaded_file_not_zip')) }}
+ {% endif %}
+
+ {% if invalid_uploaded_malcontent is defined %}
+ {{ error_note(_('web_ui.err.invalid_uploaded_malcontent')) }}
+ {% endif %}
+
+ <input id="items_zipfile" name="items_zipfile" type="file"
+ accept=".zip,application/zip" required=""
+ class="block-with-bottom-margin">
+
+ <label class="green-button block-with-bottom-margin" for="items_zipfile">
+ {{ _('web_ui.import.choose_zipfile_button') }}
+ </label>
+
+ <div class="horizontal-separator"></div>
+
+ <div class="flex-row">
+ <button class="green-button">
+ {{ _('web_ui.import.install_from_file_button') }}
+ </button>
+ </div>
+ </form>
+
+ <div class="horizontal-separator"></div>
+
+ <h4>{{ _('web_ui.import.heading_import_ad_hoc') }}</h4>
+
+ {% if invalid_ad_hoc_package is defined %}
+ {{ error_note(_('web_ui.err.invalid_ad_hoc_package')) }}
+ {% endif %}
+
+ <form method="POST">
+ <input name="action" type="hidden" value="import_ad_hoc">
+
+ {{ form_label(_('web_ui.import.identifier_field_label'), 'identifier') }}
+ {% if invalid_ad_hoc_identifier is defined %}
+ {{ error_note(_('web_ui.err.invalid_ad_hoc_identifier')) }}
+ {% endif %}
+ {{ form_field('identifier') }}
+
+ {{ form_label(_('web_ui.import.long_name_field_label'), 'long_name') }}
+ {{ form_field('long_name', required=false) }}
+
+ {{ form_label(_('web_ui.import.version_field_label'), 'version') }}
+ {% if invalid_ad_hoc_version is defined %}
+ {{ error_note(_('web_ui.err.invalid_ad_hoc_version')) }}
+ {% endif %}
+ {{ form_field('version', required=false) }}
+
+ {{ form_label(_('web_ui.import.description_field_label'), 'description') }}
+ {{ form_field('description', required=false, height=3) }}
+
+ {{ form_label(_('web_ui.import.patterns_field_label'), 'patterns') }}
+ {% if invalid_ad_hoc_patterns is defined %}
+ {{ error_note(_('web_ui.err.invalid_ad_hoc_patterns')) }}
+ {% endif %}
+ {{ form_field('patterns', height=3) }}
+
+ {{ form_label(_('web_ui.import.script_text_field_label'), 'script_text') }}
+ {{ form_field('script_text', required=false, height=15) }}
+
+ {{ form_label(_('web_ui.import.lic_text_field_label'), 'license_text') }}
+ {{ form_field('license_text', required=false, height=10) }}
+
+ <div class="flex-row">
+ <button class="green-button">
+ {{ _('web_ui.import.install_ad_hoc_button') }}
+ </button>
+ </div>
+ </form>
+{% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/load_from_disk.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/load_from_disk.html.jinja
deleted file mode 100644
index f5d7b34..0000000
--- a/src/hydrilla/proxy/web_ui/templates/items/load_from_disk.html.jinja
+++ /dev/null
@@ -1,68 +0,0 @@
-{#
-SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0
-
-Proxy web UI item loading page.
-
-This file is part of Hydrilla&Haketilo.
-
-Copyright (C) 2022 Wojtek Kosior
-
-Dual licensed under
-* GNU General Public License v3.0 or later and
-* Creative Commons Attribution Share Alike 4.0 International.
-
-You can choose to use either of these licenses or both.
-
-
-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" %}
-
-{% block title %} {{ _('web_ui.load_from_disk.title') }} {% endblock %}
-
-{% block style %}
- {{ super() }}
-
- input[type="file"]::-webkit-file-selector-button,
- input[type="file"]::file-selector-button {
- display: none;
- }
-
- input[type="file"] {
- display: block;
- font-size: inherit;
- font-style: inherit;
- }
-{% endblock %}
-
-{% block main %}
- <h3>{{ _('web_ui.load_from_disk.heading') }}</h3>
-
- <form method="POST" enctype="multipart/form-data">
- {% if uploaded_file_not_zip is defined %}
- {{ error_note(_('web_ui.err.uploaded_file_not_zip')) }}
- {% endif %}
-
- {% if invalid_uploaded_malcontent is defined %}
- {{ error_note(_('web_ui.err.invalid_uploaded_malcontent')) }}
- {% endif %}
-
- <input id="items_zipfile" name="items_zipfile" type="file"
- accept=".zip,application/zip" required=""
- class="block-with-bottom-margin">
-
- <label class="green-button block-with-bottom-margin" for="items_zipfile">
- {{ _('web_ui.load_from_disk.choose_zipfile_button') }}
- </label>
-
- <div class="horizontal-separator"></div>
-
- <div class="flex-row">
- <button class="green-button">
- {{ _('web_ui.load_from_disk.install_button') }}
- </button>
- </div>
- </form>
-{% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/repos/add.html.jinja b/src/hydrilla/proxy/web_ui/templates/repos/add.html.jinja
index 6bc1c19..be4933a 100644
--- a/src/hydrilla/proxy/web_ui/templates/repos/add.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/repos/add.html.jinja
@@ -25,37 +25,20 @@ code in a proprietary work, I am not going to enforce this in court.
{% block main %}
<h3>{{ _('web_ui.repos.add.heading') }}</h3>
<form method="POST">
+ {{ form_label(_('web_ui.repos.add.name_field_label'), 'name') }}
{% if repo_name_invalid is defined %}
{{ error_note(_('web_ui.err.repo_name_invalid')) }}
{% endif %}
-
{% if repo_name_taken is defined %}
{{ error_note(_('web_ui.err.repo_name_taken')) }}
{% endif %}
+ {{ form_field('name') }}
- <label for="name_field" class="block-with-bottom-margin">
- {{ _('web_ui.repos.add.name_field_label') }}
- </label>
-
- <div class="flex-row">
- <input id="name_field" name="name" required="">
- </div>
-
- <div class="horizontal-separator"></div>
-
+ {{ form_label(_('web_ui.repos.add.url_field_label'), 'url') }}
{% if repo_url_invalid is defined %}
{{ error_note(_('web_ui.err.repo_url_invalid')) }}
{% endif %}
-
- <label for="url_field" class="block-with-bottom-margin">
- {{ _('web_ui.repos.add.url_field_label') }}
- </label>
-
- <div class="flex-row">
- <input id="url_field" name="url" required="">
- </div>
-
- <div class="horizontal-separator"></div>
+ {{ form_field('url') }}
<div class="flex-row block-with-bottom-margin">
<button class="green-button">