From 87bfa195a6ff4ff73baadd3c04b7b6f28c9f9b73 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 24 Dec 2013 01:21:11 +0100 Subject: [PATCH] =?UTF-8?q?Permet=20de=20configurer=20plus=20finement=20le?= =?UTF-8?q?=20nombre=20d=E2=80=99articles=20minimum=20=C3=A0=20conserver?= =?UTF-8?q?=20par=20flux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 1 + app/Controllers/feedController.php | 20 ++++++++------------ app/Models/EntryDAO.php | 2 +- app/Models/Feed.php | 17 +++++------------ app/Models/FeedDAO.php | 4 ++-- app/i18n/en.php | 7 +++++-- app/i18n/fr.php | 8 ++++++-- app/views/configure/display.phtml | 29 +++++++++++++++++++++-------- app/views/configure/feed.phtml | 22 ++++++++++++++++++---- public/install.php | 2 +- 10 files changed, 68 insertions(+), 44 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af6936204..0c816dbd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Améliorations partage vers Shaarli, Poche, Diaspora*, Facebook, Twitter, Google+, courriel * Permet la suppression de tous les articles d’un flux * Option pour marquer les articles comme lus dès la réception + * Permet de configurer plus finement le nombre d’articles minimum à conserver par flux * Permet de modifier la description et l’adresse d’un flux RSS ainsi que le site Web associé * Nouveau raccourci pour ouvrir/fermer un article (‘c’ par défaut) * Bouton pour effacer les logs diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 27b76dd42..e7d9c97c3 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -102,14 +102,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->beginTransaction (); // on ajoute les articles en masse sans vérification foreach ($entries as $entry) { - if ($entry->date (true) >= $date_min || - $feed->keepHistory ()) { - $values = $entry->toArray (); - $values['id_feed'] = $feed->id (); - $values['id'] = min(time(), $entry->date (true)) . uSecString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry ($values); - } + $values = $entry->toArray (); + $values['id_feed'] = $feed->id (); + $values['id'] = min(time(), $entry->date (true)) . uSecString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry ($values); } $feedDAO->updateLastUpdate ($feed->id ()); $feedDAO->commit (); @@ -217,8 +214,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->beginTransaction (); foreach ($entries as $entry) { if ((!isset ($existingGuids[$entry->guid ()])) && - ($entry->date (true) >= $date_min || - $feed->keepHistory ())) { + ($entry->date (true) >= $date_min)) { $values = $entry->toArray (); //Use declared date at first import, otherwise use discovery date $values['id'] = empty($existingGuids) ? min(time(), $entry->date (true)) . uSecString() : uTimeString(); @@ -227,8 +223,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - if ((!$feed->keepHistory()) && (rand(0, 30) === 1)) { - $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, count($entries) + 10); + if (($feed->keepHistory() >= 0) && (rand(0, 30) === 1)) { + $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feed->keepHistory(), count($entries) + 10)); if ($nb > 0) { Minz_Log::record ($nb . ' old entries cleaned in feed ' . $feed->id (), Minz_Log::DEBUG); } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index c6bd5c404..f0207e96d 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -307,7 +307,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; } if (($date_min > 0) && ($type !== 's')) { - $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR f.keep_history = 1) '; + $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR f.keep_history <> 0) '; $joinFeed = true; } $search = ''; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 70efb0fa3..5bdf5e6d7 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -15,7 +15,7 @@ class FreshRSS_Feed extends Minz_Model { private $pathEntries = ''; private $httpAuth = ''; private $error = false; - private $keep_history = false; + private $keep_history = 0; public function __construct ($url, $validate=true) { if ($validate) { @@ -163,19 +163,12 @@ class FreshRSS_Feed extends Minz_Model { $this->httpAuth = $value; } public function _error ($value) { - if ($value) { - $value = true; - } else { - $value = false; - } - $this->error = $value; + $this->error = (bool)$value; } public function _keepHistory ($value) { - if ($value) { - $value = true; - } else { - $value = false; - } + $value = intval($value); + $value = min($value, 1000000); + $value = max($value, -1); $this->keep_history = $value; } public function _nbNotRead ($value) { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 9bd480544..451fc3850 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -193,7 +193,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } public function listFeedsOrderUpdate () { - $sql = 'SELECT * FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + $sql = 'SELECT id, url, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; $stm = $this->bd->prepare ($sql); $stm->execute (); @@ -326,7 +326,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $myFeed->_pathEntries (isset($dao['pathEntries']) ? $dao['pathEntries'] : ''); $myFeed->_httpAuth (isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : ''); $myFeed->_error ($dao['error']); - $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : ''); + $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : 0); $myFeed->_nbNotRead ($dao['cache_nbUnreads']); $myFeed->_nbEntries ($dao['cache_nbEntries']); if (isset ($dao['id'])) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 9c30573e8..b6417d8db 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -137,7 +137,8 @@ return array ( 'feed_url' => 'Feed URL', 'articles' => 'articles', 'number_articles' => 'Number of articles', - 'keep_history' => 'Keep old articles?', + 'keep_history' => 'Minimum number of articles to keep', + 'keep_history_help' => 'Set to -1 to keep everything', 'categorize' => 'Store in a category', 'truncate' => 'Delete all articles', 'advanced' => 'Advanced', @@ -157,13 +158,15 @@ return array ( 'general_configuration' => 'General configuration', 'language' => 'Language', - 'delete_articles_every' => 'Remove articles after', 'month' => 'months', 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)', 'persona_connection_email' => 'Login mail address (use Mozilla Persona)', 'allow_anonymous' => 'Allow anonymous reading', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output without authentication.
%s?token=%s', + 'archiving_configuration' => 'Archiving configuration', + 'delete_articles_every' => 'Remove articles after', + 'archiving_configuration_help' => 'More options are available in the individual stream settings', 'reading_configuration' => 'Reading configuration', 'articles_per_page' => 'Number of articles per page', 'default_view' => 'Default view', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 85bbeb4b7..b27f29940 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -137,7 +137,8 @@ return array ( 'feed_url' => 'URL du flux', 'articles' => 'articles', 'number_articles' => 'Nombre d’articles', - 'keep_history' => 'Garder les vieux articles ?', + 'keep_history' => 'Nombre minimum d’articles à conserver', + 'keep_history_help' => 'Mettre à -1 pour tout conserver', 'categorize' => 'Ranger dans une catégorie', 'truncate' => 'Supprimer tous les articles', 'advanced' => 'Avancé', @@ -157,13 +158,16 @@ return array ( 'general_configuration' => 'Configuration générale', 'language' => 'Langue', - 'delete_articles_every' => 'Supprimer les articles après', + 'month' => 'mois', 'default_user' => 'Nom de l’utilisateur par défaut (16 caractères alphanumériques maximum)', 'persona_connection_email' => 'Adresse courriel de connexion (utilise Mozilla Persona)', 'allow_anonymous' => 'Autoriser la lecture anonyme', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS sans besoin de s’authentifier.
%s?output=rss&token=%s', + 'archiving_configuration' => 'Configuration de l’archivage', + 'delete_articles_every' => 'Supprimer les articles après', + 'archiving_configuration_help' => 'D’autres options sont disponibles dans la configuration individuelle des flux', 'reading_configuration' => 'Configuration de lecture', 'articles_per_page' => 'Nombre d’articles par page', 'default_view' => 'Vue par défaut', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index ad35d7c71..68ef26bbf 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -31,13 +31,6 @@ -
- -
- -
-
-
conf->mailLogin (); ?> @@ -59,7 +52,27 @@
- + + + +
+ +
+ + + + + + + + + + +
+ +
+
+
diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 4504b8d76..3fe7d1b3a 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -52,6 +52,9 @@
+ + +
@@ -64,10 +67,21 @@
flux->nbEntries (); ?> - +
+
+
+ +
+ + + + + + + + + +
diff --git a/public/install.php b/public/install.php index afef7e473..3885f143e 100644 --- a/public/install.php +++ b/public/install.php @@ -93,7 +93,7 @@ FROM `%1$scategory006` ORDER BY id2; INSERT IGNORE INTO `%2$sfeed` (url, category, name, website, description, priority, pathEntries, httpAuth, keep_history) -SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, keep_history +SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, -1 * keep_history FROM `%1$sfeed006` ORDER BY id2;