From 979b1e081eb8042c843e91ff834f7c7e39ba06f1 Mon Sep 17 00:00:00 2001 From: dqos <8611981+dqos@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:12:45 +0100 Subject: [PATCH] Add (auto) Dark mode --- LookingGlass.php | 6 ++++++ README.md | 1 + bootstrap.php | 1 + config.dist.php | 7 ++++++- docker/php-fpm/src/config.php | 7 ++++++- index.php | 35 ++++++++++++++++++++++++++++++++--- 6 files changed, 52 insertions(+), 5 deletions(-) diff --git a/LookingGlass.php b/LookingGlass.php index a8911df..dc71779 100644 --- a/LookingGlass.php +++ b/LookingGlass.php @@ -50,6 +50,9 @@ class LookingGlass if (!defined('LG_LOGO')) { die('LG_LOGO not found in config.php'); } + if (!defined('LG_LOGO_DARK')) { + die('LG_LOGO_DARK not found in config.php'); + } if (!defined('LG_LOGO_URL')) { die('LG_LOGO_URL not found in config.php'); } @@ -122,6 +125,9 @@ class LookingGlass if (!defined('LG_CHECK_LATENCY')) { die('LG_CHECK_LATENCY not found in config.php'); } + if (!defined('LG_THEME')) { + die('LG_THEME not found in config.php'); + } //@formatter:on } diff --git a/README.md b/README.md index 2768168..9162e23 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ made user-friendly for everyone to use. It allows you to execute network related - Easy to customize and to configure. - DNS checking to prevent unnecessary executions. - Latency feature from visitor to LG. +- Dark/light/auto mode theme. ### Requirements - Any Linux distribution, this has been tested on RHEL 8 + 9. diff --git a/bootstrap.php b/bootstrap.php index 92a2191..56b4c55 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -41,6 +41,7 @@ $templateData = [ 'custom_head' => LG_CUSTOM_HEAD, 'logo_url' => LG_LOGO_URL, 'logo_data' => LG_LOGO, + 'logo_data_dark' => LG_LOGO_DARK, // 'block_network' => LG_BLOCK_NETWORK, 'block_lookingglas' => LG_BLOCK_LOOKINGGLAS, diff --git a/config.dist.php b/config.dist.php index 37a39a2..9e2034a 100644 --- a/config.dist.php +++ b/config.dist.php @@ -5,10 +5,15 @@ use Hybula\LookingGlass; const LG_TITLE = 'Looking Glass'; // Define a logo, this can be HTML too, see the other example for an image; -const LG_LOGO = '

Company Looking Glass

'; +const LG_LOGO = '

Company Looking Glass

'; +const LG_LOGO_DARK = '

Company Looking Glass

'; + // Define the URL where the logo points to; const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/'; +// Theme mode; +const LG_THEME = 'auto'; + // Enable the latency check feature; const LG_CHECK_LATENCY = false; diff --git a/docker/php-fpm/src/config.php b/docker/php-fpm/src/config.php index ea5ddce..62e8ab1 100644 --- a/docker/php-fpm/src/config.php +++ b/docker/php-fpm/src/config.php @@ -5,10 +5,15 @@ use Hybula\LookingGlass; const LG_TITLE = 'Looking Glass'; // Define a logo, this can be HTML too, see the other example for an image; -const LG_LOGO = '

Company Looking Glass

'; +const LG_LOGO = '

Company Looking Glass

'; +const LG_LOGO_DARK = '

Company Looking Glass

'; + // Define the URL where the logo points to; const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/'; +// Theme mode; +const LG_THEME = 'auto'; + // Enable the latency check feature; const LG_CHECK_LATENCY = false; diff --git a/index.php b/index.php index 9d9f6b6..90d49de 100644 --- a/index.php +++ b/index.php @@ -96,7 +96,7 @@ if (LG_CHECK_LATENCY) { $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(random_bytes(12)); ?> - + @@ -115,9 +115,12 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
- + + + +