Add the possibility to disable/enable a feed
This commit is contained in:
parent
40ab99cd6c
commit
e7be31c92c
@ -375,6 +375,11 @@ nav .active a {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.feed-disabled,
|
||||
.feed-disabled a {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
|
||||
/* items listing */
|
||||
.items article {
|
||||
|
@ -210,7 +210,6 @@
|
||||
var feed_id = links[i].getAttribute('data-feed-id');
|
||||
|
||||
if (feed_id) {
|
||||
|
||||
feeds.push(parseInt(feed_id));
|
||||
}
|
||||
}
|
||||
|
154
index.php
154
index.php
@ -279,62 +279,6 @@ Router\get_action('bookmarks', function() {
|
||||
});
|
||||
|
||||
|
||||
// Confirmation box to remove a feed
|
||||
Router\get_action('confirm-remove-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
Response\html(Template\layout('confirm_remove_feed', array(
|
||||
'feed' => Model\get_feed($id),
|
||||
'menu' => 'feeds',
|
||||
'title' => t('Confirmation')
|
||||
)));
|
||||
});
|
||||
|
||||
|
||||
// Remove a feed
|
||||
Router\get_action('remove-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
if ($id && Model\remove_feed($id)) {
|
||||
|
||||
Session\flash(t('This subscription has been removed successfully.'));
|
||||
}
|
||||
else {
|
||||
|
||||
Session\flash_error(t('Unable to remove this subscription.'));
|
||||
}
|
||||
|
||||
Response\redirect('?action=feeds');
|
||||
});
|
||||
|
||||
|
||||
// Refresh one feed and redirect to unread items
|
||||
Router\get_action('refresh-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
if ($id) Model\update_feed($id);
|
||||
Model\write_debug();
|
||||
Response\redirect('?action=unread');
|
||||
});
|
||||
|
||||
|
||||
// Ajax call to refresh one feed
|
||||
Router\post_action('refresh-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id', 0);
|
||||
|
||||
if ($id) {
|
||||
|
||||
$result = Model\update_feed($id);
|
||||
Model\write_debug();
|
||||
}
|
||||
|
||||
Response\json(array('feed_id' => $id, 'result' => $result));
|
||||
});
|
||||
|
||||
|
||||
// Mark all unread items as read
|
||||
Router\get_action('mark-as-read', function() {
|
||||
|
||||
@ -380,6 +324,104 @@ Router\get_action('refresh-all', function() {
|
||||
});
|
||||
|
||||
|
||||
// Confirmation box to disable a feed
|
||||
Router\get_action('confirm-disable-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
Response\html(Template\layout('confirm_disable_feed', array(
|
||||
'feed' => Model\get_feed($id),
|
||||
'menu' => 'feeds',
|
||||
'title' => t('Confirmation')
|
||||
)));
|
||||
});
|
||||
|
||||
|
||||
// Disable a feed
|
||||
Router\get_action('disable-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
if ($id && Model\disable_feed($id)) {
|
||||
Session\flash(t('This subscription has been disabled successfully.'));
|
||||
}
|
||||
else {
|
||||
Session\flash_error(t('Unable to disable this subscription.'));
|
||||
}
|
||||
|
||||
Response\redirect('?action=feeds');
|
||||
});
|
||||
|
||||
|
||||
// Enable a feed
|
||||
Router\get_action('enable-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
if ($id && Model\enable_feed($id)) {
|
||||
Session\flash(t('This subscription has been enabled successfully.'));
|
||||
}
|
||||
else {
|
||||
Session\flash_error(t('Unable to enable this subscription.'));
|
||||
}
|
||||
|
||||
Response\redirect('?action=feeds');
|
||||
});
|
||||
|
||||
|
||||
// Confirmation box to remove a feed
|
||||
Router\get_action('confirm-remove-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
Response\html(Template\layout('confirm_remove_feed', array(
|
||||
'feed' => Model\get_feed($id),
|
||||
'menu' => 'feeds',
|
||||
'title' => t('Confirmation')
|
||||
)));
|
||||
});
|
||||
|
||||
|
||||
// Remove a feed
|
||||
Router\get_action('remove-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
|
||||
if ($id && Model\remove_feed($id)) {
|
||||
Session\flash(t('This subscription has been removed successfully.'));
|
||||
}
|
||||
else {
|
||||
Session\flash_error(t('Unable to remove this subscription.'));
|
||||
}
|
||||
|
||||
Response\redirect('?action=feeds');
|
||||
});
|
||||
|
||||
|
||||
// Refresh one feed and redirect to unread items
|
||||
Router\get_action('refresh-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id');
|
||||
if ($id) Model\update_feed($id);
|
||||
Model\write_debug();
|
||||
Response\redirect('?action=unread');
|
||||
});
|
||||
|
||||
|
||||
// Ajax call to refresh one feed
|
||||
Router\post_action('refresh-feed', function() {
|
||||
|
||||
$id = Request\int_param('feed_id', 0);
|
||||
|
||||
if ($id) {
|
||||
$result = Model\update_feed($id);
|
||||
Model\write_debug();
|
||||
}
|
||||
|
||||
Response\json(array('feed_id' => $id, 'result' => $result));
|
||||
});
|
||||
|
||||
|
||||
// Display all feeds
|
||||
Router\get_action('feeds', function() {
|
||||
|
||||
|
12
jsonrpc.php
12
jsonrpc.php
@ -37,6 +37,18 @@ $server->register('feed.delete', function($feed_id) {
|
||||
return Model\remove_feed($feed_id);
|
||||
});
|
||||
|
||||
// Enable a feed
|
||||
$server->register('feed.enable', function($feed_id) {
|
||||
|
||||
return Model\enable_feed($feed_id);
|
||||
});
|
||||
|
||||
// Disable a feed
|
||||
$server->register('feed.disable', function($feed_id) {
|
||||
|
||||
return Model\disable_feed($feed_id);
|
||||
});
|
||||
|
||||
// Update a feed
|
||||
$server->register('feed.update', function($feed_id) {
|
||||
|
||||
|
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Unable to enable this subscription.' => 'Impossible d\'activer cet abonnement.',
|
||||
'This subscription has been enabled successfully.' => 'L\'abonnement a été activé avec succès.',
|
||||
'Unable to disable this subscription.' => 'Impossible de désactiver cet abonnement.',
|
||||
'This subscription has been disabled successfully.' => 'L\'abonnement a été désactivé avec succès.',
|
||||
'Do you really want to disable this subscription: "%s"?' => 'Voulez-vous vraiment désactiver cet abonnement : "%s" ?',
|
||||
'enable' => 'activer',
|
||||
'disable' => 'désactiver',
|
||||
'Subscription disabled' => 'Abonnement désactivé',
|
||||
'Listing' => 'Liste',
|
||||
'content downloaded' => 'contenu téléchargé',
|
||||
'in progress...' => 'en cours...',
|
||||
|
18
model.php
18
model.php
@ -25,7 +25,7 @@ use PicoFeed\Reader;
|
||||
use PicoFeed\Export;
|
||||
|
||||
|
||||
const DB_VERSION = 12;
|
||||
const DB_VERSION = 13;
|
||||
const HTTP_USERAGENT = 'Miniflux - http://miniflux.net';
|
||||
const LIMIT_ALL = -1;
|
||||
|
||||
@ -241,6 +241,7 @@ function update_feed($feed_id)
|
||||
function get_feeds_id($limit = LIMIT_ALL)
|
||||
{
|
||||
$table_feeds = \PicoTools\singleton('db')->table('feeds')
|
||||
->eq('enabled', 1)
|
||||
->asc('last_checked');
|
||||
|
||||
if ($limit !== LIMIT_ALL) {
|
||||
@ -369,8 +370,19 @@ function download_item($item_id)
|
||||
function remove_feed($feed_id)
|
||||
{
|
||||
// Items are removed by a sql constraint
|
||||
$db = \PicoTools\singleton('db');
|
||||
return $db->table('feeds')->eq('id', $feed_id)->remove();
|
||||
return \PicoTools\singleton('db')->table('feeds')->eq('id', $feed_id)->remove();
|
||||
}
|
||||
|
||||
|
||||
function enable_feed($feed_id)
|
||||
{
|
||||
return \PicoTools\singleton('db')->table('feeds')->eq('id', $feed_id)->save((array('enabled' => 1)));
|
||||
}
|
||||
|
||||
|
||||
function disable_feed($feed_id)
|
||||
{
|
||||
return \PicoTools\singleton('db')->table('feeds')->eq('id', $feed_id)->save((array('enabled' => 0)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,12 @@
|
||||
namespace Schema;
|
||||
|
||||
|
||||
function version_13($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE feeds ADD COLUMN enabled INTEGER DEFAULT 1');
|
||||
}
|
||||
|
||||
|
||||
function version_12($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT "'.\Model\generate_api_token().'"');
|
||||
|
10
templates/confirm_disable_feed.php
Normal file
10
templates/confirm_disable_feed.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Confirmation') ?></h2>
|
||||
</div>
|
||||
|
||||
<p class="alert alert-info"><?= t('Do you really want to disable this subscription: "%s"?', Helper\escape($feed['title'])) ?></p>
|
||||
|
||||
<div class="form-actions">
|
||||
<a href="?action=disable-feed&feed_id=<?= $feed['id'] ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
||||
<?= t('or') ?> <a href="?action=feeds"><?= t('cancel') ?></a>
|
||||
</div>
|
@ -21,16 +21,29 @@
|
||||
<section class="items">
|
||||
<?php foreach ($feeds as $feed): ?>
|
||||
<article>
|
||||
<h2>
|
||||
<h2 class="<?= (! $feed['enabled']) ? 'feed-disabled' : '' ?>">
|
||||
<?php if (! $feed['enabled']): ?>
|
||||
<span title="<?= t('Subscription disabled') ?>">∅</a>
|
||||
<?php else: ?>
|
||||
<span id="loading-feed-<?= $feed['id'] ?>"></span>
|
||||
<?php endif ?>
|
||||
|
||||
<a href="<?= $feed['site_url'] ?>" rel="noreferrer" target="_blank"><?= Helper\escape($feed['title']) ?></a>
|
||||
|
||||
</h2>
|
||||
<p>
|
||||
<a href="<?= $feed['site_url'] ?>" rel="noreferrer" target="_blank"><?= Helper\get_host_from_url($feed['site_url']) ?></a> |
|
||||
<span class="hide-mobile"><a href="<?= Helper\escape($feed['feed_url']) ?>" rel="noreferrer" target="_blank"><?= t('feed link') ?></a> |</span>
|
||||
|
||||
<span class="hide-mobile"><a href="?action=confirm-remove-feed&feed_id=<?= $feed['id'] ?>"><?= t('remove') ?></a> |</span>
|
||||
<span class="hide-mobile"><a href="?action=feed-items&feed_id=<?= $feed['id'] ?>"><?= t('items') ?></a> |</span>
|
||||
<a href="?action=refresh-feed&feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
|
||||
|
||||
<?php if ($feed['enabled']): ?>
|
||||
<span class="hide-mobile"><a href="?action=confirm-disable-feed&feed_id=<?= $feed['id'] ?>"><?= t('disable') ?></a> |</span>
|
||||
<a href="?action=refresh-feed&feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a> |
|
||||
<?php else: ?>
|
||||
<span class="hide-mobile"><a href="?action=enable-feed&feed_id=<?= $feed['id'] ?>"><?= t('enable') ?></a> |</span>
|
||||
<?php endif ?>
|
||||
|
||||
<span class="hide-mobile"><a href="?action=feed-items&feed_id=<?= $feed['id'] ?>"><?= t('items') ?></a></span>
|
||||
</p>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
|
Loading…
Reference in New Issue
Block a user