[mod] add manifest.json template and route (#5859)

URLs, name and colors are automatically rendered into manifest.json.
Furthermore user preference of theme (light, dark, black) and theme colors are
respected.  Theme colors can be set in settings.yml
This commit is contained in:
Ruben D.
2026-03-13 21:33:06 +01:00
committed by Markus Heiser
parent 924fc52f54
commit 3dc4d5daa8
5 changed files with 85 additions and 0 deletions
+23
View File
@@ -1215,6 +1215,29 @@ def opensearch():
return resp
@app.route('/manifest.json', methods=['GET'])
def manifest():
theme = sxng_request.preferences.get_value('simple_style')
if theme not in ("light", "dark", "black"):
theme = "light"
theme_color = get_setting(f'brand.pwa_colors.theme_color_{theme}')
background_color = get_setting(f'brand.pwa_colors.background_color_{theme}')
ret = render('manifest.json', theme_color=theme_color, background_color=background_color)
resp = Response(response=ret, status=200, mimetype="application/json")
return resp
@app.route('/logo/<resolution>')
def manifest_logo(resolution=0):
theme = sxng_request.preferences.get_value("theme")
return send_from_directory(
os.path.join(app.root_path, settings['ui']['static_path'], 'themes', theme, 'img', 'logos'), # type: ignore
resolution,
mimetype='image/vnd.microsoft.icon',
)
@app.route('/favicon.ico')
def favicon():
theme = sxng_request.preferences.get_value("theme")