Massive code cleanup

- Avoid fighting import cycles using a factory function
- Collapse useless subpackages into simple modules
- Move flask plugins / infrastructure in own module
- Refactor how blueprints are used to localize information about
  URL routing to app factory
This commit is contained in:
Jonas Schäfer
2021-01-17 10:18:20 +01:00
parent e476d9b7c2
commit fa700bba07
16 changed files with 330 additions and 291 deletions

View File

@@ -19,7 +19,7 @@ Snikket Web Portal ({{ version }})</pre>
AVATAR_CACHE_TTL = {{ config.get("AVATAR_CACHE_TTL") | repr }}
SECRET_KEY = &lt;hidden&gt;
PROSODY_ENDPOINT = &lt;hidden&gt;</pre> #}
<p><a href="{{ url_for('home') }}" class="button primary">Back to main page</a></pa>
<p><a href="{{ url_for('.home') }}" class="button primary">Back to main page</a></pa>
</div>
</main>
</body>

View File

@@ -17,6 +17,6 @@
</div>
<main>{% block content %}{% endblock %}</main>
<footer>
<ul><li>{% trans about_url=url_for('about') %}A <a href="{{ about_url }}">Snikket</a> server{% endtrans %}</li></ul>
<ul><li>{% trans about_url=url_for('main.about') %}A <a href="{{ about_url }}">Snikket</a> server{% endtrans %}</li></ul>
</footer>
{% endblock %}

View File

@@ -12,7 +12,7 @@
<main><div class="form layout-expanded">
<h1 class="form-title">{{ config["SNIKKET_DOMAIN"] }}</h1>
<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 }}
{% if form.errors %}
{% call box("alert", _("Login failed")) %}
@@ -33,6 +33,6 @@
</from>
</div></main>
<footer>
<ul><li>{% trans about_url=url_for('about') %}A <a href="{{ about_url }}">Snikket</a> server{% endtrans %}</li></ul>
<ul><li>{% trans about_url=url_for('.about') %}A <a href="{{ about_url }}">Snikket</a> server{% endtrans %}</li></ul>
</footer>
{% endblock %}

View File

@@ -3,11 +3,11 @@
<h1>{% trans %}Welcome!{% endtrans %}</h1>
<p>{% trans user_name=user_info.display_name %}Welcome home, {{ user_name }}.{% endtrans %}</p>
<div class="welcome-cards">
<a class="card" href="{{ url_for('user.profile') }}">
<a class="card" href="{{ url_for('.profile') }}">
<h2>{% trans %}Update profile{% endtrans %}</h2>
<p>{% trans %}Change display name, set avatar and configure visibility of your personal data to others.{% endtrans %}</p>
</a>
<a class="card" href="{{ url_for('user.change_pw') }}">
<a class="card" href="{{ url_for('.change_pw') }}">
<h2>{% trans %}Change password{% endtrans %}</h2>
</a>
{% if user_info.is_admin %}
@@ -16,7 +16,7 @@
<p>{% trans %}Manage users and invitations of this Snikket instance.{% endtrans %}</p>
</a>
{% endif %}
<a class="card" href="{{ url_for('user.logout') }}">
<a class="card" href="{{ url_for('.logout') }}">
<h2>{% trans %}Log out{% endtrans %}</h2>
<p>{% trans %}Exit the Snikket Web Portal, without logging out your other devices.{% endtrans %}</p>
</a>

View File

@@ -36,7 +36,7 @@
<p>{% trans %}After changing your password, you will have to enter the new password on all of your devices.{% endtrans %}</p>
</div>
<div class="f-bbox">
<a href="{{ url_for('user.index') }}" class="button secondary">{% trans %}Back{% endtrans %}</a>
<a href="{{ url_for('.index') }}" class="button secondary">{% trans %}Back{% endtrans %}</a>
<button type="submit" class="primary">{% trans %}Change password{% endtrans %}</button>
</div>
</form></div>