diff options
| author | 2014-01-13 22:27:22 +0100 | |
|---|---|---|
| committer | 2014-01-13 22:27:22 +0100 | |
| commit | f720d41cbfb18edc1b0a694a7213682b96befa1f (patch) | |
| tree | 82d8529c281639c9c02dc04f037bf719fa0576c0 | |
| parent | 7516549f60462a7bb7d5998300491df9d7e5fe82 (diff) | |
Mise à jour nom thèmes + chargement robuste des thèmes
Renomme : default -> Origine
En cas de thème introuvable, charge le thème par défaut, sinon le
premier disponible.
https://github.com/marienfressinaud/FreshRSS/issues/120
| -rwxr-xr-x | app/Controllers/configureController.php | 6 | ||||
| -rw-r--r-- | app/FreshRSS.php | 5 | ||||
| -rw-r--r-- | app/Models/Configuration.php | 2 | ||||
| -rw-r--r-- | app/Models/Themes.php | 28 | ||||
| -rw-r--r-- | app/views/configure/display.phtml | 5 | ||||
| -rw-r--r-- | p/themes/Dark/freshrss.css (renamed from p/themes/default_dark/freshrss.css) | 0 | ||||
| -rw-r--r-- | p/themes/Dark/global.css (renamed from p/themes/default_dark/global.css) | 0 | ||||
| -rw-r--r-- | p/themes/Dark/loader.gif (renamed from p/themes/default_dark/loader.gif) | bin | 404 -> 404 bytes | |||
| -rw-r--r-- | p/themes/Dark/metadata.json | 7 | ||||
| -rw-r--r-- | p/themes/Flat/freshrss.css (renamed from p/themes/flat-design/freshrss.css) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/global.css (renamed from p/themes/flat-design/global.css) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/add.svg (renamed from p/themes/flat-design/icons/add.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/all.svg (renamed from p/themes/flat-design/icons/all.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/close.svg (renamed from p/themes/flat-design/icons/close.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/configure.svg (renamed from p/themes/flat-design/icons/configure.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/down.svg (renamed from p/themes/flat-design/icons/down.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/next.svg (renamed from p/themes/flat-design/icons/next.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/prev.svg (renamed from p/themes/flat-design/icons/prev.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/refresh.svg (renamed from p/themes/flat-design/icons/refresh.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/search.svg (renamed from p/themes/flat-design/icons/search.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/icons/up.svg (renamed from p/themes/flat-design/icons/up.svg) | 0 | ||||
| -rw-r--r-- | p/themes/Flat/loader.gif (renamed from p/themes/flat-design/loader.gif) | bin | 4251 -> 4251 bytes | |||
| -rw-r--r-- | p/themes/Flat/metadata.json (renamed from p/themes/flat-design/metadata.json) | 0 | ||||
| -rw-r--r-- | p/themes/Origine/freshrss.css (renamed from p/themes/default/freshrss.css) | 0 | ||||
| -rw-r--r-- | p/themes/Origine/global.css (renamed from p/themes/default/global.css) | 0 | ||||
| -rw-r--r-- | p/themes/Origine/loader.gif (renamed from p/themes/default/loader.gif) | bin | 4167 -> 4167 bytes | |||
| -rw-r--r-- | p/themes/Origine/metadata.json (renamed from p/themes/default/metadata.json) | 2 | ||||
| -rw-r--r-- | p/themes/default_dark/metadata.json | 7 |
28 files changed, 42 insertions, 20 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 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.php index 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.php index 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.php index 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.phtml index 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.css index e9eb2c705..e9eb2c705 100644 --- a/p/themes/default_dark/freshrss.css +++ b/p/themes/Dark/freshrss.css diff --git a/p/themes/default_dark/global.css b/p/themes/Dark/global.css index 04eb723f1..04eb723f1 100644 --- a/p/themes/default_dark/global.css +++ b/p/themes/Dark/global.css diff --git a/p/themes/default_dark/loader.gif b/p/themes/Dark/loader.gif Binary files differindex 86022be71..86022be71 100644 --- a/p/themes/default_dark/loader.gif +++ b/p/themes/Dark/loader.gif diff --git a/p/themes/Dark/metadata.json b/p/themes/Dark/metadata.json new file mode 100644 index 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.css index dca1b3f28..dca1b3f28 100644 --- a/p/themes/flat-design/freshrss.css +++ b/p/themes/Flat/freshrss.css diff --git a/p/themes/flat-design/global.css b/p/themes/Flat/global.css index 5fd0a4dcf..5fd0a4dcf 100644 --- a/p/themes/flat-design/global.css +++ b/p/themes/Flat/global.css diff --git a/p/themes/flat-design/icons/add.svg b/p/themes/Flat/icons/add.svg index 15767a3ad..15767a3ad 100644 --- a/p/themes/flat-design/icons/add.svg +++ b/p/themes/Flat/icons/add.svg diff --git a/p/themes/flat-design/icons/all.svg b/p/themes/Flat/icons/all.svg index d20e0f5bf..d20e0f5bf 100644 --- a/p/themes/flat-design/icons/all.svg +++ b/p/themes/Flat/icons/all.svg diff --git a/p/themes/flat-design/icons/close.svg b/p/themes/Flat/icons/close.svg index 629fda7ff..629fda7ff 100644 --- a/p/themes/flat-design/icons/close.svg +++ b/p/themes/Flat/icons/close.svg diff --git a/p/themes/flat-design/icons/configure.svg b/p/themes/Flat/icons/configure.svg index 969c5719f..969c5719f 100644 --- a/p/themes/flat-design/icons/configure.svg +++ b/p/themes/Flat/icons/configure.svg diff --git a/p/themes/flat-design/icons/down.svg b/p/themes/Flat/icons/down.svg index 31730626f..31730626f 100644 --- a/p/themes/flat-design/icons/down.svg +++ b/p/themes/Flat/icons/down.svg diff --git a/p/themes/flat-design/icons/next.svg b/p/themes/Flat/icons/next.svg index d75cc40f5..d75cc40f5 100644 --- a/p/themes/flat-design/icons/next.svg +++ b/p/themes/Flat/icons/next.svg diff --git a/p/themes/flat-design/icons/prev.svg b/p/themes/Flat/icons/prev.svg index 9ba03ceb2..9ba03ceb2 100644 --- a/p/themes/flat-design/icons/prev.svg +++ b/p/themes/Flat/icons/prev.svg diff --git a/p/themes/flat-design/icons/refresh.svg b/p/themes/Flat/icons/refresh.svg index 8f95bf443..8f95bf443 100644 --- a/p/themes/flat-design/icons/refresh.svg +++ b/p/themes/Flat/icons/refresh.svg diff --git a/p/themes/flat-design/icons/search.svg b/p/themes/Flat/icons/search.svg index bca7571b4..bca7571b4 100644 --- a/p/themes/flat-design/icons/search.svg +++ b/p/themes/Flat/icons/search.svg diff --git a/p/themes/flat-design/icons/up.svg b/p/themes/Flat/icons/up.svg index 3ab11b168..3ab11b168 100644 --- a/p/themes/flat-design/icons/up.svg +++ b/p/themes/Flat/icons/up.svg diff --git a/p/themes/flat-design/loader.gif b/p/themes/Flat/loader.gif Binary files differindex ce36565b3..ce36565b3 100644 --- a/p/themes/flat-design/loader.gif +++ b/p/themes/Flat/loader.gif diff --git a/p/themes/flat-design/metadata.json b/p/themes/Flat/metadata.json index 6b94d11c2..6b94d11c2 100644 --- a/p/themes/flat-design/metadata.json +++ b/p/themes/Flat/metadata.json diff --git a/p/themes/default/freshrss.css b/p/themes/Origine/freshrss.css index 593f21d30..593f21d30 100644 --- a/p/themes/default/freshrss.css +++ b/p/themes/Origine/freshrss.css diff --git a/p/themes/default/global.css b/p/themes/Origine/global.css index 49f3aa4cd..49f3aa4cd 100644 --- a/p/themes/default/global.css +++ b/p/themes/Origine/global.css diff --git a/p/themes/default/loader.gif b/p/themes/Origine/loader.gif Binary files differindex 5ff26f0e3..5ff26f0e3 100644 --- a/p/themes/default/loader.gif +++ b/p/themes/Origine/loader.gif diff --git a/p/themes/default/metadata.json b/p/themes/Origine/metadata.json index 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.json deleted file mode 100644 index 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"] -} |
