Add support for setting a human-friendly SITE_NAME

This commit is contained in:
Jonas Schäfer
2021-01-22 15:28:06 +01:00
parent 2f7b99c3cc
commit 0d03cd5227
7 changed files with 31 additions and 18 deletions

View File

@@ -30,6 +30,13 @@ SNIKKET_WEB_PROSODY_ENDPOINT='http://localhost:5280'
# This must be set for login to work correctly. # This must be set for login to work correctly.
SNIKKET_WEB_DOMAIN='localhost' 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 # OPTIONAL SETTINGS
# ================= # =================

View File

@@ -140,6 +140,7 @@ class AppConfig:
secret_key = environ.var() secret_key = environ.var()
prosody_endpoint = environ.var() prosody_endpoint = environ.var()
domain = environ.var() domain = environ.var()
site_name = environ.var("")
avatar_cache_ttl = environ.var(1800, converter=int) avatar_cache_ttl = environ.var(1800, converter=int)
languages = environ.var(["de", "en"], converter=autosplit) 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["SECRET_KEY"] = config.secret_key
app.config["PROSODY_ENDPOINT"] = config.prosody_endpoint app.config["PROSODY_ENDPOINT"] = config.prosody_endpoint
app.config["SNIKKET_DOMAIN"] = config.domain 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.config["AVATAR_CACHE_TTL"] = config.avatar_cache_ttl
app.context_processor(proc) app.context_processor(proc)

View File

@@ -9,13 +9,14 @@
<h1>{% trans %}About Snikket{% endtrans %}</h1> <h1>{% trans %}About Snikket{% endtrans %}</h1>
<p>{% trans snikket_url="https://snikket.org" %}To learn more about Snikket, visit the <a href="{{ snikket_url}}">Snikket website</a>.{% endtrans %}</p> <p>{% trans snikket_url="https://snikket.org" %}To learn more about Snikket, visit the <a href="{{ snikket_url}}">Snikket website</a>.{% endtrans %}</p>
<h2>{% trans %}About this Server{% endtrans %}</h2> <h2>{% trans %}About this Server{% endtrans %}</h2>
<p>{% trans domain=config["SNIKKET_DOMAIN"] %}This is the Snikket server <em>{{ domain }}</em>.{% endtrans %}</p> <p>{% trans site_name=config["SITE_NAME"] %}This is the Snikket server <em>{{ site_name }}</em>.{% endtrans %}</p>
<h3>{% trans %}Licenses{% endtrans %}</h3> <h3>{% trans %}Licenses{% endtrans %}</h3>
<p>{% trans agpl_url="https://www.gnu.org/licenses/agpl.html" %}The web portal software is licensed under the terms of the <a href="{{ agpl_url }}">Affero GNU General Public License, version 3.0 or later</a>. The full terms of the license can be reviewed using the aforementioned link.{% endtrans %}</p> <p>{% trans agpl_url="https://www.gnu.org/licenses/agpl.html" %}The web portal software is licensed under the terms of the <a href="{{ agpl_url }}">Affero GNU General Public License, version 3.0 or later</a>. The full terms of the license can be reviewed using the aforementioned link.{% endtrans %}</p>
<p>{% trans source_url="https://github.com/snikket-im/snikket-web-portal/" %}The source code of the web portal can be downloaded and viewed in <a href="{{ source_url }}">its GitHub repository</a>.{% endtrans %}</p> <p>{% trans source_url="https://github.com/snikket-im/snikket-web-portal/" %}The source code of the web portal can be downloaded and viewed in <a href="{{ source_url }}">its GitHub repository</a>.{% endtrans %}</p>
<p>{% 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 <a href="{{ source_url }}">Googles Material Icons</a>, made available by Google under the terms of the <a href="{{ apache20_url }}">Apache 2.0 License</a>.{% endtrans %}</p> <p>{% 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 <a href="{{ source_url }}">Googles Material Icons</a>, made available by Google under the terms of the <a href="{{ apache20_url }}">Apache 2.0 License</a>.{% endtrans %}</p>
<h3>{% trans %}Software Versions{% endtrans %}</h3> <h3>{% trans %}Software Versions{% endtrans %}</h3>
<pre>Snikket Server (unknown) <pre>Snikket Server
Domain: {{ config["SNIKKET_DOMAIN"] }}
Snikket Web Portal ({{ version }}) Snikket Web Portal ({{ version }})
{%- if extra_versions -%} {%- if extra_versions -%}
{% for name, version in extra_versions.items() %} {% for name, version in extra_versions.items() %}

View File

@@ -10,7 +10,7 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<div id="mwrap"><main><div class="form layout-expanded"> <div id="mwrap"><main><div class="form layout-expanded">
<h1 class="form-title">{{ config["SNIKKET_DOMAIN"] }}</h1> <h1 class="form-title">{{ config["SITE_NAME"] }}</h1>
<p class="form-desc">{{ _("Enter your Snikket address and password to manage your account.") }}</p> <p class="form-desc">{{ _("Enter your Snikket address and password to manage your account.") }}</p>
<form method="POST" action="{{ url_for('.login') }}" name="login"> <form method="POST" action="{{ url_for('.login') }}" name="login">
{{ form.csrf_token }} {{ form.csrf_token }}

View File

@@ -2,7 +2,7 @@
{% from "library.j2" import box, form_button %} {% from "library.j2" import box, form_button %}
{% block body %} {% block body %}
<div id="topbar" class="{% block topbar_classes %}{% endblock %}"> <div id="topbar" class="{% block topbar_classes %}{% endblock %}">
<header><a href="{{ url_for('.index') }}"><span>{{ config["SNIKKET_DOMAIN"] }}</span></a></header> <header><a href="{{ url_for('.index') }}"><span>{{ config["SITE_NAME"] }}</span></a></header>
{% block topbar_left %}{% endblock %} {% block topbar_left %}{% endblock %}
<div class="filler"></div> <div class="filler"></div>
{% block topbar_right %}{% endblock %} {% block topbar_right %}{% endblock %}

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: SnikketWeb 0.1.0\n" "Project-Id-Version: SnikketWeb 0.1.0\n"
"Report-Msgid-Bugs-To: jonas@zombofant.net\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" "PO-Revision-Date: 2020-03-07 16:32+0100\n"
"Last-Translator: Jonas Schäfer <jonas@zombofant.net>\n" "Last-Translator: Jonas Schäfer <jonas@zombofant.net>\n"
"Language: de\n" "Language: de\n"
@@ -94,19 +94,19 @@ msgstr "Benutzer hinzufügen"
msgid "Main" msgid "Main"
msgstr "Kern" msgstr "Kern"
#: snikket_web/main.py:37 #: snikket_web/main.py:36
msgid "Address" msgid "Address"
msgstr "Adresse" msgstr "Adresse"
#: snikket_web/main.py:42 #: snikket_web/main.py:41
msgid "Password" msgid "Password"
msgstr "Passwort" msgstr "Passwort"
#: snikket_web/main.py:47 #: snikket_web/main.py:46
msgid "Sign in" msgid "Sign in"
msgstr "Anmelden" msgstr "Anmelden"
#: snikket_web/main.py:73 #: snikket_web/main.py:72
msgid "Invalid user name or password." msgid "Invalid user name or password."
msgstr "Benutzername oder Passwort falsch." msgstr "Benutzername oder Passwort falsch."
@@ -178,9 +178,9 @@ msgid "About this Server"
msgstr "Über diesen Server" msgstr "Über diesen Server"
#: snikket_web/templates/about.html:12 #: snikket_web/templates/about.html:12
#, python-format #, fuzzy, python-format
msgid "This is the Snikket server <em>%(domain)s</em>." msgid "This is the Snikket server <em>%(site_name)s</em>."
msgstr "Dies ist der Snikket-Server <em>%(domain)s</em>." msgstr "Dies ist der Snikket-Server <em>%(site_name)s</em>."
#: snikket_web/templates/about.html:13 #: snikket_web/templates/about.html:13
msgid "Licenses" msgid "Licenses"

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: 2020-03-07 16:50+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n" "Language: en\n"
@@ -94,19 +94,19 @@ msgstr ""
msgid "Main" msgid "Main"
msgstr "" msgstr ""
#: snikket_web/main.py:37 #: snikket_web/main.py:36
msgid "Address" msgid "Address"
msgstr "" msgstr ""
#: snikket_web/main.py:42 #: snikket_web/main.py:41
msgid "Password" msgid "Password"
msgstr "" msgstr ""
#: snikket_web/main.py:47 #: snikket_web/main.py:46
msgid "Sign in" msgid "Sign in"
msgstr "" msgstr ""
#: snikket_web/main.py:73 #: snikket_web/main.py:72
#, fuzzy #, fuzzy
msgid "Invalid user name or password." msgid "Invalid user name or password."
msgstr "" msgstr ""
@@ -179,7 +179,7 @@ msgstr ""
#: snikket_web/templates/about.html:12 #: snikket_web/templates/about.html:12
#, python-format #, python-format
msgid "This is the Snikket server <em>%(domain)s</em>." msgid "This is the Snikket server <em>%(site_name)s</em>."
msgstr "" msgstr ""
#: snikket_web/templates/about.html:13 #: snikket_web/templates/about.html:13
@@ -696,3 +696,6 @@ msgstr ""
#~ msgid "All users on this instance have already been added." #~ msgid "All users on this instance have already been added."
#~ msgstr "" #~ msgstr ""
#~ msgid "This is the Snikket server <em>%(domain)s</em>."
#~ msgstr ""