Added nocontent feature to avoid a to big database

This commit is contained in:
doubleface 2013-06-06 11:54:22 -04:00
parent 80f44c5311
commit c601c6e68d
8 changed files with 34 additions and 8 deletions

View File

@ -135,6 +135,10 @@ label {
display: block; display: block;
} }
.inline-label {
display: inline;
}
input { input {
-webkit-appearance: none; -webkit-appearance: none;
} }

View File

@ -10,7 +10,7 @@ require 'schema.php';
require 'model.php'; require 'model.php';
const DB_VERSION = 6; const DB_VERSION = 7;
const APP_VERSION = 'master'; const APP_VERSION = 'master';
const APP_USERAGENT = 'Miniflux - http://miniflux.net'; const APP_USERAGENT = 'Miniflux - http://miniflux.net';
const HTTP_TIMEOUT = 5; const HTTP_TIMEOUT = 5;
@ -38,4 +38,4 @@ PicoTools\container('db', function() {
die('Unable to migrate database schema.'); die('Unable to migrate database schema.');
} }
}); });

View File

@ -361,7 +361,7 @@ Router\get_action('config', function() {
Router\post_action('config', function() { Router\post_action('config', function() {
$values = Request\values(); $values = Request\values() + array('nocontent' => 0);
list($valid, $errors) = Model\validate_config_update($values); list($valid, $errors) = Model\validate_config_update($values);
if ($valid) { if ($valid) {
@ -404,4 +404,4 @@ Router\notfound(function() {
'items' => $items, 'items' => $items,
'menu' => 'unread' 'menu' => 'unread'
))); )));
}); });

View File

@ -1,6 +1,8 @@
<?php <?php
return array( return array(
'Do not fetch the content of articles (and remove it content for previous entries)' =>
'Ne pas récupérer le contenu des articles (et supprimer ce contenu pour les articles précédents',
'Remove automatically read items' => 'Supprimer automatiquement les éléments lus', 'Remove automatically read items' => 'Supprimer automatiquement les éléments lus',
'Never' => 'Jamais', 'Never' => 'Jamais',
'After %d day' => 'Après %d jour', 'After %d day' => 'Après %d jour',

View File

@ -137,7 +137,6 @@ function update_feeds($limit = LIMIT_ALL)
$feeds_id = get_feeds_id($limit); $feeds_id = get_feeds_id($limit);
foreach ($feeds_id as $feed_id) { foreach ($feeds_id as $feed_id) {
update_feed($feed_id); update_feed($feed_id);
} }
@ -406,6 +405,8 @@ function autoflush()
function update_items($feed_id, array $items) function update_items($feed_id, array $items)
{ {
$nocontent = (bool)\PicoTools\singleton('db')->table('config')->findOneColumn('nocontent');
$items_in_feed = array(); $items_in_feed = array();
$db = \PicoTools\singleton('db'); $db = \PicoTools\singleton('db');
@ -418,6 +419,7 @@ function update_items($feed_id, array $items)
// Insert only new item // Insert only new item
if ($db->table('items')->eq('id', $item->id)->count() !== 1) { if ($db->table('items')->eq('id', $item->id)->count() !== 1) {
$content = $nocontent ? '' : $item->content;
$db->table('items')->save(array( $db->table('items')->save(array(
'id' => $item->id, 'id' => $item->id,
@ -425,7 +427,7 @@ function update_items($feed_id, array $items)
'url' => $item->url, 'url' => $item->url,
'updated' => $item->updated, 'updated' => $item->updated,
'author' => $item->author, 'author' => $item->author,
'content' => $item->content, 'content' => $content,
'status' => 'unread', 'status' => 'unread',
'feed_id' => $feed_id 'feed_id' => $feed_id
)); ));
@ -456,7 +458,7 @@ function get_config()
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('config') ->table('config')
->columns('username', 'language', 'autoflush') ->columns('username', 'language', 'autoflush', 'nocontent')
->findOne(); ->findOne();
} }
@ -551,5 +553,10 @@ function save_config(array $values)
\PicoTools\Translator\load($values['language']); \PicoTools\Translator\load($values['language']);
// if the user does not want content of feeds, remote it in previous ones
if ((bool)$values['nocontent']) {
\PicoTools\singleton('db')->table('items')->update(array('content'=>''));
}
return \PicoTools\singleton('db')->table('config')->update($values); return \PicoTools\singleton('db')->table('config')->update($values);
} }

View File

@ -2,6 +2,10 @@
namespace Schema; namespace Schema;
function version_7($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN nocontent INTEGER');
}
function version_6($pdo) function version_6($pdo)
{ {

View File

@ -19,6 +19,9 @@
<?= Helper\form_label(t('Remove automatically read items'), 'autoflush') ?> <?= Helper\form_label(t('Remove automatically read items'), 'autoflush') ?>
<?= Helper\form_select('autoflush', $autoflush_options, $values, $errors) ?><br/> <?= Helper\form_select('autoflush', $autoflush_options, $values, $errors) ?><br/>
<?= Helper\form_label(t('Do not fetch the content of articles (and remove it content for previous entries)'), 'nocontent', "inline-label") ?>
<?= Helper\form_checkbox('nocontent', $values) ?><br />
<div class="form-actions"> <div class="form-actions">
<input type="submit" value="<?= t('Update') ?>" class="btn btn-blue"/> <input type="submit" value="<?= t('Update') ?>" class="btn btn-blue"/>
</div> </div>
@ -54,4 +57,4 @@
<li><?= t('Official website:') ?> <a href="http://miniflux.net" target="_blank">http://miniflux.net</a></li> <li><?= t('Official website:') ?> <a href="http://miniflux.net" target="_blank">http://miniflux.net</a></li>
</ul> </ul>
</div> </div>
</section> </section>

View File

@ -182,6 +182,12 @@ function form_radio($name, $label, $value, $selected = false, $class = '')
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($selected ? 'selected="selected"' : '').'>'.escape($label).'</label>'; return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($selected ? 'selected="selected"' : '').'>'.escape($label).'</label>';
} }
function form_checkbox($name, $values, $class = '' )
{
$checkedstr = (bool)$values[$name] ? 'checked' : '';
return '<input type="checkbox" value="1" name="'.$name.'" class="'.$class.'"'.$checkedstr.'>';
}
function form_label($label, $name, $class = '') function form_label($label, $name, $class = '')
{ {