aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar maTh <math-home@web.de> 2023-03-04 15:05:58 +0100
committerGravatar GitHub <noreply@github.com> 2023-03-04 15:05:58 +0100
commit068d18b69bae8456669293a8b7dfe9afd827e03d (patch)
treed24e9d3804824c065a7d6d7a9e1b45d163fce476
parentd3966befafab3fe65e753d0ab2166a8bf5fb0d75 (diff)
Add: <meta name="theme-color"> (#5105)
* implemented * themes' metadata.json * fix * fix * retrigger tests * Update lib/Minz/View.php Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * fix --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
-rw-r--r--app/FreshRSS.php4
-rw-r--r--app/layout/layout.phtml1
-rw-r--r--lib/Minz/View.php30
-rw-r--r--p/themes/Alternative-Dark/metadata.json3
-rw-r--r--p/themes/Ansum/metadata.json3
-rw-r--r--p/themes/BlueLagoon/metadata.json3
-rw-r--r--p/themes/Dark-pink/metadata.json3
-rw-r--r--p/themes/Dark/metadata.json3
-rw-r--r--p/themes/Flat/metadata.json3
-rw-r--r--p/themes/Mapco/metadata.json3
-rw-r--r--p/themes/Nord/metadata.json3
-rw-r--r--p/themes/Origine-compact/metadata.json3
-rw-r--r--p/themes/Origine/metadata.json3
-rw-r--r--p/themes/Pafat/metadata.json3
-rw-r--r--p/themes/Screwdriver/metadata.json3
-rw-r--r--p/themes/Swage/metadata.json3
-rw-r--r--p/themes/base-theme/metadata.json3
17 files changed, 63 insertions, 14 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 76ced841c..dd16fad6c 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -141,6 +141,10 @@ class FreshRSS extends Minz_FrontController {
FreshRSS_View::prependStyle(Minz_Url::display(FreshRSS::getThemeFileUrl($theme_id, $filename)));
}
}
+
+ if (!empty($theme['theme-color'])) {
+ FreshRSS_View::appendThemeColors($theme['theme-color']);
+ }
}
//Use prepend to insert before extensions. Added in reverse order.
if (Minz_Request::controllerName() !== 'index') {
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 1e9ce6905..f0ade992f 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -11,6 +11,7 @@ if (_t('gen.dir') === 'rtl') {
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
+ <?= FreshRSS_View::metaThemeColor() ?>
<?= FreshRSS_View::headStyle() ?>
<script id="jsonVars" type="application/json">
<?php $this->renderHelper('javascript_vars'); ?>
diff --git a/lib/Minz/View.php b/lib/Minz/View.php
index 459ef1e23..3b5052c36 100644
--- a/lib/Minz/View.php
+++ b/lib/Minz/View.php
@@ -19,6 +19,7 @@ class Minz_View {
private static $title = '';
private static $styles = array ();
private static $scripts = array ();
+ private static $themeColors;
private static $params = array ();
@@ -238,6 +239,35 @@ class Minz_View {
}
/**
+ * @param array|string $themeColors
+ */
+ public static function appendThemeColors($themeColors): void {
+ self::$themeColors = $themeColors;
+ }
+
+ /**
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color
+ */
+ public static function metaThemeColor(): string {
+ $meta = '';
+
+ if (!empty(self::$themeColors['light'])) {
+ $meta .= '<meta name="theme-color" media="(prefers-color-scheme: light)" content="' . htmlspecialchars(self::$themeColors['light']) . '" />';
+ }
+ if (!empty(self::$themeColors['dark'])) {
+ $meta .= '<meta name="theme-color" media="(prefers-color-scheme: dark)" content="' . htmlspecialchars(self::$themeColors['dark']) . '" />';
+ }
+ if (!empty(self::$themeColors['default'])) {
+ $meta .= '<meta name="theme-color" content="' . htmlspecialchars(self::$themeColors['default']) . '" />';
+ }
+ if (empty(self::$themeColors['default']) && !empty(self::$themeColors) && empty(self::$themeColors['light']) && empty(self::$themeColors['dark'])) {
+ $meta .= '<meta name="theme-color" content="' . htmlspecialchars(self::$themeColors) . '" />';
+ }
+
+ return $meta;
+ }
+
+ /**
* Gestion des scripts JS
*/
public static function headScript () {
diff --git a/p/themes/Alternative-Dark/metadata.json b/p/themes/Alternative-Dark/metadata.json
index 707ed1da5..99f13b549 100644
--- a/p/themes/Alternative-Dark/metadata.json
+++ b/p/themes/Alternative-Dark/metadata.json
@@ -3,5 +3,6 @@
"author": "Ghost",
"description": "Save my eyes!!!",
"version": 0.1,
- "files": ["_frss.css", "adark.css"]
+ "files": ["_frss.css", "adark.css"],
+ "theme-color": "#171717"
}
diff --git a/p/themes/Ansum/metadata.json b/p/themes/Ansum/metadata.json
index 23b1a96cc..ab2359967 100644
--- a/p/themes/Ansum/metadata.json
+++ b/p/themes/Ansum/metadata.json
@@ -3,5 +3,6 @@
"author": "Thomas Guesnon",
"description": "Thème sablonneux",
"version": 0.1,
- "files": ["_frss.css", "ansum.css"]
+ "files": ["_frss.css", "ansum.css"],
+ "theme-color": "#fbf9f6"
}
diff --git a/p/themes/BlueLagoon/metadata.json b/p/themes/BlueLagoon/metadata.json
index 37750c631..5540187ab 100644
--- a/p/themes/BlueLagoon/metadata.json
+++ b/p/themes/BlueLagoon/metadata.json
@@ -4,5 +4,6 @@
"description": "C’est un cocktail (bis)! C’est la version plus fresh de Screwdriver. C’est… c’est… un thème pour l’agrégateur de flux RSS FreshRSS. En toute modestie, ce thème tue du Nyan Cat.",
"version": 1.0,
"files": ["_frss.css","BlueLagoon.css"],
- "deprecated": true
+ "deprecated": true,
+ "theme-color": "#fefefd"
}
diff --git a/p/themes/Dark-pink/metadata.json b/p/themes/Dark-pink/metadata.json
index 7e582eefd..b76c73da1 100644
--- a/p/themes/Dark-pink/metadata.json
+++ b/p/themes/Dark-pink/metadata.json
@@ -3,5 +3,6 @@
"author": "Miicat_47",
"description": "Nice dawk pink theme. >_< UwU",
"version": 0.1,
- "files": ["_frss.css", "../Alternative-Dark/adark.css", "pinkdark.css"]
+ "files": ["_frss.css", "../Alternative-Dark/adark.css", "pinkdark.css"],
+ "theme-color": "#171717"
}
diff --git a/p/themes/Dark/metadata.json b/p/themes/Dark/metadata.json
index b38428995..19a2287a6 100644
--- a/p/themes/Dark/metadata.json
+++ b/p/themes/Dark/metadata.json
@@ -3,5 +3,6 @@
"author": "AD",
"description": "The dark side of the “Origine” theme",
"version": 0.2,
- "files": ["_frss.css", "dark.css"]
+ "files": ["_frss.css", "dark.css"],
+ "theme-color": "#111111"
}
diff --git a/p/themes/Flat/metadata.json b/p/themes/Flat/metadata.json
index bd7ce6157..acb9b0668 100644
--- a/p/themes/Flat/metadata.json
+++ b/p/themes/Flat/metadata.json
@@ -4,5 +4,6 @@
"description": "Thème plat pour FreshRSS",
"version": 0.2,
"files": ["_frss.css", "flat.css"],
- "deprecated": true
+ "deprecated": true,
+ "theme-color": "#34495e"
}
diff --git a/p/themes/Mapco/metadata.json b/p/themes/Mapco/metadata.json
index 353d0908a..e22a7875b 100644
--- a/p/themes/Mapco/metadata.json
+++ b/p/themes/Mapco/metadata.json
@@ -3,5 +3,6 @@
"author": "Thomas Guesnon",
"description": "Thème pour FreshRSS",
"version": 0.1,
- "files": ["_frss.css", "mapco.css"]
+ "files": ["_frss.css", "mapco.css"],
+ "theme-color": "#303136"
}
diff --git a/p/themes/Nord/metadata.json b/p/themes/Nord/metadata.json
index eeb9ef808..07fd420d3 100644
--- a/p/themes/Nord/metadata.json
+++ b/p/themes/Nord/metadata.json
@@ -3,5 +3,6 @@
"author": "joelchrono12",
"description": "A simple theme based on Nord's color scheme",
"version": 0.1,
- "files": ["_frss.css","nord.css"]
+ "files": ["_frss.css","nord.css"],
+ "theme-color": "#2e3440"
}
diff --git a/p/themes/Origine-compact/metadata.json b/p/themes/Origine-compact/metadata.json
index ded2f0616..acc5caa1d 100644
--- a/p/themes/Origine-compact/metadata.json
+++ b/p/themes/Origine-compact/metadata.json
@@ -3,5 +3,6 @@
"author": "Kevin Papst",
"description": "A theme that tries to use the screen size more efficiently, based on Origine",
"version": 0.1,
- "files": ["_frss.css", "../Origine/origine.css", "origine-compact.css"]
+ "files": ["_frss.css", "../Origine/origine.css", "origine-compact.css"],
+ "theme-color": {"dark": "#1f1f1f", "light": "#f0f0f0"}
}
diff --git a/p/themes/Origine/metadata.json b/p/themes/Origine/metadata.json
index 721f9af8b..7b0bbd7af 100644
--- a/p/themes/Origine/metadata.json
+++ b/p/themes/Origine/metadata.json
@@ -3,5 +3,6 @@
"author": "Marien Fressinaud",
"description": "Le thème par défaut pour FreshRSS",
"version": 0.2,
- "files": ["_frss.css", "origine.css"]
+ "files": ["_frss.css", "origine.css"],
+ "theme-color": {"dark": "#1f1f1f", "light": "#f0f0f0"}
}
diff --git a/p/themes/Pafat/metadata.json b/p/themes/Pafat/metadata.json
index f70442378..355d5bfc0 100644
--- a/p/themes/Pafat/metadata.json
+++ b/p/themes/Pafat/metadata.json
@@ -3,5 +3,6 @@
"author": "Plopoyop",
"description": "Un thème pour FreshRSS",
"version": 0.2,
- "files": ["_frss.css", "pafat.css"]
+ "files": ["_frss.css", "pafat.css"],
+ "theme-color": "#f4f4f4"
}
diff --git a/p/themes/Screwdriver/metadata.json b/p/themes/Screwdriver/metadata.json
index 8da73f80c..87deba45a 100644
--- a/p/themes/Screwdriver/metadata.json
+++ b/p/themes/Screwdriver/metadata.json
@@ -4,5 +4,6 @@
"description": "C’est un cocktail ! C’est chaud mais « fresh » à la fois. Ce thème tue du chaton.",
"version": 1.1,
"files": ["_frss.css","screwdriver.css"],
- "deprecated" : true
+ "deprecated" : true,
+ "theme-color": "#fefefe"
}
diff --git a/p/themes/Swage/metadata.json b/p/themes/Swage/metadata.json
index d51b026cc..f9aded562 100644
--- a/p/themes/Swage/metadata.json
+++ b/p/themes/Swage/metadata.json
@@ -3,5 +3,6 @@
"author": "Patrick Crandol",
"description": "A Fresh take on the interface, inspired by the Flat Theme.",
"version": 1.0,
- "files": ["_frss.css", "swage.css"]
+ "files": ["_frss.css", "swage.css"],
+ "theme-color": "#22303d"
}
diff --git a/p/themes/base-theme/metadata.json b/p/themes/base-theme/metadata.json
index 8ba17b101..8abbdc230 100644
--- a/p/themes/base-theme/metadata.json
+++ b/p/themes/base-theme/metadata.json
@@ -3,5 +3,6 @@
"author": "Your name",
"description": "A wonderful base theme",
"version": 0.1,
- "files": ["frss.css", "base.css"]
+ "files": ["frss.css", "base.css"],
+ "theme-color": "#123456"
}