Add bookmarklet link (add a subscription directly from any browsers)

This commit is contained in:
Frédéric Guillot 2013-09-04 20:45:06 -04:00
parent 67d9fbd944
commit 2ec5d4ffb0
5 changed files with 28 additions and 6 deletions

View File

@ -496,10 +496,21 @@ Router\get_action('add', function() {
});
// Add the feed
Router\post_action('add', function() {
// Add a feed with the form or directly from the url, it can be used by a bookmarklet by example
Router\action('subscribe', function() {
$result = Model\import_feed(trim($_POST['url']), isset($_POST['download_content']) && $_POST['download_content'] == 1);
if (Request\param('url')) {
$values = array();
$url = Request\param('url');
}
else {
$values = Request\values();
$url = isset($values['url']) ? $values['url'] : '';
}
$values += array('download_content' => 0);
$url = trim($url);
$result = Model\import_feed($url, $values['download_content']);
if ($result) {
@ -512,7 +523,7 @@ Router\post_action('add', function() {
}
Response\html(Template\layout('add', array(
'values' => array('url' => $_POST['url']),
'values' => array('url' => $url),
'menu' => 'feeds',
'title' => t('Subscriptions')
)));

View File

@ -1,6 +1,9 @@
<?php
return array(
'Bookmarklet:' => 'Bookmarklet :',
'Subscribe with Miniflux' => 'S\'abonner avec Miniflux',
'Drag and drop this link to your bookmarks' => 'Glisser-déposer ce lien dans vos favoris',
'The content grabber is enabled successfully.' => 'Le téléchargement de contenu est activé avec succès.',
'Unable to activate the content grabber for this subscription.' => 'Impossible d\'activer le téléchargement de contenu pour cet abonnement.',
'enable full content' => 'télécharger le contenu complet',

View File

@ -7,7 +7,7 @@
</ul>
</div>
<form method="post" action="?action=add" autocomplete="off">
<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_checkbox('download_content', t('Download full content'), 1, isset($values['download_content']) ? $values['download_content'] : false) ?><br/>

View File

@ -40,7 +40,11 @@
<div class="alert alert-normal">
<h3 id="api"><?= t('API') ?></h3>
<ul>
<li><?= t('Bookmarks RSS Feed:') ?>
<li>
<?= t('Bookmarklet:') ?>
<a href="javascript:location.href='<?= Helper\get_current_base_url() ?>?action=subscribe&amp;url='+encodeURIComponent(location.href)"><?= t('Subscribe with Miniflux') ?></a> (<?= t('Drag and drop this link to your bookmarks') ?>)
<li>
<?= t('Bookmarks RSS Feed:') ?>
<a href="<?= Helper\get_current_base_url().'feed.php?token='.urlencode($values['feed_token']) ?>" target="_blank"><?= Helper\get_current_base_url().'feed.php?token='.urlencode($values['feed_token']) ?></a>
</li>
<li><?= t('API endpoint:') ?> <strong><?= Helper\get_current_base_url().'jsonrpc.php' ?></strong></li>

View File

@ -22,9 +22,13 @@ class Grabber
'article-content',
'articlePage',
'post-content',
'post_content',
'entry-content',
'main-content',
'entryBox',
'entrytext',
'comic',
'post',
'article',
'content',
'main',