From eefca6150f153c35b40a6683fd733b450182b979 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 8 Aug 2026 18:39:35 +0200 Subject: [PATCH 01/33] Added Theming --- cps/admin.py | 8 +++- cps/templates/config_view_edit.html | 5 +- cps/templates/http_error.html | 6 +-- cps/templates/layout.html | 28 +++++------ cps/templates/login.html | 2 +- cps/templates/shelfdown.html | 7 ++- cps/themes.py | 72 +++++++++++++++++++++++++++++ 7 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 cps/themes.py diff --git a/cps/admin.py b/cps/admin.py index 7bddc1bd1..3ba6fe245 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -44,7 +44,7 @@ from sqlalchemy.orm.attributes import flag_modified from sqlalchemy.exc import IntegrityError, OperationalError, InvalidRequestError, ArgumentError from sqlalchemy.sql.expression import func, or_, text -from . import constants, logger, helper, services, cli_param +from . import constants, logger, helper, services, cli_param, themes from . import db, calibre_db, ub, web_server, config, updater_thread, gdriveutils, \ kobo_sync_status, schedule from .helper import check_valid_domain, send_test_mail, reset_password, generate_password_hash, check_email, \ @@ -121,6 +121,8 @@ def before_request(): g.allow_anonymous = config.config_anonbrowse g.allow_upload = config.config_uploading g.current_theme = config.config_theme + g.themes = themes.get_available_themes() + g.theme = themes.get_theme(config.config_theme) g.config_authors_max = config.config_authors_max if ('/static/' not in request.path and not config.db_configured and request.endpoint not in ('admin.ajax_db_config', @@ -589,6 +591,10 @@ def update_view_configuration(): return view_configuration() _config_int(to_save, "config_restricted_column") + if not themes.is_valid_theme(to_save.get("config_theme", "0")): + flash(_("Invalid Theme"), category="error") + log.debug("Invalid Theme") + return view_configuration() _config_int(to_save, "config_theme") _config_int(to_save, "config_random_books") _config_int(to_save, "config_books_per_page") diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index e4fea44d7..c1f4e1654 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -39,8 +39,9 @@
diff --git a/cps/templates/http_error.html b/cps/templates/http_error.html index ad3640920..53b315817 100644 --- a/cps/templates/http_error.html +++ b/cps/templates/http_error.html @@ -15,9 +15,9 @@ - {% if g.current_theme == 1 %} - - {% endif %} + {% for theme_css in g.theme['css_files'] %} + + {% endfor %}
diff --git a/cps/templates/layout.html b/cps/templates/layout.html index dfb347ae3..71c1b774f 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -18,12 +18,11 @@ {% block header %}{% endblock %} - {% if g.current_theme == 1 %} - - - {% endif %} + {% for theme_css in g.theme['css_files'] %} + + {% endfor %} - +