add barebones theme switcher

This commit is contained in:
2025-08-17 01:36:55 +03:00
parent fc80823713
commit 89817340c9
4 changed files with 20 additions and 2 deletions

View File

@ -165,6 +165,12 @@ def admin_only(*args, **kwargs):
return decorator
def get_prefers_theme():
if not 'theme' in session:
return 'style'
return session['theme']
@bp.get("/log_in")
@redirect_if_logged_in(".page", username = lambda: get_active_user().username)
def log_in():
@ -288,6 +294,12 @@ def settings_form(username):
# we silently ignore the passed username
# and grab the correct user from the session
user = get_active_user()
theme = request.form.get('theme', default='default')
if theme == 'default':
if 'theme' in session:
session.pop('theme')
else:
session['theme'] = theme
topic_sort_by = request.form.get('topic_sort_by', default='activity')
if topic_sort_by == 'activity' or topic_sort_by == 'thread':
sort_by = session['sort_by'] = topic_sort_by