Add an option to choose where to be redirected when there is nothing to read

This commit is contained in:
Frédéric Guillot 2013-12-23 13:33:16 -05:00
parent eb9f307da8
commit 9a021ba43e
11 changed files with 47 additions and 4 deletions

View File

@ -143,7 +143,7 @@ Miniflux.Item = (function() {
counter = parseInt(container.textContent.trim(), 10) - 1; counter = parseInt(container.textContent.trim(), 10) - 1;
if (counter == 0) { if (counter == 0) {
window.location = "?action=feeds&nothing_to_read=1"; window.location = "?action=unread";
} }
else { else {
container.textContent = counter + " "; container.textContent = counter + " ";

View File

@ -48,6 +48,7 @@ Router\get_action('bookmarks', function() {
'nb_items' => $nb_items, 'nb_items' => $nb_items,
'offset' => $offset, 'offset' => $offset,
'items_per_page' => Model\Config\get('items_per_page'), 'items_per_page' => Model\Config\get('items_per_page'),
'nothing_to_read' => Request\int_param('nothing_to_read'),
'menu' => 'bookmarks', 'menu' => 'bookmarks',
'title' => t('Bookmarks').' ('.$nb_items.')' 'title' => t('Bookmarks').' ('.$nb_items.')'
))); )));

View File

@ -39,6 +39,7 @@ Router\get_action('config', function() {
'paging_options' => Model\Config\get_paging_options(), 'paging_options' => Model\Config\get_paging_options(),
'theme_options' => Model\Config\get_themes(), 'theme_options' => Model\Config\get_themes(),
'sorting_options' => Model\Config\get_sorting_directions(), 'sorting_options' => Model\Config\get_sorting_directions(),
'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(),
'menu' => 'config', 'menu' => 'config',
'title' => t('Preferences') 'title' => t('Preferences')
))); )));
@ -71,6 +72,7 @@ Router\post_action('config', function() {
'paging_options' => Model\Config\get_paging_options(), 'paging_options' => Model\Config\get_paging_options(),
'theme_options' => Model\Config\get_themes(), 'theme_options' => Model\Config\get_themes(),
'sorting_options' => Model\Config\get_sorting_directions(), 'sorting_options' => Model\Config\get_sorting_directions(),
'redirect_nothing_to_read' => Model\Config\get_nothing_to_read_redirections(),
'menu' => 'config', 'menu' => 'config',
'title' => t('Preferences') 'title' => t('Preferences')
))); )));

View File

@ -25,6 +25,7 @@ Router\get_action('history', function() {
'nb_items' => $nb_items, 'nb_items' => $nb_items,
'offset' => $offset, 'offset' => $offset,
'items_per_page' => Model\Config\get('items_per_page'), 'items_per_page' => Model\Config\get('items_per_page'),
'nothing_to_read' => Request\int_param('nothing_to_read'),
'menu' => 'history', 'menu' => 'history',
'title' => t('History').' ('.$nb_items.')' 'title' => t('History').' ('.$nb_items.')'
))); )));

View File

@ -17,7 +17,11 @@ Router\notfound(function() {
$items = Model\Item\get_all('unread', $offset, Model\Config\get('items_per_page'), $order, $direction); $items = Model\Item\get_all('unread', $offset, Model\Config\get('items_per_page'), $order, $direction);
$nb_items = Model\Item\count_by_status('unread'); $nb_items = Model\Item\count_by_status('unread');
if ($nb_items === 0) Response\redirect('?action=feeds&nothing_to_read=1'); if ($nb_items === 0) {
$action = Model\Config\get('redirect_nothing_to_read');
Response\redirect('?action='.$action.'&nothing_to_read=1');
}
Response\html(Template\layout('unread_items', array( Response\html(Template\layout('unread_items', array(
'order' => $order, 'order' => $order,

View File

@ -1,6 +1,12 @@
<?php <?php
return array( return array(
'When there is nothing to read, redirect me to this page' => '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', 'Immediately' => 'Immédiatement',
'(error occurred during the last check)' => '(problème rencontré pendant la dernière vérification)', '(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', '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.', '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 link Miniflux to your Google Account.' => 'Impossible de lier Miniflux à votre compte Google',
'Unable to authenticate with Google' => 'Impossible de s\'authentifier avec 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.', '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.', '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', 'Login with my Google Account' => 'Se connecter avec mon compte Google',

View File

@ -15,7 +15,7 @@ require_once 'vendor/SimpleValidator/Validators/Integer.php';
use SimpleValidator\Validator; use SimpleValidator\Validator;
use SimpleValidator\Validators; use SimpleValidator\Validators;
const DB_VERSION = 19; const DB_VERSION = 20;
const HTTP_USERAGENT = 'Miniflux - http://miniflux.net'; 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'; 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 // Generate a token from /dev/urandom or with uniqid() if open_basedir is enabled
function generate_token() function generate_token()
{ {
@ -189,7 +199,8 @@ function get_all()
'feed_token', 'feed_token',
'auth_google_token', 'auth_google_token',
'auth_mozilla_token', 'auth_mozilla_token',
'items_sorting_direction' 'items_sorting_direction',
'redirect_nothing_to_read'
) )
->findOne(); ->findOne();
} }

View File

@ -3,6 +3,12 @@
namespace Schema; namespace Schema;
function version_20($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN redirect_nothing_to_read TEXT DEFAULT "feeds"');
}
function version_19($pdo) function version_19($pdo)
{ {
$rq = $pdo->prepare('SELECT autoflush FROM config'); $rq = $pdo->prepare('SELECT autoflush FROM config');

View File

@ -6,6 +6,10 @@
<h2><?= t('Bookmarks') ?> (<?= $nb_items ?>)</h2> <h2><?= t('Bookmarks') ?> (<?= $nb_items ?>)</h2>
</div> </div>
<?php if ($nothing_to_read): ?>
<p class="alert"><?= t('There is nothing new to read, enjoy your favorites articles!') ?></p>
<?php endif ?>
<section class="items" id="listing"> <section class="items" id="listing">
<?php foreach ($items as $item): ?> <?php foreach ($items as $item): ?>
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?> <?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?>

View File

@ -25,6 +25,9 @@
<?= Helper\form_label(t('Default sorting order for items'), 'items_sorting_direction') ?> <?= Helper\form_label(t('Default sorting order for items'), 'items_sorting_direction') ?>
<?= Helper\form_select('items_sorting_direction', $sorting_options, $values, $errors) ?><br/> <?= Helper\form_select('items_sorting_direction', $sorting_options, $values, $errors) ?><br/>
<?= Helper\form_label(t('When there is nothing to read, redirect me to this page'), 'redirect_nothing_to_read') ?>
<?= Helper\form_select('redirect_nothing_to_read', $redirect_nothing_to_read_options, $values, $errors) ?><br/>
<?= Helper\form_label(t('Theme'), 'theme') ?> <?= Helper\form_label(t('Theme'), 'theme') ?>
<?= Helper\form_select('theme', $theme_options, $values, $errors) ?><br/> <?= Helper\form_select('theme', $theme_options, $values, $errors) ?><br/>

View File

@ -9,6 +9,10 @@
</ul> </ul>
</div> </div>
<?php if ($nothing_to_read): ?>
<p class="alert"><?= t('There is nothing new to read, enjoy your previous readings!') ?></p>
<?php endif ?>
<section class="items" id="listing"> <section class="items" id="listing">
<?php foreach ($items as $item): ?> <?php foreach ($items as $item): ?>
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?> <?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>