From 0d03cd52279edd2e327ab4b17f55b2f9fa5a1181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Fri, 22 Jan 2021 15:28:06 +0100 Subject: [PATCH] Add support for setting a human-friendly SITE_NAME --- example.env | 7 +++++++ snikket_web/__init__.py | 2 ++ snikket_web/templates/about.html | 5 +++-- snikket_web/templates/login.html | 2 +- snikket_web/templates/unauth.html | 2 +- .../translations/de/LC_MESSAGES/messages.po | 16 ++++++++-------- .../translations/en/LC_MESSAGES/messages.po | 15 +++++++++------ 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/example.env b/example.env index a1a85f4..00e69ce 100644 --- a/example.env +++ b/example.env @@ -30,6 +30,13 @@ SNIKKET_WEB_PROSODY_ENDPOINT='http://localhost:5280' # This must be set for login to work correctly. SNIKKET_WEB_DOMAIN='localhost' +# A human-friendly name for the Snikket server. +# +# This should not be too wide when rendered to fit into the layout. +# Defaults to SNIKKET_WEB_DOMAIN. +# +#SNIKKET_WEB_SITE_NAME + # OPTIONAL SETTINGS # ================= diff --git a/snikket_web/__init__.py b/snikket_web/__init__.py index ae77d84..8068042 100644 --- a/snikket_web/__init__.py +++ b/snikket_web/__init__.py @@ -140,6 +140,7 @@ class AppConfig: secret_key = environ.var() prosody_endpoint = environ.var() domain = environ.var() + site_name = environ.var("") avatar_cache_ttl = environ.var(1800, converter=int) languages = environ.var(["de", "en"], converter=autosplit) @@ -169,6 +170,7 @@ def create_app() -> quart.Quart: app.config["SECRET_KEY"] = config.secret_key app.config["PROSODY_ENDPOINT"] = config.prosody_endpoint app.config["SNIKKET_DOMAIN"] = config.domain + app.config["SITE_NAME"] = config.site_name or config.domain app.config["AVATAR_CACHE_TTL"] = config.avatar_cache_ttl app.context_processor(proc) diff --git a/snikket_web/templates/about.html b/snikket_web/templates/about.html index 317858d..b6e2f7f 100644 --- a/snikket_web/templates/about.html +++ b/snikket_web/templates/about.html @@ -9,13 +9,14 @@

{% trans %}About Snikket{% endtrans %}

{% trans snikket_url="https://snikket.org" %}To learn more about Snikket, visit the Snikket website.{% endtrans %}

{% trans %}About this Server{% endtrans %}

-

{% trans domain=config["SNIKKET_DOMAIN"] %}This is the Snikket server {{ domain }}.{% endtrans %}

+

{% trans site_name=config["SITE_NAME"] %}This is the Snikket server {{ site_name }}.{% endtrans %}

{% trans %}Licenses{% endtrans %}

{% trans agpl_url="https://www.gnu.org/licenses/agpl.html" %}The web portal software is licensed under the terms of the Affero GNU General Public License, version 3.0 or later. The full terms of the license can be reviewed using the aforementioned link.{% endtrans %}

{% trans source_url="https://github.com/snikket-im/snikket-web-portal/" %}The source code of the web portal can be downloaded and viewed in its GitHub repository.{% endtrans %}

{% trans source_url="https://material.io/resources/icons/", apache20_url="https://www.apache.org/licenses/LICENSE-2.0.txt" %}The icons used in the web portal are Google’s Material Icons, made available by Google under the terms of the Apache 2.0 License.{% endtrans %}

{% trans %}Software Versions{% endtrans %}

-
Snikket Server (unknown)
+		
Snikket Server
+Domain: {{ config["SNIKKET_DOMAIN"] }}
 Snikket Web Portal ({{ version }})
 {%- if extra_versions -%}
 {% for name, version in extra_versions.items() %}
diff --git a/snikket_web/templates/login.html b/snikket_web/templates/login.html
index 24c3691..44334df 100644
--- a/snikket_web/templates/login.html
+++ b/snikket_web/templates/login.html
@@ -10,7 +10,7 @@
 {% endblock %}
 {% block body %}
 
-

{{ config["SNIKKET_DOMAIN"] }}

+

{{ config["SITE_NAME"] }}

{{ _("Enter your Snikket address and password to manage your account.") }}

{{ form.csrf_token }} diff --git a/snikket_web/templates/unauth.html b/snikket_web/templates/unauth.html index fcb6936..a9190bf 100644 --- a/snikket_web/templates/unauth.html +++ b/snikket_web/templates/unauth.html @@ -2,7 +2,7 @@ {% from "library.j2" import box, form_button %} {% block body %}
-
{{ config["SNIKKET_DOMAIN"] }}
+
{{ config["SITE_NAME"] }}
{% block topbar_left %}{% endblock %}
{% block topbar_right %}{% endblock %} diff --git a/snikket_web/translations/de/LC_MESSAGES/messages.po b/snikket_web/translations/de/LC_MESSAGES/messages.po index c26699a..2193e82 100644 --- a/snikket_web/translations/de/LC_MESSAGES/messages.po +++ b/snikket_web/translations/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: SnikketWeb 0.1.0\n" "Report-Msgid-Bugs-To: jonas@zombofant.net\n" -"POT-Creation-Date: 2021-01-21 17:39+0100\n" +"POT-Creation-Date: 2021-01-22 15:27+0100\n" "PO-Revision-Date: 2020-03-07 16:32+0100\n" "Last-Translator: Jonas Schäfer \n" "Language: de\n" @@ -94,19 +94,19 @@ msgstr "Benutzer hinzufügen" msgid "Main" msgstr "Kern" -#: snikket_web/main.py:37 +#: snikket_web/main.py:36 msgid "Address" msgstr "Adresse" -#: snikket_web/main.py:42 +#: snikket_web/main.py:41 msgid "Password" msgstr "Passwort" -#: snikket_web/main.py:47 +#: snikket_web/main.py:46 msgid "Sign in" msgstr "Anmelden" -#: snikket_web/main.py:73 +#: snikket_web/main.py:72 msgid "Invalid user name or password." msgstr "Benutzername oder Passwort falsch." @@ -178,9 +178,9 @@ msgid "About this Server" msgstr "Über diesen Server" #: snikket_web/templates/about.html:12 -#, python-format -msgid "This is the Snikket server %(domain)s." -msgstr "Dies ist der Snikket-Server %(domain)s." +#, fuzzy, python-format +msgid "This is the Snikket server %(site_name)s." +msgstr "Dies ist der Snikket-Server %(site_name)s." #: snikket_web/templates/about.html:13 msgid "Licenses" diff --git a/snikket_web/translations/en/LC_MESSAGES/messages.po b/snikket_web/translations/en/LC_MESSAGES/messages.po index 100bef1..baebebd 100644 --- a/snikket_web/translations/en/LC_MESSAGES/messages.po +++ b/snikket_web/translations/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-01-21 17:39+0100\n" +"POT-Creation-Date: 2021-01-22 15:27+0100\n" "PO-Revision-Date: 2020-03-07 16:50+0100\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -94,19 +94,19 @@ msgstr "" msgid "Main" msgstr "" -#: snikket_web/main.py:37 +#: snikket_web/main.py:36 msgid "Address" msgstr "" -#: snikket_web/main.py:42 +#: snikket_web/main.py:41 msgid "Password" msgstr "" -#: snikket_web/main.py:47 +#: snikket_web/main.py:46 msgid "Sign in" msgstr "" -#: snikket_web/main.py:73 +#: snikket_web/main.py:72 #, fuzzy msgid "Invalid user name or password." msgstr "" @@ -179,7 +179,7 @@ msgstr "" #: snikket_web/templates/about.html:12 #, python-format -msgid "This is the Snikket server %(domain)s." +msgid "This is the Snikket server %(site_name)s." msgstr "" #: snikket_web/templates/about.html:13 @@ -696,3 +696,6 @@ msgstr "" #~ msgid "All users on this instance have already been added." #~ msgstr "" +#~ msgid "This is the Snikket server %(domain)s." +#~ msgstr "" +