A free, self-hostable news aggregator…
Add a bookmark to easily subscribe to websites
Marien Fressinaud19517baf13db
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 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.phpindex 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.phpindex 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é à <em>%s</em>','feed_added' => 'Le flux <em>%s</em> a bien été ajouté','feed_not_added' => '<em>%s</em> n’a pas pu être ajouté',- 'internal_problem_feed' => 'Le flux n’a pas pu être ajouté. <a href="%s">Consulter les logs de FreshRSS</a> pour plus de détails.',+ 'internal_problem_feed' => 'Le flux ne peux pas être ajouté. <a href="%s">Consulter les logs de FreshRSS</a> pour plus de détails.','invalid_url' => 'L’url <em>%s</em> est invalide','feed_actualized' => '<em>%s</em> 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.phtmlindex 899cafe02..7a5b2ce5e 100644--- a/app/layout/aside_feed.phtml+++ b/app/layout/aside_feed.phtml@@ -43,6 +43,12 @@</div></form></li>+ <li class="item">+ <a href="javascript:(function(){var%20url%20=%20location.href;window.open('<?php echo Minz_Url::display(array('c' => 'feed', 'a' => 'add'), 'html', true); ?>&url_rss='+encodeURIComponent(url), '_blank');})();">+ <?php echo Minz_Translate::t('bookmark'); ?>+ </a>+ </li>+<li class="item<?php echo Minz_Request::actionName () == 'importExport' ? ' active' : ''; ?>"><a href="<?php echo _url ('importExport', 'index'); ?>"><?php echo Minz_Translate::t ('import_export'); ?></a></li>diff --git a/app/views/feed/add.phtml b/app/views/feed/add.phtmlnew file mode 100644index 000000000..56ac5f8dd--- /dev/null+++ b/app/views/feed/add.phtml@@ -0,0 +1,91 @@+<?php if ($this->feed) { ?>+<div class="post">+ <h1><?php echo Minz_Translate::t ('add_rss_feed'); ?></h1>++ <?php if (!$this->load_ok) { ?>+ <p class="alert alert-error"><span class="alert-head"><?php echo Minz_Translate::t('damn'); ?></span> <?php echo Minz_Translate::t('internal_problem_feed', _url('index', 'logs')); ?></p>+ <?php } ?>++ <form method="post" action="<?php echo _url('feed', 'add'); ?>" autocomplete="off">+ <legend><?php echo Minz_Translate::t('informations'); ?></legend>+ <?php if ($this->load_ok) { ?>+ <div class="form-group">+ <label class="group-name"><?php echo Minz_Translate::t('title'); ?></label>+ <div class="group-controls">+ <label><?php echo $this->feed->name() ; ?></label>+ </div>+ </div>++ <?php $desc = $this->feed->description(); if ($desc != '') { ?>+ <div class="form-group">+ <label class="group-name"><?php echo Minz_Translate::t('feed_description'); ?></label>+ <div class="group-controls">+ <label><?php echo htmlspecialchars($desc, ENT_NOQUOTES, 'UTF-8'); ?></label>+ </div>+ </div>+ <?php } ?>++ <div class="form-group">+ <label class="group-name"><?php echo Minz_Translate::t('website_url'); ?></label>+ <div class="group-controls">+ <label>+ <?php echo $this->feed->website(); ?>+ <a target="_blank" href="<?php echo $this->feed->website(); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a>+ </label>+ </div>+ </div>+ <?php } ?>++ <div class="form-group">+ <label class="group-name" for="url"><?php echo Minz_Translate::t('feed_url'); ?></label>+ <div class="group-controls">+ <input type="text" name="url_rss" id="url" class="extend" value="<?php echo $this->feed->url(); ?>" />+ <a target="_blank" href="<?php echo $this->feed->url(); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a>+ <a class="btn" target="_blank" href="http://validator.w3.org/feed/check.cgi?url=<?php echo $this->feed->url(); ?>"><?php echo Minz_Translate::t('feed_validator'); ?></a>+ </div>+ </div>+ <div class="form-group">+ <label class="group-name" for="category"><?php echo Minz_Translate::t('category'); ?></label>+ <div class="group-controls">+ <select name="category" id="category">+ <?php foreach ($this->categories as $cat) { ?>+ <option value="<?php echo $cat->id(); ?>"<?php echo $cat->id() == 1 ? ' selected="selected"' : ''; ?>>+ <?php echo $cat->name(); ?>+ </option>+ <?php } ?>+ <option value="nc"><?php echo Minz_Translate::t('new_category'); ?></option>+ </select>++ <span style="display: none;">+ <input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo Minz_Translate::t('new_category'); ?>" />+ </span>+ </div>+ </div>++ <legend><?php echo Minz_Translate::t('http_authentication'); ?></legend>+ <?php $auth = $this->feed->httpAuth(false); ?>+ <div class="form-group">+ <label class="group-name" for="http_user"><?php echo Minz_Translate::t('http_username'); ?></label>+ <div class="group-controls">+ <input type="text" name="http_user" id="http_user" class="extend" value="<?php echo $auth['username']; ?>" autocomplete="off" />+ </div>++ <label class="group-name" for="http_pass"><?php echo Minz_Translate::t('http_password'); ?></label>+ <div class="group-controls">+ <input type="password" name="http_pass" id="http_pass" class="extend" value="<?php echo $auth['password']; ?>" autocomplete="off" />+ </div>++ <div class="group-controls">+ <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('access_protected_feeds'); ?>+ </div>+ </div>++ <div class="form-group form-actions">+ <div class="group-controls">+ <button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>+ <button type="reset" class="btn"><?php echo Minz_Translate::t('cancel'); ?></button>+ </div>+ </div>+ </form>+</div>+<?php } ?>diff --git a/p/scripts/main.js b/p/scripts/main.jsindex 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();