From 9a021ba43e720e9b4a596b8c0a14a728cfb2f3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Mon, 23 Dec 2013 13:33:16 -0500 Subject: [PATCH] Add an option to choose where to be redirected when there is nothing to read --- assets/js/item.js | 2 +- controllers/bookmark.php | 1 + controllers/config.php | 2 ++ controllers/history.php | 1 + controllers/unread.php | 6 +++++- locales/fr_FR/translations.php | 7 +++++++ models/config.php | 15 +++++++++++++-- schema.php | 6 ++++++ templates/bookmarks.php | 4 ++++ templates/config.php | 3 +++ templates/history.php | 4 ++++ 11 files changed, 47 insertions(+), 4 deletions(-) diff --git a/assets/js/item.js b/assets/js/item.js index ad36982..dd4991a 100644 --- a/assets/js/item.js +++ b/assets/js/item.js @@ -143,7 +143,7 @@ Miniflux.Item = (function() { counter = parseInt(container.textContent.trim(), 10) - 1; if (counter == 0) { - window.location = "?action=feeds¬hing_to_read=1"; + window.location = "?action=unread"; } else { container.textContent = counter + " "; diff --git a/controllers/bookmark.php b/controllers/bookmark.php index 8d9db91..cae52e8 100644 --- a/controllers/bookmark.php +++ b/controllers/bookmark.php @@ -48,6 +48,7 @@ Router\get_action('bookmarks', function() { 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), + 'nothing_to_read' => Request\int_param('nothing_to_read'), 'menu' => 'bookmarks', 'title' => t('Bookmarks').' ('.$nb_items.')' ))); diff --git a/controllers/config.php b/controllers/config.php index 6a76394..06f979a 100644 --- a/controllers/config.php +++ b/controllers/config.php @@ -39,6 +39,7 @@ Router\get_action('config', function() { 'paging_options' => Model\Config\get_paging_options(), 'theme_options' => Model\Config\get_themes(), 'sorting_options' => Model\Config\get_sorting_directions(), + 'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(), 'menu' => 'config', 'title' => t('Preferences') ))); @@ -71,6 +72,7 @@ Router\post_action('config', function() { 'paging_options' => Model\Config\get_paging_options(), 'theme_options' => Model\Config\get_themes(), 'sorting_options' => Model\Config\get_sorting_directions(), + 'redirect_nothing_to_read' => Model\Config\get_nothing_to_read_redirections(), 'menu' => 'config', 'title' => t('Preferences') ))); diff --git a/controllers/history.php b/controllers/history.php index 205adf2..63c312c 100644 --- a/controllers/history.php +++ b/controllers/history.php @@ -25,6 +25,7 @@ Router\get_action('history', function() { 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), + 'nothing_to_read' => Request\int_param('nothing_to_read'), 'menu' => 'history', 'title' => t('History').' ('.$nb_items.')' ))); diff --git a/controllers/unread.php b/controllers/unread.php index 753401e..79237f0 100644 --- a/controllers/unread.php +++ b/controllers/unread.php @@ -17,7 +17,11 @@ Router\notfound(function() { $items = Model\Item\get_all('unread', $offset, Model\Config\get('items_per_page'), $order, $direction); $nb_items = Model\Item\count_by_status('unread'); - if ($nb_items === 0) Response\redirect('?action=feeds¬hing_to_read=1'); + if ($nb_items === 0) { + + $action = Model\Config\get('redirect_nothing_to_read'); + Response\redirect('?action='.$action.'¬hing_to_read=1'); + } Response\html(Template\layout('unread_items', array( 'order' => $order, diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 5ff0382..c05797f 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -1,6 +1,12 @@ 'Quand il n\'y a rien à lire, redirigez moi vers cette page', + 'Subscription page' => 'Page des abonnements', + 'History page' => 'Historique de lecture', + 'Bookmark page' => 'Page des favoris', + 'There is nothing new to read, enjoy your favorites articles!' => 'Il n\'y a rien de nouveau à lire, relisez vos articles favoris !', + 'There is nothing new to read, enjoy your previous readings!' => 'Il n\'y a rien de nouveau à lire, profitez de vos lectures précédentes !', 'Immediately' => 'Immédiatement', '(error occurred during the last check)' => '(problème rencontré pendant la dernière vérification)', 'The feed id is required' => 'L\'identifiant du flux est obligatoire', @@ -36,6 +42,7 @@ return array( 'Your Google Account is linked to Miniflux.' => 'Votre compte Google est relié à Miniflux.', 'Unable to link Miniflux to your Google Account.' => 'Impossible de lier Miniflux à votre compte Google', 'Unable to authenticate with Google' => 'Impossible de s\'authentifier avec Google', + 'Your Mozilla Persona Account is linked to Miniflux' => 'Votre compte Mozilla Persona est lié avec Miniflux', 'Your Mozilla Persona Account is linked to Miniflux.' => 'Votre compte Mozilla Persona est lié avec Miniflux.', 'Unable to link Miniflux to your Mozilla Persona Account.' => 'Impossible de lier Miniflux avec votre compte Mozilla Persona.', 'Login with my Google Account' => 'Se connecter avec mon compte Google', diff --git a/models/config.php b/models/config.php index 902175c..fe8bfc2 100644 --- a/models/config.php +++ b/models/config.php @@ -15,7 +15,7 @@ require_once 'vendor/SimpleValidator/Validators/Integer.php'; use SimpleValidator\Validator; use SimpleValidator\Validators; -const DB_VERSION = 19; +const DB_VERSION = 20; const HTTP_USERAGENT = 'Miniflux - http://miniflux.net'; const HTTP_FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36'; @@ -109,6 +109,16 @@ function get_paging_options() ); } +// Get redirect options when there is nothing to read +function get_nothing_to_read_redirections() +{ + return array( + 'feeds' => t('Subscription page'), + 'history' => t('History page'), + 'bookmarks' => t('Bookmark page'), + ); +} + // Generate a token from /dev/urandom or with uniqid() if open_basedir is enabled function generate_token() { @@ -189,7 +199,8 @@ function get_all() 'feed_token', 'auth_google_token', 'auth_mozilla_token', - 'items_sorting_direction' + 'items_sorting_direction', + 'redirect_nothing_to_read' ) ->findOne(); } diff --git a/schema.php b/schema.php index 6e83c6b..d586098 100644 --- a/schema.php +++ b/schema.php @@ -3,6 +3,12 @@ namespace Schema; +function version_20($pdo) +{ + $pdo->exec('ALTER TABLE config ADD COLUMN redirect_nothing_to_read TEXT DEFAULT "feeds"'); +} + + function version_19($pdo) { $rq = $pdo->prepare('SELECT autoflush FROM config'); diff --git a/templates/bookmarks.php b/templates/bookmarks.php index 65301f4..dddfd66 100644 --- a/templates/bookmarks.php +++ b/templates/bookmarks.php @@ -6,6 +6,10 @@

()

+ +

+ +
$item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?> diff --git a/templates/config.php b/templates/config.php index 9a8d19a..5450635 100644 --- a/templates/config.php +++ b/templates/config.php @@ -25,6 +25,9 @@
+ +
+
diff --git a/templates/history.php b/templates/history.php index f2c7ecb..c73bca8 100644 --- a/templates/history.php +++ b/templates/history.php @@ -9,6 +9,10 @@ + +

+ +
$item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>