A free, self-hostable news aggregator…
Mise à jour nom thèmes + chargement robuste des thèmes
Alexandre Alapetitef720d41cbfb1
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.phpindex 5b5770cbe..70144a8db 100755--- a/app/Controllers/configureController.php+++ b/app/Controllers/configureController.php@@ -157,7 +157,11 @@ class FreshRSS_configure_Controller extends Minz_ActionController {'scroll' => Minz_Request::param('mark_scroll', false),'reception' => Minz_Request::param('mark_upon_reception', false),));- $this->view->conf->_theme(Minz_Request::param('theme', 'default'));+ $themeId = Minz_Request::param('theme', '');+ if ($themeId == '') {+ $themeId = FreshRSS_Themes::defaultTheme;+ }+ $this->view->conf->_theme($themeId);$this->view->conf->_topline_read(Minz_Request::param('topline_read', false));$this->view->conf->_topline_favorite(Minz_Request::param('topline_favorite', false));$this->view->conf->_topline_date(Minz_Request::param('topline_date', false));diff --git a/app/FreshRSS.php b/app/FreshRSS.phpindex e64a1986b..52f34c6e2 100644--- a/app/FreshRSS.php+++ b/app/FreshRSS.php@@ -114,11 +114,10 @@ class FreshRSS extends Minz_FrontController {}private function loadStylesAndScripts ($loginOk) {- $theme = FreshRSS_Themes::get_infos($this->conf->theme);+ $theme = FreshRSS_Themes::load($this->conf->theme);if ($theme) {- FreshRSS_Themes::setThemeId($this->conf->theme);foreach($theme['files'] as $file) {- Minz_View::appendStyle (Minz_Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));+ Minz_View::appendStyle (Minz_Url::display ('/themes/' . $theme['id'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));}}diff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex 8f394737a..f3fb76e72 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -25,7 +25,7 @@ class FreshRSS_Configuration {'scroll' => false,'reception' => false,),- 'theme' => 'default',+ 'theme' => 'Origine','shortcuts' => array('mark_read' => 'r','mark_favorite' => 'f',diff --git a/app/Models/Themes.php b/app/Models/Themes.phpindex a52812339..c7099a1df 100644--- a/app/Models/Themes.php+++ b/app/Models/Themes.php@@ -3,13 +3,17 @@class FreshRSS_Themes extends Minz_Model {private static $themesUrl = '/themes/';private static $defaultIconsUrl = '/themes/icons/';+ public static $defaultTheme = 'Origine';- public static function get() {- $themes_list = array_diff(+ public static function getList() {+ return array_values(array_diff(scandir(PUBLIC_PATH . self::$themesUrl),array('..', '.')- );+ ));+ }+ public static function get() {+ $themes_list = self::getList();$list = array();foreach ($themes_list as $theme_dir) {$theme = self::get_infos($theme_dir);@@ -28,7 +32,7 @@ class FreshRSS_Themes extends Minz_Model {$content = file_get_contents($json_filename);$res = json_decode($content, true);if ($res && isset($res['files']) && is_array($res['files'])) {- $res['path'] = $theme_id;+ $res['id'] = $theme_id;return $res;}}@@ -39,12 +43,26 @@ class FreshRSS_Themes extends Minz_Model {private static $themeIconsUrl;private static $themeIcons;- public static function setThemeId($theme_id) {+ public static function load($theme_id) {+ $infos = self::get_infos($theme_id);+ if (!$infos) {+ if ($theme_id !== self::$defaultTheme) { //Fall-back to default theme+ return self::load(self::$defaultTheme);+ }+ $themes_list = self::getList();+ if (!empty($themes_list)) {+ if ($theme_id !== $themes_list[0]) { //Fall-back to first theme+ return self::load($themes_list[0]);+ }+ }+ return false;+ }self::$themeIconsUrl = self::$themesUrl . $theme_id . '/icons/';self::$themeIcons = is_dir(PUBLIC_PATH . self::$themeIconsUrl) ? array_fill_keys(array_diff(scandir(PUBLIC_PATH . self::$themeIconsUrl),array('..', '.')), 1) : array();+ return $infos;}public static function icon($name, $urlOnly = false) {diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtmlindex 3cc5442fb..725356c8d 100644--- a/app/views/configure/display.phtml+++ b/app/views/configure/display.phtml@@ -21,9 +21,10 @@<div class="form-group"><label class="group-name" for="theme"><?php echo Minz_Translate::t ('theme'); ?></label><div class="group-controls">- <select name="theme" id="theme">+ <select name="theme" id="theme" required="">+ <option></option><?php foreach ($this->themes as $theme) { ?>- <option value="<?php echo $theme['path']; ?>"<?php echo $this->conf->theme === $theme['path'] ? ' selected="selected"' : ''; ?>>+ <option value="<?php echo $theme['id']; ?>"<?php echo $this->conf->theme === $theme['id'] ? ' selected="selected"' : ''; ?>><?php echo $theme['name'] . ' — ' . Minz_Translate::t ('by') . ' ' . $theme['author']; ?></option><?php } ?>diff --git a/p/themes/default_dark/freshrss.css b/p/themes/Dark/freshrss.csssimilarity index 100%rename from p/themes/default_dark/freshrss.cssrename to p/themes/Dark/freshrss.cssdiff --git a/p/themes/default_dark/global.css b/p/themes/Dark/global.csssimilarity index 100%rename from p/themes/default_dark/global.cssrename to p/themes/Dark/global.cssdiff --git a/p/themes/default_dark/loader.gif b/p/themes/Dark/loader.gifsimilarity index 100%rename from p/themes/default_dark/loader.gifrename to p/themes/Dark/loader.gifdiff --git a/p/themes/Dark/metadata.json b/p/themes/Dark/metadata.jsonnew file mode 100644index 000000000..27cae27df--- /dev/null+++ b/p/themes/Dark/metadata.json@@ -0,0 +1,7 @@+{+ "name": "Dark",+ "author": "AD",+ "description": "Le coté obscur du thème “Origine”",+ "version": 0.1,+ "files": ["global.css", "freshrss.css"]+}diff --git a/p/themes/flat-design/freshrss.css b/p/themes/Flat/freshrss.csssimilarity index 100%rename from p/themes/flat-design/freshrss.cssrename to p/themes/Flat/freshrss.cssdiff --git a/p/themes/flat-design/global.css b/p/themes/Flat/global.csssimilarity index 100%rename from p/themes/flat-design/global.cssrename to p/themes/Flat/global.cssdiff --git a/p/themes/flat-design/icons/add.svg b/p/themes/Flat/icons/add.svgsimilarity index 100%rename from p/themes/flat-design/icons/add.svgrename to p/themes/Flat/icons/add.svgdiff --git a/p/themes/flat-design/icons/all.svg b/p/themes/Flat/icons/all.svgsimilarity index 100%rename from p/themes/flat-design/icons/all.svgrename to p/themes/Flat/icons/all.svgdiff --git a/p/themes/flat-design/icons/close.svg b/p/themes/Flat/icons/close.svgsimilarity index 100%rename from p/themes/flat-design/icons/close.svgrename to p/themes/Flat/icons/close.svgdiff --git a/p/themes/flat-design/icons/configure.svg b/p/themes/Flat/icons/configure.svgsimilarity index 100%rename from p/themes/flat-design/icons/configure.svgrename to p/themes/Flat/icons/configure.svgdiff --git a/p/themes/flat-design/icons/down.svg b/p/themes/Flat/icons/down.svgsimilarity index 100%rename from p/themes/flat-design/icons/down.svgrename to p/themes/Flat/icons/down.svgdiff --git a/p/themes/flat-design/icons/next.svg b/p/themes/Flat/icons/next.svgsimilarity index 100%rename from p/themes/flat-design/icons/next.svgrename to p/themes/Flat/icons/next.svgdiff --git a/p/themes/flat-design/icons/prev.svg b/p/themes/Flat/icons/prev.svgsimilarity index 100%rename from p/themes/flat-design/icons/prev.svgrename to p/themes/Flat/icons/prev.svgdiff --git a/p/themes/flat-design/icons/refresh.svg b/p/themes/Flat/icons/refresh.svgsimilarity index 100%rename from p/themes/flat-design/icons/refresh.svgrename to p/themes/Flat/icons/refresh.svgdiff --git a/p/themes/flat-design/icons/search.svg b/p/themes/Flat/icons/search.svgsimilarity index 100%rename from p/themes/flat-design/icons/search.svgrename to p/themes/Flat/icons/search.svgdiff --git a/p/themes/flat-design/icons/up.svg b/p/themes/Flat/icons/up.svgsimilarity index 100%rename from p/themes/flat-design/icons/up.svgrename to p/themes/Flat/icons/up.svgdiff --git a/p/themes/flat-design/loader.gif b/p/themes/Flat/loader.gifsimilarity index 100%rename from p/themes/flat-design/loader.gifrename to p/themes/Flat/loader.gifdiff --git a/p/themes/flat-design/metadata.json b/p/themes/Flat/metadata.jsonsimilarity index 100%rename from p/themes/flat-design/metadata.jsonrename to p/themes/Flat/metadata.jsondiff --git a/p/themes/default/freshrss.css b/p/themes/Origine/freshrss.csssimilarity index 100%rename from p/themes/default/freshrss.cssrename to p/themes/Origine/freshrss.cssdiff --git a/p/themes/default/global.css b/p/themes/Origine/global.csssimilarity index 100%rename from p/themes/default/global.cssrename to p/themes/Origine/global.cssdiff --git a/p/themes/default/loader.gif b/p/themes/Origine/loader.gifsimilarity index 100%rename from p/themes/default/loader.gifrename to p/themes/Origine/loader.gifdiff --git a/p/themes/default/metadata.json b/p/themes/Origine/metadata.jsonsimilarity index 87%rename from p/themes/default/metadata.jsonrename to p/themes/Origine/metadata.jsonindex d316ec517..f93dcbc3f 100644--- a/p/themes/default/metadata.json+++ b/p/themes/Origine/metadata.json@@ -1,5 +1,5 @@{- "name": "Default",+ "name": "Origine","author": "Marien Fressinaud","description": "Le thème par défaut pour FreshRSS","version": 0.1,diff --git a/p/themes/default_dark/metadata.json b/p/themes/default_dark/metadata.jsondeleted file mode 100644index 7504831a6..000000000--- a/p/themes/default_dark/metadata.json+++ /dev/null@@ -1,7 +0,0 @@-{- "name": "Dark",- "author": "AD",- "description": "Le coté obscur du thème par défaut pour FreshRSS",- "version": 0.1,- "files": ["global.css", "freshrss.css"]-}