diff --git a/README.markdown b/README.markdown
index 767dafc..0ee82ae 100644
--- a/README.markdown
+++ b/README.markdown
@@ -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
diff --git a/index.php b/index.php
index 7b5d9af..6693434 100644
--- a/index.php
+++ b/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');
diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php
index ab2b013..08f43b5 100644
--- a/locales/fr_FR/translations.php
+++ b/locales/fr_FR/translations.php
@@ -1,10 +1,13 @@
'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, go back to unread items' => 'Cet abonnement est vide, retourner à la liste des éléments non lus',
'sort by date ' => 'trier par date ',
- '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',
diff --git a/model.php b/model.php
index 2892dd2..37a92ec 100644
--- a/model.php
+++ b/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();
}
diff --git a/schema.php b/schema.php
index c1fcaf5..58ab98e 100644
--- a/schema.php
+++ b/schema.php
@@ -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 ""');
diff --git a/templates/config.php b/templates/config.php
index 0e71a05..9a8d19a 100644
--- a/templates/config.php
+++ b/templates/config.php
@@ -22,6 +22,9 @@
= Helper\form_label(t('Items per page'), 'items_per_page') ?>
= Helper\form_select('items_per_page', $paging_options, $values, $errors) ?>
+ = Helper\form_label(t('Default sorting order for items'), 'items_sorting_direction') ?>
+ = Helper\form_select('items_sorting_direction', $sorting_options, $values, $errors) ?>
+
= Helper\form_label(t('Theme'), 'theme') ?>
= Helper\form_select('theme', $theme_options, $values, $errors) ?>
diff --git a/templates/feed_items.php b/templates/feed_items.php
index e9eb31b..2a57108 100644
--- a/templates/feed_items.php
+++ b/templates/feed_items.php
@@ -10,7 +10,7 @@