aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-08-07 11:46:55 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-08-07 11:46:55 +0200
commitabb25a58dc8668c6716c419c99b215536861057a (patch)
tree37be666df9383f447e84cfc29fa840e60678bebb /app
parentf6d730f9d1ce7957001bd981f04b32d67ebb44e6 (diff)
Fix issue #86 : possibilité de changer de thème
Désormais il est possible de créer des thèmes. Le thème peut être changé sur la page de configuration. Les thèmes sont détectés grâce à un fichier metadata.json détaillant le nom du thème, son auteur, une petite description et une version. Un nouveau thème "Flat design" a été ajouté et est pleinement fonctionnel
Diffstat (limited to 'app')
-rw-r--r--app/App_FrontController.php6
-rwxr-xr-xapp/controllers/configureController.php7
-rw-r--r--app/i18n/en.php2
-rw-r--r--app/i18n/fr.php2
-rw-r--r--app/models/RSSThemes.php38
-rw-r--r--app/views/configure/display.phtml13
6 files changed, 65 insertions, 3 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php
index 637d61206..50313522f 100644
--- a/app/App_FrontController.php
+++ b/app/App_FrontController.php
@@ -30,6 +30,7 @@ class App_FrontController extends FrontController {
include (APP_PATH . '/models/Exception/FeedException.php');
include (APP_PATH . '/models/Exception/EntriesGetterException.php');
include (APP_PATH . '/models/RSSConfiguration.php');
+ include (APP_PATH . '/models/RSSThemes.php');
include (APP_PATH . '/models/Days.php');
include (APP_PATH . '/models/Category.php');
include (APP_PATH . '/models/Feed.php');
@@ -50,9 +51,8 @@ class App_FrontController extends FrontController {
}
private function loadStylesAndScripts () {
- View::appendStyle (Url::display ('/theme/fallback.css'));
- View::appendStyle (Url::display ('/theme/global.css'));
- View::appendStyle (Url::display ('/theme/freshrss.css'));
+ $theme = $this->conf->theme();
+ View::appendStyle (Url::display ('/themes/' . $theme . '/style.css'));
if (login_is_conf ($this->conf)) {
View::appendScript ('https://login.persona.org/include.js');
}
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php
index abd546504..6b582fde6 100755
--- a/app/controllers/configureController.php
+++ b/app/controllers/configureController.php
@@ -137,6 +137,8 @@ class configureController extends ActionController {
}
public function displayAction () {
+ RSSThemes::init();
+
if (Request::isPost ()) {
$language = Request::param ('language', 'en');
$nb = Request::param ('posts_per_page', 10);
@@ -152,6 +154,7 @@ class configureController extends ActionController {
$openSite = Request::param ('mark_open_site', 'no');
$scroll = Request::param ('mark_scroll', 'no');
$urlShaarli = Request::param ('shaarli', '');
+ $theme = Request::param ('theme', 'default');
$this->view->conf->_language ($language);
$this->view->conf->_postsPerPage (intval ($nb));
@@ -169,6 +172,7 @@ class configureController extends ActionController {
'scroll' => $scroll,
));
$this->view->conf->_urlShaarli ($urlShaarli);
+ $this->view->conf->_theme ($theme);
$values = array (
'language' => $this->view->conf->language (),
@@ -183,6 +187,7 @@ class configureController extends ActionController {
'anon_access' => $this->view->conf->anonAccess (),
'mark_when' => $this->view->conf->markWhen (),
'url_shaarli' => $this->view->conf->urlShaarli (),
+ 'theme' => $this->view->conf->theme ()
);
$confDAO = new RSSConfigurationDAO ();
@@ -203,6 +208,8 @@ class configureController extends ActionController {
Request::forward (array ('c' => 'configure', 'a' => 'display'), true);
}
+ $this->view->themes = RSSThemes::get();
+
View::prependTitle (Translate::t ('general_and_reading_management') . ' - ');
}
diff --git a/app/i18n/en.php b/app/i18n/en.php
index 3287e3a15..9afc0182c 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -168,11 +168,13 @@ return array (
'on_shaarli' => 'On your Shaarli',
'optimize_bdd' => 'Optimize database',
'optimize_todo_sometimes' => 'To do occasionally to reduce size of database',
+ 'themes' => 'Themes',
'article' => 'Article',
'title' => 'Title',
'author' => 'Author',
'publication_date' => 'Date of publication',
+ 'by' => 'by',
'load_more' => 'Load more articles',
'nothing_to_load' => 'There is no more articles',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index d5a7f8fa0..57e288166 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -168,11 +168,13 @@ return array (
'on_shaarli' => 'Sur votre Shaarli',
'optimize_bdd' => 'Optimiser la base de données',
'optimize_todo_sometimes' => 'À faire de temps en temps pour réduire la taille de la BDD',
+ 'themes' => 'Thèmes',
'article' => 'Article',
'title' => 'Titre',
'author' => 'Auteur',
'publication_date' => 'Date de publication',
+ 'by' => 'par',
'load_more' => 'Charger plus d\'articles',
'nothing_to_load' => 'Il n\'y a pas plus d\'article',
diff --git a/app/models/RSSThemes.php b/app/models/RSSThemes.php
new file mode 100644
index 000000000..291b295e3
--- /dev/null
+++ b/app/models/RSSThemes.php
@@ -0,0 +1,38 @@
+<?php
+
+class RSSThemes extends Model {
+ private static $themes_dir = '/themes';
+
+ private static $list = array();
+
+ public static function init() {
+ $basedir = PUBLIC_PATH . self::$themes_dir;
+
+ $themes_list = array_diff(
+ scandir($basedir),
+ array('..', '.')
+ );
+
+ foreach ($themes_list as $theme_dir) {
+ $json_filename = $basedir . '/' . $theme_dir . '/metadata.json';
+ if(file_exists($json_filename)) {
+ $content = file_get_contents($json_filename);
+ $res = json_decode($content, true);
+
+ if($res &&
+ isset($res['name']) &&
+ isset($res['author']) &&
+ isset($res['description']) &&
+ isset($res['version'])) {
+ $theme = $res;
+ $theme['path'] = $theme_dir;
+ self::$list[] = $theme;
+ }
+ }
+ }
+ }
+
+ public static function get() {
+ return self::$list;
+ }
+} \ No newline at end of file
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml
index f8e94c0f2..2516f2692 100644
--- a/app/views/configure/display.phtml
+++ b/app/views/configure/display.phtml
@@ -41,6 +41,19 @@
<legend><?php echo Translate::t ('reading_configuration'); ?></legend>
<div class="form-group">
+ <label class="group-name" for="theme"><?php echo Translate::t ('themes'); ?></label>
+ <div class="group-controls">
+ <select name="theme" id="theme">
+ <?php foreach ($this->themes as $theme) { ?>
+ <option value="<?php echo $theme['path']; ?>"<?php echo $this->conf->theme () == $theme['path'] ? ' selected="selected"' : ''; ?>>
+ <?php echo $theme['name'] . ' ' . Translate::t ('by') . ' ' . $theme['author']; ?>
+ </option>
+ <?php } ?>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group">
<label class="group-name" for="posts_per_page"><?php echo Translate::t ('articles_per_page'); ?></label>
<div class="group-controls">
<input type="number" id="posts_per_page" name="posts_per_page" value="<?php echo $this->conf->postsPerPage (); ?>" />