Introduce the shared stub /static for providing all static files

master
Dimitri Huisman 3 years ago
parent eb74a72a52
commit 5d81846c5d

@ -38,7 +38,7 @@ RUN set -eu \
&& pip3 install -r requirements.txt \
&& apk del --no-cache build-dep
COPY --from=assets static ./mailu/ui/static
COPY --from=assets static ./mailu/static_files/static
COPY mailu ./mailu
COPY migrations ./migrations
COPY start.py /start.py

@ -58,10 +58,11 @@ def create_app_from_config(config):
)
# Import views
from mailu import ui, internal, sso
from mailu import ui, internal, sso, static_files
app.register_blueprint(ui.ui, url_prefix='/ui')
app.register_blueprint(internal.internal, url_prefix='/internal')
app.register_blueprint(sso.sso, url_prefix='/sso')
app.register_blueprint(static_files.static, url_prefix='/static')
return app

@ -1,15 +1,15 @@
{%- import "macros.html" as macros %}
{%- import "bootstrap/utils.html" as utils %}
<!doctype html>
<html lang="{{ session['language'] }}" data-static="{{ url_for('.static', filename='') }}">
<html lang="{{ session['language'] }}" data-static="/static/">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{% trans %}Admin page for{% endtrans %} {{ config["SITENAME"] }}">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Mailu-Admin | {{ config["SITENAME"] }}</title>
<link rel="stylesheet" href="{{ url_for('.static', filename='vendor.css') }}">
<link rel="stylesheet" href="{{ url_for('.static', filename='app.css') }}">
<link rel="stylesheet" href="/static/vendor.css">
<link rel="stylesheet" href="/static/app.css">
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
@ -46,7 +46,7 @@
</nav>
<aside class="main-sidebar sidebar-dark-primary nav-compact elevation-4">
<a class="brand-link bg-mailu-logo"{% if config["LOGO_BACKGROUND"] %} style="background-color:{{ config["LOGO_BACKGROUND"] }}!important;"{% endif %}>
<img src="{{ config["LOGO_URL"] if config["LOGO_URL"] else url_for('.static', filename='mailu.png') }}" width="33" height="33" alt="Mailu" class="brand-image mailu-logo img-circle elevation-3">
<img src="{{ config["LOGO_URL"] if config["LOGO_URL"] else '/static/mailu.png' }}" width="33" height="33" alt="Mailu" class="brand-image mailu-logo img-circle elevation-3">
<span class="brand-text font-weight-light">{{ config["SITENAME"] }}</span>
</a>
{%- include "sidebar_sso.html" %}
@ -80,7 +80,7 @@
</span>
</footer>
</div>
<script src="{{ url_for('.static', filename='vendor.js') }}"></script>
<script src="{{ url_for('.static', filename='app.js') }}"></script>
<script src="/static/vendor.js"></script>
<script src="/static/app.js"></script>
</body>
</html>

@ -0,0 +1,5 @@
from flask import Blueprint
static = Blueprint('static', __name__, static_folder='static', static_url_path='/static')

@ -1,15 +1,15 @@
{%- import "macros.html" as macros %}
{%- import "bootstrap/utils.html" as utils %}
<!doctype html>
<html lang="{{ session['language'] }}" data-static="{{ url_for('.static', filename='') }}">
<html lang="{{ session['language'] }}" data-static="/static/">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{% trans %}Admin page for{% endtrans %} {{ config["SITENAME"] }}">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Mailu-Admin | {{ config["SITENAME"] }}</title>
<link rel="stylesheet" href="{{ url_for('.static', filename='vendor.css') }}">
<link rel="stylesheet" href="{{ url_for('.static', filename='app.css') }}">
<link rel="stylesheet" href="/static/vendor.css">
<link rel="stylesheet" href="/static/app.css">
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
@ -46,7 +46,7 @@
</nav>
<aside class="main-sidebar sidebar-dark-primary nav-compact elevation-4">
<a href="{{ url_for('.domain_list' if current_user.manager_of or current_user.global_admin else '.user_settings') }}" class="brand-link bg-mailu-logo"{% if config["LOGO_BACKGROUND"] %} style="background-color:{{ config["LOGO_BACKGROUND"] }}!important;"{% endif %}>
<img src="{{ config["LOGO_URL"] if config["LOGO_URL"] else url_for('.static', filename='mailu.png') }}" width="33" height="33" alt="Mailu" class="brand-image mailu-logo img-circle elevation-3">
<img src="{{ config["LOGO_URL"] if config["LOGO_URL"] else '/static/mailu.png' }}" width="33" height="33" alt="Mailu" class="brand-image mailu-logo img-circle elevation-3">
<span class="brand-text font-weight-light">{{ config["SITENAME"] }}</span>
</a>
{%- include "sidebar.html" %}
@ -80,7 +80,7 @@
</span>
</footer>
</div>
<script src="{{ url_for('.static', filename='vendor.js') }}"></script>
<script src="{{ url_for('.static', filename='app.js') }}"></script>
<script src="/static/vendor.js"></script>
<script src="/static/app.js"></script>
</body>
</html>

@ -136,19 +136,12 @@ http {
location ^~ /ui/language {
include /etc/nginx/proxy.conf;
proxy_set_header X-Forwarded-Prefix {{ WEB_ADMIN }};
proxy_pass http://$admin;
expires $expires;
}
location ^~ /sso/static {
include /etc/nginx/proxy.conf;
rewrite /sso/static/(.*) /static/$1 permanent;
}
location ^~ /static {
include /etc/nginx/proxy.conf;
rewrite ^/static/(.*) /ui/static/$1 break;
rewrite ^/static/(.*) /static/static/$1 break;
proxy_pass http://$admin;
}
{% endif %}
@ -230,11 +223,6 @@ http {
expires $expires;
}
location ^~ {{ WEB_ADMIN }}/ui/static {
include /etc/nginx/proxy.conf;
rewrite {{ WEB_ADMIN }}/ui/static/(.*) /static/$1 permanent;
}
location {{ WEB_ADMIN }}/antispam {
rewrite ^{{ WEB_ADMIN }}/antispam/(.*) /$1 break;
auth_request /internal/auth/admin;

Loading…
Cancel
Save