add default theme config option

This commit is contained in:
davidovski
2024-05-23 11:59:32 +01:00
parent d1be316d40
commit 894ff89e90
4 changed files with 20 additions and 9 deletions
+3
View File
@@ -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",
+4 -2
View File
@@ -1,4 +1,6 @@
<?php require_once "locale/localization.php"; ?>
<?php require_once "locale/localization.php";
$GLOBALS["opts"] = require_once "config.php";
?>
<!DOCTYPE html >
<html lang="en">
<head>
@@ -9,6 +11,6 @@
<link rel="stylesheet" type="text/css" href="static/css/styles.css"/>
<link title="<?php printtext("page_title"); ?>" type="application/opensearchdescription+xml" href="opensearch.xml?method=POST" rel="search"/>
<link rel="stylesheet" type="text/css" href="<?php
$theme = $_REQUEST["theme"] ?? trim(htmlspecialchars($_COOKIE["theme"] ?? "amoled"));
$theme = $_REQUEST["theme"] ?? trim(htmlspecialchars($_COOKIE["theme"] ?? $GLOBALS["opts"]->default_theme ?? "dark"));
echo "static/css/" . $theme . ".css";
?>"/>
+5 -2
View File
@@ -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"]);
+8 -5
View File
@@ -38,9 +38,9 @@
die();
}
$opts = load_opts();
require_once "misc/header.php";
$opts = load_opts();
?>
<title>LibreY - <?php printtext("settings_title");?></title>
@@ -53,7 +53,9 @@
<label for="theme"><?php printtext("settings_theme");?>:</label>
<select name="theme">
<?php
$themes = "<option value=\"amoled\">AMOLED</option>
$default = $opts->default_theme ?? "dark";
$themes = "
<option value=\"dark\">Dark</option>
<option value=\"darker\">Darker</option>
<option value=\"amoled\">AMOLED</option>
<option value=\"light\">Light</option>
@@ -73,11 +75,12 @@
<option value=\"ubuntu\">Ubuntu</option>
<option value=\"tokyo_night\">Tokyo Night</option>";
if (isset($opts->theme)) {
$theme = $opts->theme;
$themes = str_replace($theme . "\"", $theme . "\" selected", $themes);
if (!isset($opts->theme)) {
$theme = $default;
}
$theme = $opts->theme;
$themes = str_replace($theme . "\"", $theme . "\" selected", $themes);
echo $themes;
?>
</select>