From 2ec5d4ffb0beaa44fe5c0bfd7abdcd227997dfdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 4 Sep 2013 20:45:06 -0400 Subject: [PATCH] Add bookmarklet link (add a subscription directly from any browsers) --- index.php | 19 +++++++++++++++---- locales/fr_FR/translations.php | 3 +++ templates/add.php | 2 +- templates/config.php | 6 +++++- vendor/PicoFeed/Grabber.php | 4 ++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index a6eaab2..a9d506d 100644 --- a/index.php +++ b/index.php @@ -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') ))); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 3798320..8ec548a 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -1,6 +1,9 @@ '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', diff --git a/templates/add.php b/templates/add.php index 291f9a8..a0b9e53 100644 --- a/templates/add.php +++ b/templates/add.php @@ -7,7 +7,7 @@ -
+
diff --git a/templates/config.php b/templates/config.php index a813680..e50d899 100644 --- a/templates/config.php +++ b/templates/config.php @@ -40,7 +40,11 @@

    -
  • +
  • + + () +
  • +
  • diff --git a/vendor/PicoFeed/Grabber.php b/vendor/PicoFeed/Grabber.php index 06f822b..5483d82 100644 --- a/vendor/PicoFeed/Grabber.php +++ b/vendor/PicoFeed/Grabber.php @@ -22,9 +22,13 @@ class Grabber 'article-content', 'articlePage', 'post-content', + 'post_content', 'entry-content', 'main-content', + 'entryBox', + 'entrytext', 'comic', + 'post', 'article', 'content', 'main',