From c601c6e68d6af1ce58e93e076b1c073563163cde Mon Sep 17 00:00:00 2001 From: doubleface Date: Thu, 6 Jun 2013 11:54:22 -0400 Subject: [PATCH] Added nocontent feature to avoid a to big database --- assets/css/app.css | 4 ++++ common.php | 4 ++-- index.php | 4 ++-- locales/fr_FR/translations.php | 2 ++ model.php | 13 ++++++++++--- schema.php | 4 ++++ templates/config.php | 5 ++++- vendor/PicoTools/Helper.php | 6 ++++++ 8 files changed, 34 insertions(+), 8 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index 040a890..e5fc5d3 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -135,6 +135,10 @@ label { display: block; } +.inline-label { + display: inline; +} + input { -webkit-appearance: none; } diff --git a/common.php b/common.php index 5fc9893..705e633 100644 --- a/common.php +++ b/common.php @@ -10,7 +10,7 @@ require 'schema.php'; require 'model.php'; -const DB_VERSION = 6; +const DB_VERSION = 7; const APP_VERSION = 'master'; const APP_USERAGENT = 'Miniflux - http://miniflux.net'; const HTTP_TIMEOUT = 5; @@ -38,4 +38,4 @@ PicoTools\container('db', function() { die('Unable to migrate database schema.'); } -}); \ No newline at end of file +}); diff --git a/index.php b/index.php index 850c8e5..34b90f3 100644 --- a/index.php +++ b/index.php @@ -361,7 +361,7 @@ Router\get_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); if ($valid) { @@ -404,4 +404,4 @@ Router\notfound(function() { 'items' => $items, 'menu' => 'unread' ))); -}); \ No newline at end of file +}); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index e87df66..b8d990c 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -1,6 +1,8 @@ + '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', 'Never' => 'Jamais', 'After %d day' => 'Après %d jour', diff --git a/model.php b/model.php index a9ea1b1..da83e29 100644 --- a/model.php +++ b/model.php @@ -137,7 +137,6 @@ function update_feeds($limit = LIMIT_ALL) $feeds_id = get_feeds_id($limit); foreach ($feeds_id as $feed_id) { - update_feed($feed_id); } @@ -406,6 +405,8 @@ function autoflush() function update_items($feed_id, array $items) { + $nocontent = (bool)\PicoTools\singleton('db')->table('config')->findOneColumn('nocontent'); + $items_in_feed = array(); $db = \PicoTools\singleton('db'); @@ -418,6 +419,7 @@ function update_items($feed_id, array $items) // Insert only new item if ($db->table('items')->eq('id', $item->id)->count() !== 1) { + $content = $nocontent ? '' : $item->content; $db->table('items')->save(array( 'id' => $item->id, @@ -425,7 +427,7 @@ function update_items($feed_id, array $items) 'url' => $item->url, 'updated' => $item->updated, 'author' => $item->author, - 'content' => $item->content, + 'content' => $content, 'status' => 'unread', 'feed_id' => $feed_id )); @@ -456,7 +458,7 @@ function get_config() { return \PicoTools\singleton('db') ->table('config') - ->columns('username', 'language', 'autoflush') + ->columns('username', 'language', 'autoflush', 'nocontent') ->findOne(); } @@ -551,5 +553,10 @@ function save_config(array $values) \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); } diff --git a/schema.php b/schema.php index 3ec5beb..6636f5b 100644 --- a/schema.php +++ b/schema.php @@ -2,6 +2,10 @@ namespace Schema; +function version_7($pdo) +{ + $pdo->exec('ALTER TABLE config ADD COLUMN nocontent INTEGER'); +} function version_6($pdo) { diff --git a/templates/config.php b/templates/config.php index bf4f710..47b7c45 100644 --- a/templates/config.php +++ b/templates/config.php @@ -19,6 +19,9 @@
+ +
+
@@ -54,4 +57,4 @@
  • http://miniflux.net
  • - + \ No newline at end of file diff --git a/vendor/PicoTools/Helper.php b/vendor/PicoTools/Helper.php index a884898..767e15d 100644 --- a/vendor/PicoTools/Helper.php +++ b/vendor/PicoTools/Helper.php @@ -182,6 +182,12 @@ function form_radio($name, $label, $value, $selected = false, $class = '') return ''; } +function form_checkbox($name, $values, $class = '' ) +{ + $checkedstr = (bool)$values[$name] ? 'checked' : ''; + return ''; +} + function form_label($label, $name, $class = '') {