Add a preference parameter to save default items sorting order
This commit is contained in:
parent
53712f2ec1
commit
9e437c1a93
@ -41,11 +41,12 @@ Original author: [Frédéric Guillot](http://fredericguillot.com/)
|
||||
|
||||
### Contributors
|
||||
|
||||
People who sent one or many pull-requests:
|
||||
People who sent a pull-request, report a bug, make a new theme or share super a cool idea:
|
||||
|
||||
- André Kelpe: https://github.com/fs111
|
||||
- Ayodio: https://github.com/ayodio
|
||||
- Bjauy: https://github.com/bjauy
|
||||
- Bohwaz: https://github.com/bohwaz
|
||||
- Chase Arnold: https://github.com/chase4926
|
||||
- Chris Lemonier: https://github.com/chrislemonier
|
||||
- Derjus: https://github.com/derjus
|
||||
@ -53,6 +54,7 @@ People who sent one or many pull-requests:
|
||||
- Félix: https://github.com/dysosmus
|
||||
- Horsely: https://github.com/horsley
|
||||
- Ing. Jan Kaláb: https://github.com/Pitel
|
||||
- Itoine: https://github.com/itoine
|
||||
- James Scott-Brown: https://github.com/jamesscottbrown
|
||||
- Luca Marra: https://github.com/facciocose
|
||||
- Maxime: https://github.com/EpocDotFr
|
||||
|
14
index.php
14
index.php
@ -242,7 +242,13 @@ Router\get_action('history', function() {
|
||||
$nb_items = Model\count_items('read');
|
||||
|
||||
Response\html(Template\layout('history', array(
|
||||
'items' => Model\get_items('read', $offset, Model\get_config_value('items_per_page')),
|
||||
'items' => Model\get_items(
|
||||
'read',
|
||||
$offset,
|
||||
Model\get_config_value('items_per_page'),
|
||||
'updated',
|
||||
Model\get_config_value('items_sorting_direction')
|
||||
),
|
||||
'nb_items' => $nb_items,
|
||||
'offset' => $offset,
|
||||
'items_per_page' => Model\get_config_value('items_per_page'),
|
||||
@ -260,7 +266,7 @@ Router\get_action('feed-items', function() {
|
||||
$nb_items = Model\count_feed_items($feed_id);
|
||||
$feed = Model\get_feed($feed_id);
|
||||
$order = Request\param('order', 'updated');
|
||||
$direction = Request\param('direction', 'desc');
|
||||
$direction = Request\param('direction', Model\get_config_value('items_sorting_direction'));
|
||||
$items = Model\get_feed_items($feed_id, $offset, Model\get_config_value('items_per_page'), $order, $direction);
|
||||
|
||||
Response\html(Template\layout('feed_items', array(
|
||||
@ -642,6 +648,7 @@ Router\get_action('config', function() {
|
||||
'autoflush_options' => Model\get_autoflush_options(),
|
||||
'paging_options' => Model\get_paging_options(),
|
||||
'theme_options' => Model\get_themes(),
|
||||
'sorting_options' => Model\get_sorting_directions(),
|
||||
'menu' => 'config',
|
||||
'title' => t('Preferences')
|
||||
)));
|
||||
@ -674,6 +681,7 @@ Router\post_action('config', function() {
|
||||
'autoflush_options' => Model\get_autoflush_options(),
|
||||
'paging_options' => Model\get_paging_options(),
|
||||
'theme_options' => Model\get_themes(),
|
||||
'sorting_options' => Model\get_sorting_directions(),
|
||||
'menu' => 'config',
|
||||
'title' => t('Preferences')
|
||||
)));
|
||||
@ -797,7 +805,7 @@ Router\notfound(function() {
|
||||
Model\autoflush();
|
||||
|
||||
$order = Request\param('order', 'updated');
|
||||
$direction = Request\param('direction', 'desc');
|
||||
$direction = Request\param('direction', Model\get_config_value('items_sorting_direction'));
|
||||
$offset = Request\int_param('offset', 0);
|
||||
$items = Model\get_items('unread', $offset, Model\get_config_value('items_per_page'), $order, $direction);
|
||||
$nb_items = Model\count_items('unread');
|
||||
|
@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Older items first' => 'Plus anciens en premier',
|
||||
'Most recent first' => 'Plus récents en premier',
|
||||
'Default sorting order for items' => 'Ordre des éléments par défaut',
|
||||
'This subscription is empty, <a href="?action=unread">go back to unread items</a>' => 'Cet abonnement est vide, <a href="?action=unread">retourner à la liste des éléments non lus</a>',
|
||||
'sort by date<span class="hide-mobile"> (%s)</span>' => 'trier par date<span class="hide-mobile"> (%s)</span>',
|
||||
'most recent' => 'plus récents',
|
||||
'older' => 'anciens d\'abord',
|
||||
'most recent first' => 'plus récents d\'abord',
|
||||
'older first' => 'anciens d\'abord',
|
||||
'Show only this subscription' => 'Montrer seulement cet abonnement',
|
||||
'Go to unread' => 'Voir les éléments non lus',
|
||||
'Go to bookmarks' => 'Voir les favoris',
|
||||
|
18
model.php
18
model.php
@ -24,12 +24,21 @@ use PicoFeed\Reader;
|
||||
use PicoFeed\Export;
|
||||
|
||||
|
||||
const DB_VERSION = 16;
|
||||
const DB_VERSION = 17;
|
||||
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 LIMIT_ALL = -1;
|
||||
|
||||
|
||||
function get_sorting_directions()
|
||||
{
|
||||
return array(
|
||||
'asc' => t('Older items first'),
|
||||
'desc' => t('Most recent first'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function get_languages()
|
||||
{
|
||||
return array(
|
||||
@ -571,7 +580,7 @@ function get_bookmarks($offset = null, $limit = null)
|
||||
->join('feeds', 'id', 'feed_id')
|
||||
->in('status', array('read', 'unread'))
|
||||
->eq('bookmark', 1)
|
||||
->desc('updated')
|
||||
->orderBy('updated', get_config_value('items_sorting_direction'))
|
||||
->offset($offset)
|
||||
->limit($limit)
|
||||
->findAll();
|
||||
@ -628,7 +637,7 @@ function get_nav_item($item, $status = array('unread'), $bookmark = array(1, 0),
|
||||
->table('items')
|
||||
->columns('id', 'status', 'title', 'bookmark')
|
||||
->neq('status', 'removed')
|
||||
->desc('updated');
|
||||
->orderBy('updated', get_config_value('items_sorting_direction'));
|
||||
|
||||
if ($feed_id) $query->eq('feed_id', $feed_id);
|
||||
|
||||
@ -937,7 +946,8 @@ function get_config()
|
||||
'api_token',
|
||||
'feed_token',
|
||||
'auth_google_token',
|
||||
'auth_mozilla_token'
|
||||
'auth_mozilla_token',
|
||||
'items_sorting_direction'
|
||||
)
|
||||
->findOne();
|
||||
}
|
||||
|
@ -3,6 +3,12 @@
|
||||
namespace Schema;
|
||||
|
||||
|
||||
function version_17($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN items_sorting_direction TEXT DEFAULT "desc"');
|
||||
}
|
||||
|
||||
|
||||
function version_16($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN auth_google_token TEXT DEFAULT ""');
|
||||
|
@ -22,6 +22,9 @@
|
||||
<?= Helper\form_label(t('Items per page'), 'items_per_page') ?>
|
||||
<?= Helper\form_select('items_per_page', $paging_options, $values, $errors) ?><br/>
|
||||
|
||||
<?= 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_label(t('Theme'), 'theme') ?>
|
||||
<?= Helper\form_select('theme', $theme_options, $values, $errors) ?><br/>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<h2><?= Helper\escape($feed['title']) ?> (<?= $nb_items ?>)</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="?action=feed-items&feed_id=<?= $feed['id'] ?>&order=updated&direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= t('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older') : t('most recent')) ?></a>
|
||||
<a href="?action=feed-items&feed_id=<?= $feed['id'] ?>&order=updated&direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= t('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older first') : t('most recent first')) ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?action=mark-feed-as-read&feed_id=<?= $feed['id'] ?>" data-action="mark-feed-read" data-feed-id="<?= $feed['id'] ?>"><?= t('mark all as read') ?></a>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<h2><?= t('<span id="page-counter">%s</span>unread items', isset($nb_items) ? $nb_items.' ' : '') ?></h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="?action=unread&order=updated&direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= t('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older') : t('most recent')) ?></a>
|
||||
<a href="?action=unread&order=updated&direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= t('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older first') : t('most recent first')) ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?action=mark-as-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
|
||||
|
Loading…
Reference in New Issue
Block a user