From 8eb340c3ca9f30e48d8019f16d3b2a4385881192 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 1 Aug 2025 17:20:05 +0300 Subject: [PATCH 1/3] make default light/dark themes configurable, add support for main application and login form --- classes/Config.php | 8 ++++++++ include/functions.php | 4 ++-- include/login_form.php | 5 +++++ index.php | 3 +++ js/App.js | 4 +++- js/utility.js | 5 ++++- prefs.php | 3 +++ 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index 7be529e41..49715a576 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -214,6 +214,12 @@ class Config { /** scheduled task to send digests, value should be valid cron expression */ const SCHEDULE_SEND_HEADLINES_DIGESTS = "SCHEDULE_SEND_HEADLINES_DIGESTS"; + /** default (fallback) light theme path */ + const DEFAULT_LIGHT_THEME = "DEFAULT_LIGHT_THEME"; + + /** default (fallback) dark (night) theme path */ + const DEFAULT_DARK_THEME = "DEFAULT_DARK_THEME"; + /** default values for all global configuration options */ private const _DEFAULTS = [ Config::DB_TYPE => [ "pgsql", Config::T_STRING ], @@ -280,6 +286,8 @@ class Config { Config::SCHEDULE_EXPIRE_ERROR_LOG => ["@hourly", Config::T_STRING], Config::SCHEDULE_EXPIRE_LOCK_FILES => ["@hourly", Config::T_STRING], Config::SCHEDULE_SEND_HEADLINES_DIGESTS => ["@hourly", Config::T_STRING], + Config::DEFAULT_LIGHT_THEME => [ "light.css", Config::T_STRING], + Config::DEFAULT_DARK_THEME => [ "night.css", Config::T_STRING], ]; private static ?Config $instance = null; diff --git a/include/functions.php b/include/functions.php index ae403ca84..24b5c8538 100644 --- a/include/functions.php +++ b/include/functions.php @@ -464,14 +464,14 @@ return false; } - function get_theme_path(string $theme): string { + function get_theme_path(string $theme, string $default = ""): string { $check = "themes/$theme"; if (file_exists($check)) return $check; $check = "themes.local/$theme"; if (file_exists($check)) return $check; - return ""; + return $default; } function theme_exists(string $theme): bool { diff --git a/include/login_form.php b/include/login_form.php index 8fa578c11..e601ca619 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -33,6 +33,11 @@ require({cache:{}}); + + diff --git a/js/App.js b/js/App.js index 5c4be5ea0..1ac3a43f0 100644 --- a/js/App.js +++ b/js/App.js @@ -173,7 +173,7 @@ const App = { if (link) { if (navigator.onLine) { - const css_override = is_night ? "themes/night.css" : "themes/light.css"; + const css_override = is_night ? App.getInitParam("default_dark_theme") : App.getInitParam("default_light_theme"); link.setAttribute("href", css_override + "?" + Date.now()); } else if (retry < 5) { console.log("nightModeChanged: we're offline, will attempt to retry..."); @@ -704,6 +704,8 @@ const App = { window.onerror = this.Error.onWindowError; this.setInitParam("csrf_token", __csrf_token); + this.setInitParam("default_light_theme", __default_light_theme); + this.setInitParam("default_dark_theme", __default_dark_theme); this.setupNightModeDetection(() => { parser.parse(); diff --git a/js/utility.js b/js/utility.js index 43ad5644e..070e9e2d1 100644 --- a/js/utility.js +++ b/js/utility.js @@ -7,8 +7,11 @@ window.addEventListener("load", function() { apply_night_mode: function (is_night, link) { console.log("night mode changed to", is_night); + const light_theme = typeof __default_light_theme != 'undefined' ? __default_light_theme : 'themes/light.css'; + const dark_theme = typeof __default_dark_theme != 'undefined' ? __default_dark_theme : 'themes/dark.css'; + if (link) { - const css_override = is_night ? "themes/night.css" : "themes/light.css"; + const css_override = is_night ? dark_theme : light_theme; link.setAttribute("href", css_override + "?" + Date.now()); } diff --git a/prefs.php b/prefs.php index 36d496d5e..9c9980e2a 100644 --- a/prefs.php +++ b/prefs.php @@ -29,6 +29,9 @@ From 0d0745da44f7ee8ec1eba8f5ed30802a60842ddf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 4 Aug 2025 19:54:12 +0300 Subject: [PATCH 2/3] add necessary plumbing for auto light/dark switch for the forgotpass handler --- classes/Handler_Public.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/classes/Handler_Public.php b/classes/Handler_Public.php index 405d16d24..23f4dd2d2 100644 --- a/classes/Handler_Public.php +++ b/classes/Handler_Public.php @@ -438,15 +438,23 @@ class Handler_Public extends Handler { - +
+ + + + + ".__("Password recovery").""; From 19fc3bff213d56f52982eb53bdc8eb9d910f882e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 4 Aug 2025 20:05:59 +0300 Subject: [PATCH 3/3] drop unused legacy (?) handler method OPML->import() --- classes/OPML.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/classes/OPML.php b/classes/OPML.php index bae00b8bc..0560cc5f5 100644 --- a/classes/OPML.php +++ b/classes/OPML.php @@ -20,33 +20,6 @@ class OPML extends Handler_Protected { return $rc; } - function import(): void { - $owner_uid = $_SESSION["uid"]; - - header('Content-Type: text/html; charset=utf-8'); - - print " - - ".stylesheet_tag("themes/light.css")." - ".__("OPML Utility")." - - - -

".__('OPML Utility')."

"; - - Feeds::_add_cat("Imported feeds", $owner_uid); - - $this->opml_notice(__("Importing OPML...")); - - $this->opml_import($owner_uid); - - print "
- -
"; - - print "
"; - } - // Export private function opml_export_category(int $owner_uid, int $cat_id, bool $hide_private_feeds = false, bool $include_settings = true): string {