aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-24 01:21:11 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-24 01:21:11 +0100
commit87bfa195a6ff4ff73baadd3c04b7b6f28c9f9b73 (patch)
tree927fbfc08401e69d81c0e14fb1fb54d878ac97dd
parentffbe676d7d33f8e075018bfa35f0d919e3e1a9bf (diff)
Permet de configurer plus finement le nombre d’articles minimum à conserver par flux
-rw-r--r--CHANGELOG1
-rwxr-xr-xapp/Controllers/feedController.php20
-rw-r--r--app/Models/EntryDAO.php2
-rw-r--r--app/Models/Feed.php17
-rw-r--r--app/Models/FeedDAO.php4
-rw-r--r--app/i18n/en.php7
-rw-r--r--app/i18n/fr.php8
-rw-r--r--app/views/configure/display.phtml29
-rw-r--r--app/views/configure/feed.phtml22
-rw-r--r--public/install.php2
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 <a href="https://persona.org/">Mozilla Persona</a>)',
'allow_anonymous' => 'Allow anonymous reading',
'auth_token' => 'Authentication token',
'explain_token' => 'Allows to access RSS output without authentication.<br />%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 <a href="https://persona.org/">Mozilla Persona</a>)',
'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.<br />%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
@@ -32,13 +32,6 @@
</div>
<div class="form-group">
- <label class="group-name" for="old_entries"><?php echo Minz_Translate::t ('delete_articles_every'); ?></label>
- <div class="group-controls">
- <input type="number" id="old_entries" name="old_entries" value="<?php echo $this->conf->oldEntries (); ?>" /> <?php echo Minz_Translate::t ('month'); ?>
- </div>
- </div>
-
- <div class="form-group">
<label class="group-name" for="mail_login"><?php echo Minz_Translate::t ('persona_connection_email'); ?></label>
<?php $mail = $this->conf->mailLogin (); ?>
<div class="group-controls">
@@ -59,7 +52,27 @@
<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('explain_token', Minz_Url::display(null, 'html', true), $token); ?>
</div>
</div>
-
+
+ <legend><?php echo Minz_Translate::t ('archiving_configuration'); ?></legend>
+
+ <div class="form-group">
+ <label class="group-name" for="old_entries"><?php echo Minz_Translate::t ('delete_articles_every'); ?></label>
+ <div class="group-controls">
+ <input type="number" id="old_entries" name="old_entries" list="list_months" min="1" max="1200" value="<?php echo $this->conf->oldEntries (); ?>" /> <?php echo Minz_Translate::t ('month'); ?>
+ <datalist id="list_months">
+ <option>1</option>
+ <option>2</option>
+ <option>3</option>
+ <option>6</option>
+ <option>12</option>
+ <option>18</option>
+ <option>24</option>
+ <option>36</option>
+ </datalist><br />
+ <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('archiving_configuration_help'); ?>
+ </div>
+ </div>
+
<legend><?php echo Minz_Translate::t ('reading_configuration'); ?></legend>
<div class="form-group">
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 @@
</select>
</div>
</div>
+
+ <legend><?php echo Minz_Translate::t ('archiving_configuration'); ?></legend>
+
<div class="form-group">
<label class="group-name"></label>
<div class="group-controls">
@@ -64,10 +67,21 @@
<label class="group-name"><?php echo Minz_Translate::t ('number_articles'); ?></label>
<div class="group-controls">
<span class="control"><?php echo $this->flux->nbEntries (); ?></span>
- <label class="checkbox" for="keep_history">
- <input type="checkbox" name="keep_history" id="keep_history" value="yes"<?php echo $this->flux->keepHistory () == 'yes' ? ' checked="checked"' : ''; ?> />
- <?php echo Minz_Translate::t ('keep_history'); ?>
- </label>
+ </div>
+ </div>
+ <div class="form-group">
+ <label class="group-name" for="keep_history"><?php echo Minz_Translate::t ('keep_history'); ?></label>
+ <div class="group-controls">
+ <input type="number" name="keep_history" id="keep_history" list="old_values" min="-1" max="1000000" value="<?php echo $this->flux->keepHistory(); ?>" />
+ <datalist id="old_values">
+ <option value="0">0</option>
+ <option value="10">10</option>
+ <option value="100">100</option>
+ <option value="1000">1 000</option>
+ <option value="10000">10 000</option>
+ <option value="-1">∞</option>
+ </datalist>
+ <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t ('keep_history_help'); ?>
</div>
</div>
<div class="form-group">
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;