From 894ff89e90eae4f9a2839c318c3aaa1c8de4dd1b Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 23 May 2024 11:59:32 +0100 Subject: [PATCH] add default theme config option --- config.php.example | 3 +++ misc/header.php | 6 ++++-- misc/search_engine.php | 7 +++++-- settings.php | 13 ++++++++----- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config.php.example b/config.php.example index 9b2c21b..0484ef1 100644 --- a/config.php.example +++ b/config.php.example @@ -8,6 +8,9 @@ "language" => "", "number_of_results" => 10, + // The default theme css to use + "default_theme" => "dark", + // You can use any Invidious instance here "invidious_instance_for_video_results" => "https://invidious.snopyta.org", diff --git a/misc/header.php b/misc/header.php index 47e8c56..66b6998 100644 --- a/misc/header.php +++ b/misc/header.php @@ -1,4 +1,6 @@ - + @@ -9,6 +11,6 @@ " type="application/opensearchdescription+xml" href="opensearch.xml?method=POST" rel="search"/> default_theme ?? "dark")); echo "static/css/" . $theme . ".css"; ?>"/> diff --git a/misc/search_engine.php b/misc/search_engine.php index 27d6fda..00e1f6b 100644 --- a/misc/search_engine.php +++ b/misc/search_engine.php @@ -60,7 +60,10 @@ } function load_opts() { - $opts = require_once "config.php"; + if (isset($GLOBALS["opts"])) + $opts = $GLOBALS["opts"]; + else + $opts = require_once "config.php"; # account for the old, misspelled options if (isset($opts->disable_bittorent_search)) @@ -76,7 +79,7 @@ $opts->type = (int) ($_REQUEST["t"] ?? 0); $opts->page = (int) ($_REQUEST["p"] ?? 0); - $opts->theme = $_REQUEST["theme"] ?? trim(htmlspecialchars($_COOKIE["theme"] ?? "amoled")); + $opts->theme = $_REQUEST["theme"] ?? trim(htmlspecialchars($_COOKIE["theme"] ?? $opts->default_theme ?? "dark")); $opts->safe_search = (int) ($_REQUEST["safe"] ?? 0) == 1 || isset($_COOKIE["safe_search"]); diff --git a/settings.php b/settings.php index b77467f..411b907 100644 --- a/settings.php +++ b/settings.php @@ -38,9 +38,9 @@ die(); } - $opts = load_opts(); require_once "misc/header.php"; + $opts = load_opts(); ?> LibreY - <?php printtext("settings_title");?> @@ -53,7 +53,9 @@