diff --git a/app/app.py b/app/app.py index 27e31a6..52e95ea 100644 --- a/app/app.py +++ b/app/app.py @@ -191,9 +191,29 @@ def register_context_processors(app): @app.context_processor def inject_config(): """Inject configuration variables into all templates""" + # Cache-busting token for the uploadable logos. + # + # Must be appended OUTSIDE url_for(): passing 'logo.png?v=1' as the + # filename makes Flask percent-encode the '?' into '%3F', which asks + # for a file literally named "logo.png%3Fv=1" and 404s. + # + # Derived from the newest logo's mtime so that uploading a new logo in + # Admin → Customize Logos is picked up immediately, rather than reusing + # a hardcoded value the browser has already cached. + logo_version = 1 + for _logo_name in ('header_logo.png', 'login_logo.png'): + try: + _mtime = int(os.path.getmtime( + os.path.join(app.config['UPLOAD_FOLDER'], _logo_name))) + logo_version = max(logo_version, _mtime) + except OSError: + # Logo not uploaded yet — keep the current token. + pass + return { 'server_version': app.config['SERVER_VERSION'], 'build_date': app.config['BUILD_DATE'], + 'logo_version': logo_version, 'logo_exists': os.path.exists( os.path.join(app.root_path, app.config['UPLOAD_FOLDERLOGO'], 'logo.png') ) diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html index 5d4a88d..ff9fcb0 100644 --- a/app/templates/auth/login.html +++ b/app/templates/auth/login.html @@ -181,7 +181,7 @@
- DigiServer Logo
diff --git a/app/templates/base.html b/app/templates/base.html index f9a7d30..a242638 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -376,7 +376,7 @@

- DigiServer + DigiServer DigiServer