Add option to force RTL mode per feed and improve feed modification

This commit is contained in:
Frédéric Guillot 2014-10-19 19:14:33 -04:00
parent e2280f1b7b
commit 53b94d8f7b
22 changed files with 120 additions and 169 deletions

View File

@ -263,6 +263,9 @@ textarea.form-error {
border-color: #ddd;
}
.alert-error a {
color: #b94a48;
}
/* buttons */
.btn {

View File

@ -53,78 +53,6 @@ Router\post_action('edit-feed', function() {
)));
});
// Disable content grabber for a feed
Router\get_action('disable-grabber-feed', function() {
$id = Request\int_param('feed_id');
if ($id && Model\Feed\disable_grabber($id)) {
Session\flash(t('The content grabber is disabled successfully.'));
}
else {
Session\flash_error(t('Unable to disable the content grabber for this subscription.'));
}
Response\redirect('?action=feeds');
});
// Enable content grabber for a feed
Router\get_action('enable-grabber-feed', function() {
$id = Request\int_param('feed_id');
if ($id && Model\Feed\enable_grabber($id)) {
Session\flash(t('The content grabber is enabled successfully.'));
}
else {
Session\flash_error(t('Unable to activate the content grabber for this subscription.'));
}
Response\redirect('?action=feeds');
});
// 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\Feed\get($id),
'menu' => 'feeds',
'title' => t('Confirmation')
)));
});
// Disable a feed
Router\get_action('disable-feed', function() {
$id = Request\int_param('feed_id');
if ($id && Model\Feed\disable($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\Feed\enable($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() {
@ -232,9 +160,9 @@ Router\action('subscribe', function() {
}
}
$values += array('download_content' => 0);
$values += array('download_content' => 0, 'rtl' => 0);
$url = trim($url);
$feed_id = Model\Feed\create($url, $values['download_content']);
$feed_id = Model\Feed\create($url, $values['download_content'], $values['rtl']);
if ($feed_id) {
Session\flash(t('Subscription added successfully.'));

View File

@ -2,9 +2,9 @@
namespace Helper;
function isRTL($language)
function isRTL(array $item)
{
return \PicoFeed\Parser::isLanguageRTL($language);
return ! empty($item['rtl']) || \PicoFeed\Parser::isLanguageRTL($item['language']);
}
function css()

View File

@ -225,4 +225,7 @@ return array(
// 'Display items on lists' => '',
// 'Summaries' => '',
// 'Full contents' => '',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -225,4 +225,7 @@ return array(
'Display items on lists' => 'Einträge in Listen anzeigen',
'Summaries' => 'Zusammenfassungen',
'Full contents' => 'Komplette Inhalte',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -225,4 +225,7 @@ return array(
// 'Display items on lists' => '',
// 'Summaries' => '',
// 'Full contents' => '',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -225,4 +225,7 @@ return array(
'Display items on lists' => 'Mode d\'affichage en listes',
'Summaries' => 'Résumés',
'Full contents' => 'Contenus complets',
'Force RTL mode (Right-to-left language)' => 'Forcer le mode RTL (Lecture de droite à gauche)',
'Activated' => 'Activé',
'Remove this feed' => 'Supprimer cet abonnement',
);

View File

@ -225,4 +225,7 @@ return array(
// 'Display items on lists' => '',
// 'Summaries' => '',
// 'Full contents' => '',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -225,4 +225,7 @@ return array(
// 'Display items on lists' => '',
// 'Summaries' => '',
// 'Full contents' => '',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -225,4 +225,7 @@ return array(
// 'Display items on lists' => '',
// 'Summaries' => '',
// 'Full contents' => '',
// 'Force RTL mode (Right-to-left language)' => '',
// 'Activated' => '',
// 'Remove this feed' => '',
);

View File

@ -8,7 +8,7 @@ use PicoDb\Database;
use PicoFeed\Config as ReaderConfig;
use PicoFeed\Logging;
const DB_VERSION = 27;
const DB_VERSION = 28;
const HTTP_USER_AGENT = 'Miniflux (http://miniflux.net)';
// Get PicoFeed config

View File

@ -23,7 +23,10 @@ function update(array $values)
->save(array(
'title' => $values['title'],
'site_url' => $values['site_url'],
'feed_url' => $values['feed_url']
'feed_url' => $values['feed_url'],
'enabled' => empty($values['enabled']) ? 0 : $values['enabled'],
'rtl' => empty($values['rtl']) ? 0 : $values['rtl'],
'download_content' => empty($values['download_content']) ? 0 : $values['download_content'],
));
}
@ -71,7 +74,7 @@ function import_opml($content)
}
// Add a new feed from an URL
function create($url, $enable_grabber = false)
function create($url, $enable_grabber = false, $force_rtl = false)
{
$reader = new Reader(Config\get_reader_config());
$resource = $reader->download($url);
@ -110,7 +113,8 @@ function create($url, $enable_grabber = false)
'title' => $feed->getTitle(),
'site_url' => $feed->getUrl(),
'feed_url' => $reader->getUrl(),
'download_content' => $enable_grabber ? 1 : 0
'download_content' => $enable_grabber ? 1 : 0,
'rtl' => $force_rtl ? 1 : 0,
));
if ($rs) {
@ -385,18 +389,6 @@ function disable($feed_id)
return Database::get('db')->table('feeds')->eq('id', $feed_id)->save((array('enabled' => 0)));
}
// Enable content download
function enable_grabber($feed_id)
{
return Database::get('db')->table('feeds')->eq('id', $feed_id)->save((array('download_content' => 1)));
}
// Disable content download
function disable_grabber($feed_id)
{
return Database::get('db')->table('feeds')->eq('id', $feed_id)->save((array('download_content' => 0)));
}
// Validation for edit
function validate_modification(array $values)
{

View File

@ -27,7 +27,8 @@ function get_everything()
'items.content',
'items.language',
'feeds.site_url',
'feeds.title AS feed_title'
'feeds.title AS feed_title',
'feeds.rtl'
)
->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread'))
@ -53,7 +54,8 @@ function get_everything_since($timestamp)
'items.content',
'items.language',
'feeds.site_url',
'feeds.title AS feed_title'
'feeds.title AS feed_title',
'feeds.rtl'
)
->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread'))
@ -90,7 +92,8 @@ function get_all($status, $offset = null, $limit = null, $order_column = 'update
'items.content',
'items.language',
'feeds.site_url',
'feeds.title AS feed_title'
'feeds.title AS feed_title',
'feeds.rtl'
)
->join('feeds', 'id', 'feed_id')
->eq('status', $status)
@ -137,7 +140,8 @@ function get_bookmarks($offset = null, $limit = null)
'items.feed_id',
'items.language',
'feeds.site_url',
'feeds.title AS feed_title'
'feeds.title AS feed_title',
'feeds.rtl'
)
->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread'))
@ -175,7 +179,8 @@ function get_all_by_feed($feed_id, $offset = null, $limit = null, $order_column
'items.content',
'items.bookmark',
'items.language',
'feeds.site_url'
'feeds.site_url',
'feeds.rtl'
)
->join('feeds', 'id', 'feed_id')
->in('status', array('unread', 'read'))

View File

@ -2,18 +2,21 @@
namespace Schema;
function version_28($pdo)
{
$pdo->exec('ALTER TABLE feeds ADD COLUMN rtl INTEGER DEFAULT 0');
}
function version_27($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN items_display_mode TEXT DEFAULT "summaries"');
}
function version_26($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN bookmarklet_token TEXT DEFAULT "'.\Model\Config\generate_token().'"');
}
function version_25($pdo)
{
$pdo->exec(
@ -30,38 +33,32 @@ function version_25($pdo)
);
}
function version_24($pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN auto_update_url TEXT DEFAULT 'https://github.com/fguillot/miniflux/archive/master.zip'");
}
function version_23($pdo)
{
$pdo->exec('ALTER TABLE items ADD COLUMN language TEXT');
}
function version_22($pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN timezone TEXT DEFAULT 'UTC'");
}
function version_21($pdo)
{
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure TEXT');
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure_type TEXT');
}
function version_20($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN redirect_nothing_to_read TEXT DEFAULT "feeds"');
}
function version_19($pdo)
{
$rq = $pdo->prepare('SELECT autoflush FROM config');
@ -75,50 +72,42 @@ function version_19($pdo)
}
}
function version_18($pdo)
{
$pdo->exec('ALTER TABLE feeds ADD COLUMN parsing_error INTEGER DEFAULT 0');
}
function version_17($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN items_sorting_direction TEXT DEFAULT "desc"');
}
function version_16($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN auth_google_token TEXT DEFAULT ""');
$pdo->exec('ALTER TABLE config ADD COLUMN auth_mozilla_token TEXT DEFAULT ""');
}
function version_15($pdo)
{
$pdo->exec('ALTER TABLE feeds ADD COLUMN download_content INTEGER DEFAULT 0');
}
function version_14($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN feed_token TEXT DEFAULT "'.\Model\Config\generate_token().'"');
}
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\Config\generate_token().'"');
}
function version_11($pdo)
{
$rq = $pdo->prepare('
@ -148,62 +137,52 @@ function version_11($pdo)
}
}
function version_10($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN theme TEXT DEFAULT "original"');
}
function version_9($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN items_per_page INTEGER DEFAULT 100');
}
function version_8($pdo)
{
$pdo->exec('ALTER TABLE items ADD COLUMN bookmark INTEGER DEFAULT 0');
}
function version_7($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN nocontent INTEGER DEFAULT 0');
}
function version_6($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN autoflush INTEGER DEFAULT 0');
}
function version_5($pdo)
{
$pdo->exec('ALTER TABLE feeds ADD COLUMN last_checked INTEGER');
}
function version_4($pdo)
{
$pdo->exec('CREATE INDEX idx_status ON items(status)');
}
function version_3($pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN language TEXT DEFAULT 'en_US'");
}
function version_2($pdo)
{
$pdo->exec('ALTER TABLE feeds ADD COLUMN last_modified TEXT');
$pdo->exec('ALTER TABLE feeds ADD COLUMN etag TEXT');
}
function version_1($pdo)
{
$pdo->exec("

View File

@ -1,10 +1,13 @@
#!/usr/bin/env php
<?php
$reference_file = $argv[1];
$outdated_file = $argv[2];
$reference_lang = 'fr_FR';
$reference_file = 'locales/'.$reference_lang.'/translations.php';
$reference = include $reference_file;
function update_missing_locales(array $reference, $outdated_file)
{
$outdated = include $outdated_file;
$output = '<?php'.PHP_EOL.PHP_EOL;
@ -13,15 +16,26 @@ $output .= 'return array('.PHP_EOL;
foreach ($reference as $key => $value) {
if (isset($outdated[$key])) {
//$output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $value)."',\n";
$output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n";
}
else {
//$output .= " // '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $value)."',\n";
$output .= " // '".str_replace("'", "\'", $key)."' => '',\n";
}
}
$output .= ');'.PHP_EOL;
$output .= ");\n";
return $output;
}
echo $output;
foreach (new DirectoryIterator('locales') as $fileInfo) {
if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== $reference_lang) {
$filename = 'locales/'.$fileInfo->getFilename().'/translations.php';
echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL;
file_put_contents($filename, update_missing_locales($reference, $filename));
}
}

View File

@ -9,8 +9,11 @@
<form method="post" action="?action=subscribe" autocomplete="off">
<?= Helper\form_label(t('Website or Feed URL'), 'url') ?>
<?= Helper\form_text('url', $values, array(), array('required', 'autofocus', 'placeholder="'.t('http://website/').'"')) ?>
<?= Helper\form_text('url', $values, array(), array('required', 'autofocus', 'placeholder="'.t('http://website/').'"')) ?><br/><br/>
<?= Helper\form_checkbox('rtl', t('Force RTL mode (Right-to-left language)'), 1, isset($values['rtl']) ? $values['rtl'] : false) ?><br/>
<?= Helper\form_checkbox('download_content', t('Download full content'), 1, isset($values['download_content']) ? $values['download_content'] : false) ?><br/>
<p class="form-help"><?= t('Downloading full content is slower because Miniflux grab the content from the original website. You should use that for subscriptions that display only a summary. This feature doesn\'t work with all websites.') ?></p>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Add') ?></button>

View File

@ -21,8 +21,20 @@
<?= Helper\form_label(t('Feed URL'), 'feed_url') ?>
<?= Helper\form_text('feed_url', $values, $errors, array('required', 'placeholder="http://..."')) ?>
<?= Helper\form_checkbox('rtl', t('Force RTL mode (Right-to-left language)'), 1, isset($values['rtl']) ? $values['rtl'] : false) ?><br />
<?= Helper\form_checkbox('download_content', t('Download full content'), 1, isset($values['download_content']) ? $values['download_content'] : false) ?><br />
<?= Helper\form_checkbox('enabled', t('Activated'), 1, isset($values['enabled']) ? $values['enabled'] : false) ?>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
<?= t('or') ?> <a href="?action=feeds"><?= t('cancel') ?></a>
</div>
</form>
<br/>
<div class="alert alert-error">
<ul>
<li><a href="?action=confirm-remove-feed&amp;feed_id=<?= $values['id'] ?>"><?= t('Remove this feed') ?></a></li>
</ul>
</div>

View File

@ -18,7 +18,14 @@
<section class="items" id="listing">
<?php foreach ($items as $item): ?>
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false, 'display_mode' => $display_mode)) ?>
<?= \PicoFarad\Template\load('item', array(
'feed' => $feed,
'item' => $item,
'menu' => $menu,
'offset' => $offset,
'hide' => false,
'display_mode' => $display_mode,
)) ?>
<?php endforeach ?>
<div id="bottom-menu">

View File

@ -56,33 +56,14 @@
<li>
<a href="<?= $feed['site_url'] ?>" rel="noreferrer" target="_blank"><?= Helper\get_host_from_url($feed['site_url']) ?></a>
</li>
<li class="hide-mobile">
<a href="?action=confirm-remove-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('remove') ?></a>
</li>
<li class="hide-mobile">
<?php if ($feed['download_content']): ?>
<a href="?action=disable-grabber-feed&amp;feed_id=<?= $feed['id'] ?>"><strong><?= t('disable full content') ?></strong></a>
<?php else: ?>
<a href="?action=enable-grabber-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('enable full content') ?></a>
<?php endif ?>
</li>
<?php if ($feed['enabled']): ?>
<li class="hide-mobile">
<a href="?action=confirm-disable-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('disable') ?></a>
</li>
<li class="hide-mobile">
<a href="?action=refresh-feed&amp;feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
</li>
<?php else: ?>
<li>
<a href="?action=enable-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('enable') ?></a>
<a href="?action=refresh-feed&amp;feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
</li>
<?php endif ?>
<li class="hide-mobile">
<a href="?action=edit-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('edit') ?></a>
</li>
<li><a href="?action=edit-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('edit') ?></a></li>
</ul>
</article>
<?php endforeach ?>

View File

@ -7,7 +7,7 @@
data-item-page="<?= $menu ?>"
<?= $hide ? 'data-hide="true"' : '' ?>
>
<h2 <?= Helper\isRTL($item['language']) ? 'dir="rtl"' : '' ?>>
<h2 <?= Helper\isRTL($item) ? 'dir="rtl"' : '' ?>>
<?= $item['bookmark'] ? '<span id="bookmark-icon-'.$item['id'].'">★ </span>' : '' ?>
<?= $item['status'] === 'read' ? '<span id="read-icon-'.$item['id'].'">✔ </span>' : '' ?>
<a
@ -20,11 +20,11 @@
</a>
</h2>
<?php if($display_mode === 'full'): ?>
<div class="preview" <?= Helper\isRTL($item['language']) ? 'dir="rtl"' : '' ?>>
<div class="preview" <?= Helper\isRTL($item) ? 'dir="rtl"' : '' ?>>
<?= $item['content'] ?>
</div>
<?php else: ?>
<p class="preview" <?= Helper\isRTL($item['language']) ? 'dir="rtl"' : '' ?>>
<p class="preview" <?= Helper\isRTL($item) ? 'dir="rtl"' : '' ?>>
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
</p>
<?php endif ?>

View File

@ -30,7 +30,7 @@
</nav>
<?php endif ?>
<h1 <?= Helper\isRTL($item['language']) ? 'dir="rtl"' : '' ?>>
<h1 <?= Helper\isRTL($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : '' ?>>
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-<?= $item['id'] ?>">
<?= Helper\escape($item['title']) ?>
</a>
@ -89,7 +89,7 @@
</li>
</ul>
<div id="item-content" <?= Helper\isRTL($item['language']) ? 'dir="rtl"' : '' ?>>
<div id="item-content" <?= Helper\isRTL($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : '' ?>>
<?php if ($item['enclosure']): ?>
<div id="item-content-enclosure">

View File

@ -16,7 +16,13 @@
<section class="items" id="listing">
<?php foreach ($items as $item): ?>
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true, 'display_mode' => $display_mode)) ?>
<?= \PicoFarad\Template\load('item', array(
'item' => $item,
'menu' => $menu,
'offset' => $offset,
'hide' => true,
'display_mode' => $display_mode,
)) ?>
<?php endforeach ?>
<div id="bottom-menu">