From 19517baf13dba7ebd7d41dbbacceaea3ed75af8e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 30 Mar 2014 17:49:39 +0200 Subject: Add a bookmark to easily subscribe to websites - FeedController->addAction (GET) shows a confirmation page - If already subscribe, redirect to Configure->feedAction - Add a bookmark in aside_feed See #425 #426 and #464 --- app/Controllers/feedController.php | 53 +++++++++++++++++++--- app/i18n/en.php | 1 + app/i18n/fr.php | 3 +- app/layout/aside_feed.phtml | 6 +++ app/views/feed/add.phtml | 91 ++++++++++++++++++++++++++++++++++++++ p/scripts/main.js | 2 +- 6 files changed, 148 insertions(+), 8 deletions(-) create mode 100644 app/views/feed/add.phtml diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 16516ad39..503295587 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -22,13 +22,23 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } public function addAction () { - @set_time_limit(300); + $url = Minz_Request::param('url_rss', false); + + if ($url === false) { + Minz_Request::forward(array( + 'c' => 'configure', + 'a' => 'feed' + ), true); + } + + $feedDAO = new FreshRSS_FeedDAO (); + $this->catDAO = new FreshRSS_CategoryDAO (); + $this->catDAO->checkDefault (); + + if (Minz_Request::isPost()) { + @set_time_limit(300); - if (Minz_Request::isPost ()) { - $this->catDAO = new FreshRSS_CategoryDAO (); - $this->catDAO->checkDefault (); - $url = Minz_Request::param ('url_rss'); $cat = Minz_Request::param ('category', false); if ($cat === 'nc') { $new_cat = Minz_Request::param ('new_category'); @@ -60,7 +70,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed->load(true); - $feedDAO = new FreshRSS_FeedDAO (); $values = array ( 'url' => $feed->url (), 'category' => $feed->category (), @@ -154,6 +163,38 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); } + + // GET request so we must ask confirmation to user + Minz_View::prependTitle(Minz_Translate::t('add_rss_feed') . ' · '); + $this->view->categories = $this->catDAO->listCategories(); + $this->view->feed = new FreshRSS_Feed($url); + try { + // We try to get some more information about the feed + $this->view->feed->load(true); + $this->view->load_ok = true; + } catch (Exception $e) { + $this->view->load_ok = false; + } + + $feed = $feedDAO->searchByUrl($this->view->feed->url()); + if ($feed) { + // Already subscribe so we redirect to the feed configuration page + $notif = array( + 'type' => 'bad', + 'content' => Minz_Translate::t( + 'already_subscribed', $feed->name() + ) + ); + Minz_Session::_param('notification', $notif); + + Minz_Request::forward(array( + 'c' => 'configure', + 'a' => 'feed', + 'params' => array( + 'id' => $feed->id() + ) + ), true); + } } public function truncateAction () { diff --git a/app/i18n/en.php b/app/i18n/en.php index e9bed39a7..3d516bbb4 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -22,6 +22,7 @@ return array ( 'add_rss_feed' => 'Add a RSS feed', 'no_rss_feed' => 'No RSS feed', 'import_export' => 'Import / export', + 'bookmark' => 'Subscribe (FreshRSS bookmark)', 'subscription_management' => 'Subscriptions management', 'main_stream' => 'Main stream', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 24f3741c8..9d745fc9a 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -22,6 +22,7 @@ return array ( 'add_rss_feed' => 'Ajouter un flux RSS', 'no_rss_feed' => 'Aucun flux RSS', 'import_export' => 'Importer / exporter', + 'bookmark' => 'S’abonner (bookmark FreshRSS)', 'subscription_management' => 'Gestion des abonnements', 'main_stream' => 'Flux principal', @@ -89,7 +90,7 @@ return array ( 'already_subscribed' => 'Vous êtes déjà abonné à %s', 'feed_added' => 'Le flux %s a bien été ajouté', 'feed_not_added' => '%s n’a pas pu être ajouté', - 'internal_problem_feed' => 'Le flux n’a pas pu être ajouté. Consulter les logs de FreshRSS pour plus de détails.', + 'internal_problem_feed' => 'Le flux ne peux pas être ajouté. Consulter les logs de FreshRSS pour plus de détails.', 'invalid_url' => 'L’url %s est invalide', 'feed_actualized' => '%s a été mis à jour', 'n_feeds_actualized' => '%d flux ont été mis à jour', diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 899cafe02..7a5b2ce5e 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -43,6 +43,12 @@ +
  • + + + +
  • +
  • diff --git a/app/views/feed/add.phtml b/app/views/feed/add.phtml new file mode 100644 index 000000000..56ac5f8dd --- /dev/null +++ b/app/views/feed/add.phtml @@ -0,0 +1,91 @@ +feed) { ?> +
    +

    + + load_ok) { ?> +

    + + +
    + + load_ok) { ?> +
    + +
    + +
    +
    + + feed->description(); if ($desc != '') { ?> +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    + +
    + + +   +
    +
    +
    + +
    + + + + + +
    +
    + + + feed->httpAuth(false); ?> +
    + +
    + +
    + + +
    + +
    + +
    + +
    +
    + +
    +
    + + +
    +
    +
    +
    + diff --git a/p/scripts/main.js b/p/scripts/main.js index a03be85eb..818d459b3 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -988,7 +988,7 @@ function init_share_observers() { function init_feed_observers() { $('select[id="category"]').on('change', function() { - var detail = $(this).parent('li').next('li'); + var detail = $('#new_category_name').parent(); if ($(this).val() === 'nc') { detail.show(); detail.find('input').focus(); -- cgit v1.2.3