From cf8ee6bd48221e73b515922e75945e9aa763f907 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 14:04:37 +0100 Subject: Rafraîchissement des flux en cache super rapide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012 Les flux non-modifiés et en cache ne coûtent maintenant presque plus rien (304, ou délai de cache SimplePie non expiré), alors qu'avant toutes les entrées étaient rechargées --- app/Controllers/feedController.php | 57 +++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c40b3c400..cf9c993d5 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -191,36 +191,45 @@ class FreshRSS_feed_Controller extends Minz_ActionController { foreach ($feeds as $feed) { try { $url = $feed->url(); + $feedHistory = $feed->keepHistory(); + $feed->load(false); $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order + $hasTransaction = false; - //For this feed, check last n entry GUIDs already in database - $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); - $useDeclaredDate = empty($existingGuids); + if (count($entries) > 0) { + //For this feed, check last n entry GUIDs already in database + $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); + $useDeclaredDate = empty($existingGuids); - $feedHistory = $feed->keepHistory(); - if ($feedHistory == -2) { //default - $feedHistory = $this->view->conf->keep_history_default; - } + if ($feedHistory == -2) { //default + $feedHistory = $this->view->conf->keep_history_default; + } + + $hasTransaction = true; + $feedDAO->beginTransaction(); - // On ne vérifie pas strictement que l'article n'est pas déjà en BDD - // La BDD refusera l'ajout car (id_feed, guid) doit être unique - $feedDAO->beginTransaction (); - foreach ($entries as $entry) { - $eDate = $entry->date (true); - if ((!isset ($existingGuids[$entry->guid ()])) && - (($feedHistory != 0) || ($eDate >= $date_min))) { - $values = $entry->toArray (); - //Use declared date at first import, otherwise use discovery date - $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? - min(time(), $eDate) . uSecString() : - uTimeString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry ($values); + // On ne vérifie pas strictement que l'article n'est pas déjà en BDD + // La BDD refusera l'ajout car (id_feed, guid) doit être unique + foreach ($entries as $entry) { + $eDate = $entry->date (true); + if ((!isset ($existingGuids[$entry->guid ()])) && + (($feedHistory != 0) || ($eDate >= $date_min))) { + $values = $entry->toArray (); + //Use declared date at first import, otherwise use discovery date + $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? + min(time(), $eDate) . uSecString() : + uTimeString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry ($values); + } } } if (($feedHistory >= 0) && (rand(0, 30) === 1)) { + if (!$hasTransaction) { + $feedDAO->beginTransaction(); + } $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feedHistory, count($entries) + 10)); if ($nb > 0) { Minz_Log::record ($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG); @@ -228,8 +237,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // on indique que le flux vient d'être mis à jour en BDD - $feedDAO->updateLastUpdate ($feed->id ()); - $feedDAO->commit (); + $feedDAO->updateLastUpdate ($feed->id (), 0, $hasTransaction); + if ($hasTransaction) { + $feedDAO->commit(); + } $flux_update++; if ($feed->url() !== $url) { //URL has changed (auto-discovery) $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); -- cgit v1.2.3 From a201450b5817af23a57e8c68569c24ed5451b7ef Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 2 Feb 2014 10:02:45 -0500 Subject: Modification des raccourcis de navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modification du raccourci pour naviguer au premier article (Home au lieu de Shift+j) Modification du raccourci pour naviguer au dernier article (End au lieu de Shift+k) Ajout de modificateurs pour utiliser les touches de navigation dans d'autres contextes (Shift pour les flux, Ctrl pour les catégories) Voir issue#256 --- app/Controllers/configureController.php | 2 +- app/Models/Configuration.php | 2 + app/i18n/en.php | 15 ++++-- app/i18n/fr.php | 15 ++++-- app/views/configure/shortcut.phtml | 55 +++++++++++++------ app/views/helpers/javascript_vars.phtml | 2 + p/scripts/main.js | 94 +++++++++++++++++++++++++++++++-- 7 files changed, 154 insertions(+), 31 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 645f9eabf..a5d99c508 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -286,7 +286,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function shortcutAction () { $list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter', - 'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left', + 'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left', 'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right', 's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 2a7fe95aa..2b719c370 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -32,6 +32,8 @@ class FreshRSS_Configuration { 'go_website' => 'space', 'next_entry' => 'j', 'prev_entry' => 'k', + 'first_entry' => 'home', + 'last_entry' => 'end', 'collapse_entry' => 'c', 'load_more' => 'm', 'auto_share' => 's', diff --git a/app/i18n/en.php b/app/i18n/en.php index a2cc461c5..66386f0ed 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -78,6 +78,10 @@ return array ( 'bad_opml_file' => 'Your OPML file is invalid', 'shortcuts_updated' => 'Shortcuts have been updated', 'shortcuts_management' => 'Shortcuts management', + 'shortcuts_navigation' => 'Navigation', + 'shortcuts_navigation_help' => 'With the "Shift" modifier, navigation shortcuts apply on feeds.
With the "Ctrl" modifier, navigation shortcuts apply on categories.', + 'shortcuts_article_action' => 'Article actions', + 'shortcuts_other_action' => 'Other actions', 'feeds_marked_read' => 'Feeds have been marked as read', 'updated' => 'Modifications have been updated', @@ -121,15 +125,16 @@ return array ( 'javascript_for_shortcuts' => 'JavaScript must be enabled in order to use shortcuts', 'javascript_should_be_activated'=> 'JavaScript must be enabled', 'shift_for_all_read' => '+ shift to mark all articles as read', - 'see_on_website' => 'See article on its original website', + 'see_on_website' => 'See on original website', 'next_article' => 'Skip to the next article', - 'shift_for_last' => '+ shift to skip to the last article of page', + 'last_article' => 'Skip to the last article', 'previous_article' => 'Skip to the previous article', - 'shift_for_first' => '+ shift to skip to the first article of page', + 'first_article' => 'Skip to the first article', 'next_page' => 'Skip to the next page', 'previous_page' => 'Skip to the previous page', - 'collapse_article' => 'Collapse current article', - 'auto_share' => 'Share current article', + 'collapse_article' => 'Collapse', + 'auto_share' => 'Share', + 'auto_share_help' => 'If there is only one sharing mode, it is used. Else modes are accessible by their number.', 'file_to_import' => 'File to import', 'import' => 'Import', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 9ab06ba26..edf2fb19f 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -78,6 +78,10 @@ return array ( 'bad_opml_file' => 'Votre fichier OPML n’est pas valide', 'shortcuts_updated' => 'Les raccourcis ont été mis à jour', 'shortcuts_management' => 'Gestion des raccourcis', + 'shortcuts_navigation' => 'Navigation', + 'shortcuts_navigation_help' => 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.
Avec le modificateur "Ctrl", les raccourcis de navigation s’appliquent aux catégories.', + 'shortcuts_article_action' => 'Actions associées à l’article courant', + 'shortcuts_other_action' => 'Autres actions', 'feeds_marked_read' => 'Les flux ont été marqués comme lus', 'updated' => 'Modifications enregistrées', @@ -121,15 +125,16 @@ return array ( 'javascript_for_shortcuts' => 'Le JavaScript doit être activé pour pouvoir profiter des raccourcis', 'javascript_should_be_activated'=> 'Le JavaScript doit être activé', 'shift_for_all_read' => '+ shift pour marquer tous les articles comme lus', - 'see_on_website' => 'Voir l’article sur le site d’origine', + 'see_on_website' => 'Voir sur le site d’origine', 'next_article' => 'Passer à l’article suivant', - 'shift_for_last' => '+ shift pour passer au dernier article de la page', + 'last_article' => 'Passer au dernier article', 'previous_article' => 'Passer à l’article précédent', - 'shift_for_first' => '+ shift pour passer au premier article de la page', + 'first_article' => 'Passer au premier article', 'next_page' => 'Passer à la page suivante', 'previous_page' => 'Passer à la page précédente', - 'collapse_article' => 'Refermer l’article courant', - 'auto_share' => 'Partager l’article courant', + 'collapse_article' => 'Refermer', + 'auto_share' => 'Partager', + 'auto_share_help' => 'Si il n’y a qu’un mode de partage, celui ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.', 'file_to_import' => 'Fichier à importer', 'import' => 'Importer', diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index b0867f711..748a65d17 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -16,55 +16,59 @@ + +
- +
- - +
- +
- +
- +
- +
- +
- - +
+
+ + +
- +
- - + +
- +
- +
- +
- +
@@ -72,6 +76,23 @@
+ +
+ + +
+ +
+ +
+
+ + + +
+ +
+
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 0ecdc1bca..42312bc97 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -19,6 +19,8 @@ echo ',shortcuts={', 'go_website:"', $s['go_website'], '",', 'prev_entry:"', $s['prev_entry'], '",', 'next_entry:"', $s['next_entry'], '",', + 'first_entry:"', $s['first_entry'], '",', + 'last_entry:"', $s['last_entry'], '",', 'collapse_entry:"', $s['collapse_entry'], '",', 'load_more:"', $s['load_more'], '",', 'auto_share:"', $s['auto_share'], '"', diff --git a/p/scripts/main.js b/p/scripts/main.js index ee729b9e5..e9d6c40da 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -247,6 +247,67 @@ function next_entry() { } } +function prev_feed() { + if ($('li.active').length > 0) { + var pf = $('li.active').prev().find('a.feed'); + if (pf.length > 0) { + pf[0].click(); + } + } else { + first_feed(); + } +} + +function next_feed() { + if ($('li.active').length > 0) { + var nf = $('li.active').next().find('a.feed'); + if (nf.length > 0) { + nf[0].click(); + } + } else { + last_feed(); + } +} + +function first_feed() { + $('.feeds.active li').first().find('a')[1].click(); +} + +function last_feed() { + $('.feeds.active li').last().find('a')[1].click(); +} + +function prev_category() { + if ($('div.active').length > 0) { + var pc = $('div.active').parent('li').prev().find('div.stick a.btn'); + if (pc.length > 0) { + pc[0].click(); + return; + } + } else { + first_category(); + } +} + +function next_category() { + if ($('div.active').length > 0) { + var nc = $('div.active').parent('li').next().find('div.stick a.btn'); + if (nc.length > 0) { + nc[0].click(); + } + } else { + last_category(); + } +} + +function first_category() { + $('div.category.stick').first().find('a.btn')[0].click(); +} + +function last_category() { + $('div.category.stick').last().find('a.btn')[0].click(); +} + function collapse_entry() { isCollapsed = !isCollapsed; $(".flux.current").toggleClass("active"); @@ -415,11 +476,11 @@ function init_shortcuts() { }); } - // Touches de navigation + // Touches de navigation pour les articles shortcut.add(shortcuts.prev_entry, prev_entry, { 'disable_in_input': true }); - shortcut.add("shift+" + shortcuts.prev_entry, function () { + shortcut.add(shortcuts.first_entry, function () { var old_active = $(".flux.current"), first = $(".flux:first"); @@ -432,7 +493,7 @@ function init_shortcuts() { shortcut.add(shortcuts.next_entry, next_entry, { 'disable_in_input': true }); - shortcut.add("shift+" + shortcuts.next_entry, function () { + shortcut.add(shortcuts.last_entry, function () { var old_active = $(".flux.current"), last = $(".flux:last"); @@ -442,6 +503,33 @@ function init_shortcuts() { }, { 'disable_in_input': true }); + // Touches de navigation pour les flux + shortcut.add("shift+" + shortcuts.prev_entry, prev_feed, { + 'disable_in_input': true + }); + shortcut.add("shift+" + shortcuts.next_entry, next_feed, { + 'disable_in_input': true + }); + shortcut.add("shift+" + shortcuts.first_entry, first_feed, { + 'disable_in_input': true + }); + shortcut.add("shift+" + shortcuts.last_entry, last_feed, { + 'disable_in_input': true + }); + // Touches de navigation pour les categories + shortcut.add("ctrl+" + shortcuts.prev_entry, prev_category, { + 'disable_in_input': true + }); + shortcut.add("ctrl+" + shortcuts.next_entry, next_category, { + 'disable_in_input': true + }); + shortcut.add("ctrl+" + shortcuts.first_entry, first_category, { + 'disable_in_input': true + }); + shortcut.add("ctrl+" + shortcuts.last_entry, last_category, { + 'disable_in_input': true + }); + shortcut.add(shortcuts.go_website, function () { var url_website = $(".flux.active .link a").attr("href"); -- cgit v1.2.3 From 575d0002cc3839760f0a389eb4af8cd7d23b74c6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 4 Feb 2014 19:07:33 +0100 Subject: Rafraîchissement plus rapide en évitant une requête MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351 --- app/Controllers/feedController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index cf9c993d5..918f007fd 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -14,15 +14,15 @@ class FreshRSS_feed_Controller extends Minz_ActionController { ); } } - - $this->catDAO = new FreshRSS_CategoryDAO (); - $this->catDAO->checkDefault (); } public function addAction () { @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 === false) { @@ -309,6 +309,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { public function massiveImportAction () { @set_time_limit(300); + $this->catDAO = new FreshRSS_CategoryDAO (); + $this->catDAO->checkDefault (); + $entryDAO = new FreshRSS_EntryDAO (); $feedDAO = new FreshRSS_FeedDAO (); -- cgit v1.2.3 From 7fa620cce54f7fd187c477df080ebed33c818b07 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 8 Feb 2014 15:57:19 +0100 Subject: SimplePie Fuite de mémoire PHP 5.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/marienfressinaud/FreshRSS/issues/415 http://simplepie.org/wiki/faq/i_m_getting_memory_leaks (Pas testé) --- app/Controllers/feedController.php | 1 + app/Models/Feed.php | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 918f007fd..056ed96b5 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -246,6 +246,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } $feed->faviconPrepare(); + unset($feed); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index c71fb41ae..e94ae2b3a 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -224,6 +224,9 @@ class FreshRSS_Feed extends Minz_Model { syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url); $this->entries = array(); } + + $feed->__destruct(); //http://simplepie.org/wiki/faq/i_m_getting_memory_leaks + unset($feed); } } } @@ -273,6 +276,7 @@ class FreshRSS_Feed extends Minz_Model { $entry->loadCompleteContent($this->pathEntries()); $entries[] = $entry; + unset($item); } $this->entries = $entries; -- cgit v1.2.3 From 7dc5c9eff211b6f36340c9c40d7460afeb60fc96 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 15:51:46 +0100 Subject: un ->color oublié MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fichier oublié dans le patch précédent https://github.com/marienfressinaud/FreshRSS/issues/295 --- app/Controllers/configureController.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index a5d99c508..c0665d241 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -29,7 +29,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $cat = new FreshRSS_Category ($name); $values = array ( 'name' => $cat->name (), - 'color' => $cat->color () ); $catDAO->updateCategory ($ids[$key], $values); } elseif ($ids[$key] != $defaultId) { @@ -43,7 +42,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), - 'color' => $cat->color () ); if ($catDAO->searchByName ($newCat) == false) { -- cgit v1.2.3 From a6b7243b1634b50bdf9852045e2b31133864b4f8 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 15:58:13 +0100 Subject: un ->color oublié #2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Autre fichier oublié dans le patch précédent :-/ https://github.com/marienfressinaud/FreshRSS/issues/295 --- app/Controllers/feedController.php | 1 - 1 file changed, 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 056ed96b5..ddbb62e24 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -431,7 +431,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), - 'color' => $cat->color () ); $catDAO->addCategory ($values); } -- cgit v1.2.3 From d48f612c437009069593978fe43833fe2c7d74ea Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 21:26:09 +0100 Subject: Bug variable $feed utilisée en dehors de la boucle foreach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/marienfressinaud/FreshRSS/issues/415 https://github.com/marienfressinaud/FreshRSS/issues/420 --- app/Controllers/feedController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index ddbb62e24..55e8f76cf 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -246,12 +246,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } $feed->faviconPrepare(); - unset($feed); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); } + unset($feed); + // On arrête à 10 flux pour ne pas surcharger le serveur // sauf si le paramètre $force est à vrai $i++; @@ -263,6 +264,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $url = array (); if ($flux_update === 1) { // on a mis un seul flux à jour + $feed = reset ($feeds); $notif = array ( 'type' => 'good', 'content' => Minz_Translate::t ('feed_actualized', $feed->name ()) -- cgit v1.2.3 From 0cabd1f50dd7d1cf0941a50139e6fbeed6825b4d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 21:48:10 +0100 Subject: Mutex par flux pour les actualisations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351 Nouvelle constante TMP_PATH comme répertoire pour stocker des fichiers temporaires (si possible en mémoire et non sur disque, tel tmpfs pour /tmp sur certaines distributions Linux) Requiert PHP 5.2.1+ (contre 5.2.0 auparavant) pour le `sys_get_temp_dir()` --- README.md | 2 +- app/Controllers/feedController.php | 5 +++++ app/Models/Feed.php | 18 ++++++++++++++++++ app/actualize_script.php | 19 ------------------- constants.php | 2 ++ p/i/install.php | 5 +++-- 6 files changed, 29 insertions(+), 22 deletions(-) (limited to 'app/Controllers') diff --git a/README.md b/README.md index 247d08799..1ed6d8f82 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Privilégiez pour cela des demandes sur GitHub * Serveur modeste, par exemple sous Linux ou Windows * Fonctionne même sur un Raspberry Pi avec des temps de réponse < 1s (testé sur 150 flux, 22k articles, soit 32Mo de données partiellement compressées) * Serveur Web Apache2 ou Nginx (non testé sur les autres) -* PHP 5.2+ (PHP 5.3.7+ recommandé) +* PHP 5.2.1+ (PHP 5.3.7+ recommandé) * Requis : [PDO_MySQL](http://php.net/pdo-mysql), [cURL](http://php.net/curl), [LibXML](http://php.net/xml), [PCRE](http://php.net/pcre), [ctype](http://php.net/ctype) * Recommandés : [JSON](http://php.net/json), [zlib](http://php.net/zlib), [mbstring](http://php.net/mbstring), [iconv](http://php.net/iconv) * MySQL 5.0.3+ (ou SQLite 3.7.4+ à venir) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 55e8f76cf..61bfc5919 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -189,6 +189,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $flux_update = 0; $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { + if (!$feed->lock()) { + Minz_Log::record('Feed already being actualized: ' . $feed->url(), Minz_Log::NOTICE); + continue; + } try { $url = $feed->url(); $feedHistory = $feed->keepHistory(); @@ -251,6 +255,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->updateLastUpdate ($feed->id (), 1); } + $feed->unlock(); unset($feed); // On arrête à 10 flux pour ne pas surcharger le serveur diff --git a/app/Models/Feed.php b/app/Models/Feed.php index e94ae2b3a..73f9c32fb 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -281,4 +281,22 @@ class FreshRSS_Feed extends Minz_Model { $this->entries = $entries; } + + function lock() { + $lock = TMP_PATH . '/' . md5(Minz_Configuration::salt() . $this->url) . '.freshrss.lock'; + if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { + @unlink($lock); + } + if (($handle = @fopen($lock, 'x')) === false) { + return false; + } + //register_shutdown_function('unlink', $lock); + @fclose($handle); + return true; + } + + function unlock() { + $lock = TMP_PATH . '/' . md5(Minz_Configuration::salt() . $this->url) . '.freshrss.lock'; + @unlink($lock); + } } diff --git a/app/actualize_script.php b/app/actualize_script.php index bef9bd218..8d81e0189 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -1,24 +1,5 @@ -$lock = DATA_PATH . '/actualize.lock.txt'; -if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { - @unlink($lock); -} -if (($handle = @fopen($lock, 'x')) === false) { - syslog(LOG_NOTICE, 'FreshRSS actualize already running?'); - if (defined('STDERR')) { - fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); - } - echo 'FreshRSS actualize already running?', "\n"; - return; -} -register_shutdown_function('unlink', $lock); -//Could use http://php.net/function.pcntl-signal.php to catch interruptions -@fclose($handle); -// - require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader session_cache_limiter(''); diff --git a/constants.php b/constants.php index a7c96f47b..4818f1565 100644 --- a/constants.php +++ b/constants.php @@ -15,3 +15,5 @@ define('FRESHRSS_PATH', dirname(__FILE__)); define('LIB_PATH', FRESHRSS_PATH . '/lib'); define('APP_PATH', FRESHRSS_PATH . '/app'); + +define('TMP_PATH', sys_get_temp_dir()); diff --git a/p/i/install.php b/p/i/install.php index bb49e3fdb..4b0b1d194 100644 --- a/p/i/install.php +++ b/p/i/install.php @@ -548,8 +548,9 @@ function checkStep0 () { 'all' => $language ? 'ok' : 'ko' ); } + function checkStep1 () { - $php = version_compare (PHP_VERSION, '5.2.0') >= 0; + $php = version_compare (PHP_VERSION, '5.2.1') >= 0; $minz = file_exists (LIB_PATH . '/Minz'); $curl = extension_loaded ('curl'); $pdo = extension_loaded ('pdo_mysql'); @@ -721,7 +722,7 @@ function printStep1 () {

-

+

-- cgit v1.2.3 From 06abbd02c2d10934155b2464f73d8ecdb2a68de1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 22:10:55 +0100 Subject: Rafraîchit uniquement les flux qui n'ont pas déjà été rafraîchis récemment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351 --- app/Controllers/javascriptController.php | 2 +- app/Models/FeedDAO.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index b879dcd6d..3d741e298 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -8,7 +8,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { public function actualizeAction () { header('Content-Type: text/javascript; charset=UTF-8'); $feedDAO = new FreshRSS_FeedDAO (); - $this->view->feeds = $feedDAO->listFeeds (); + $this->view->feeds = $feedDAO->listFeedsOrderUpdate(); } public function nbUnreadsPerFeedAction() { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index a2ce0e46f..7ebe68d2b 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -198,8 +198,11 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return self::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC)); } - public function listFeedsOrderUpdate () { - $sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + public function listFeedsOrderUpdate ($cacheDuration = 1500) { + $sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history ' + . 'FROM `' . $this->prefix . 'feed` ' + . 'WHERE lastUpdate < ' . (time() - intval($cacheDuration)) + . ' ORDER BY lastUpdate'; $stm = $this->bd->prepare ($sql); $stm->execute (); -- cgit v1.2.3 From 11c4c733d6971a977748f874b4976044bab7afc0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Feb 2014 23:04:12 +0100 Subject: Bug mise à jour favicons dans le cas de flux invalides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controllers/configureController.php | 2 +- app/Controllers/feedController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index c0665d241..ad8bc546a 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -114,7 +114,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { if ($feedDAO->updateFeed ($id, $values)) { $this->view->flux->_category ($cat); - + $this->view->flux->faviconPrepare(); $notif = array ( 'type' => 'good', 'content' => Minz_Translate::t ('feed_updated') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 61bfc5919..d98c77558 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -249,12 +249,12 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($feed->url() !== $url) { //URL has changed (auto-discovery) $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } - $feed->faviconPrepare(); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); } + $feed->faviconPrepare(); $feed->unlock(); unset($feed); -- cgit v1.2.3 From 178af19fb0e7c13015e991593feea6a5f4aafcc0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 13 Feb 2014 21:01:12 +0100 Subject: Add possibility to open notification in JavaScript + new message Notifications can be opened directly in JavaScript Class .notification is now id #notification New message when there is no feed to refresh See 06abbd02c2d10934155b2464f73d8ecdb2a68de1 (comments) --- app/Controllers/feedController.php | 4 ++-- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/layout/layout.phtml | 11 ++++++--- app/views/javascript/actualize.phtml | 1 + p/scripts/main.js | 46 +++++++++++++++++++++++++++++------- p/themes/Dark/freshrss.css | 15 +++++++----- p/themes/Flat/freshrss.css | 15 +++++++----- p/themes/Origine/freshrss.css | 11 +++++---- 9 files changed, 75 insertions(+), 30 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index d98c77558..264607216 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -283,8 +283,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { // aucun flux n'a été mis à jour, oups $notif = array ( - 'type' => 'bad', - 'content' => Minz_Translate::t ('no_feed_actualized') + 'type' => 'good', + 'content' => Minz_Translate::t ('no_feed_to_refresh') ); } diff --git a/app/i18n/en.php b/app/i18n/en.php index af051673d..369853610 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -248,6 +248,7 @@ return array ( 'rss_feeds_of' => 'RSS feed of %s', 'refresh' => 'Refresh', + 'no_feed_to_refresh' => 'There is no feed to refresh…', 'today' => 'Today', 'yesterday' => 'Yesterday', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 5dc184aa3..275c3b1d8 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -248,6 +248,7 @@ return array ( 'rss_feeds_of' => 'Flux RSS de %s', 'refresh' => 'Actualisation', + 'no_feed_to_refresh' => 'Il n’y a aucun flux à actualiser…', 'today' => 'Aujourd’hui', 'yesterday' => 'Hier', diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index d6a1737ee..1501df3c3 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -36,13 +36,18 @@ notification)) { + $msg = $this->notification['content']; + $status = $this->notification['type']; + invalidateHttpCache(); + } ?> -
- notification['content']; ?> +
+
- diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index 58c3b7c8f..a2b076ea8 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -24,6 +24,7 @@ function updateProgressBar(i) { function updateFeeds() { if (feed_count === 0) { + openNotification("", "good"); return; } initProgressBar(true); diff --git a/p/scripts/main.js b/p/scripts/main.js index e94df2a39..88ef670cd 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -665,23 +665,51 @@ function init_actualize() { } } + +// +var notification = null, + notification_interval = null, + notification_working = false; + +function openNotification(msg, status) { + if (notification_working === true) { + return false; + } + + notification_working = true; + + notification.removeClass(); + notification.addClass(status); + notification.find(".msg").html(msg); + notification.fadeIn(300); + + notification_interval = window.setInterval(closeNotification, 4000); +} + function closeNotification() { - $(".notification").fadeOut(600, function () { - $(".notification").remove(); + notification.fadeOut(600, function() { + notification.removeClass(); + notification.addClass('closed'); + + window.clearInterval(notification_interval); + notification_working = false; }); } function init_notifications() { - var notif = $(".notification"); - if (notif.length > 0) { - window.setInterval(closeNotification, 4000); + notification = $("#notification"); - notif.find("a.close").click(function () { - closeNotification(); - return false; - }); + notification.find("a.close").click(function () { + closeNotification(); + return false; + }); + + if (notification.find(".msg").html().length > 0) { + notification_working = true; + notification_interval = window.setInterval(closeNotification, 4000); } } +// function refreshUnreads() { $.getJSON('./?c=javascript&a=nbUnreadsPerFeed').done(function (data) { diff --git a/p/themes/Dark/freshrss.css b/p/themes/Dark/freshrss.css index e54a0eadd..380dee877 100644 --- a/p/themes/Dark/freshrss.css +++ b/p/themes/Dark/freshrss.css @@ -558,7 +558,7 @@ } /*** NOTIFICATION ***/ -.notification { +#notification { position: absolute; top: 10px; left: 25%; right: 25%; @@ -573,13 +573,16 @@ font-weight: bold; z-index: 10; } - .notification.good { + #notification.closed { + display: none; + } + #notification.good { border:1px solid #f4f899; } - .notification.bad { + #notification.bad { border:1px solid #f4a899; } - .notification a.close { + #notification a.close { display: inline-block; width: 16px; height: 16px; @@ -590,10 +593,10 @@ border-radius: 50px; line-height: 16px; } - .notification.good a.close{ + #notification.good a.close{ border:1px solid #f4f899; } - .notification.bad a.close{ + #notification.bad a.close{ border:1px solid #f4a899; } diff --git a/p/themes/Flat/freshrss.css b/p/themes/Flat/freshrss.css index 19f5967ea..edd67e17c 100644 --- a/p/themes/Flat/freshrss.css +++ b/p/themes/Flat/freshrss.css @@ -561,7 +561,7 @@ body { } /*** NOTIFICATION ***/ -.notification { +#notification { position: absolute; top: 10px; left: 25%; right: 25%; @@ -575,15 +575,18 @@ body { font-weight: bold; z-index: 10; } - .notification.good { + #notification.closed { + display: none; + } + #notification.good { background: #1abc9c; color: #fff; } - .notification.bad { + #notification.bad { background: #e74c3c; color: #fff; } - .notification a.close { + #notification a.close { display: inline-block; width: 16px; height: 16px; @@ -593,10 +596,10 @@ body { border-radius: 3px; line-height: 16px; } - .notification.good a.close { + #notification.good a.close { background: #1abc9c; } - .notification.bad a.close { + #notification.bad a.close { background: #e74c3c; } diff --git a/p/themes/Origine/freshrss.css b/p/themes/Origine/freshrss.css index 85a23140c..80fac05cd 100644 --- a/p/themes/Origine/freshrss.css +++ b/p/themes/Origine/freshrss.css @@ -569,7 +569,7 @@ } /*** NOTIFICATION ***/ -.notification { +#notification { position: absolute; top: 10px; left: 25%; right: 25%; @@ -584,13 +584,16 @@ font-weight: bold; z-index: 10; } - .notification.good { + #notification.closed { + display: none; + } + #notification.good { background: #f4f899; } - .notification.bad { + #notification.bad { background: #f4a899; } - .notification a.close { + #notification a.close { display: inline-block; width: 16px; height: 16px; -- cgit v1.2.3 From 4dd673157b05fea5fe3643f16e22d01bbf005fe9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 13 Feb 2014 21:45:25 +0100 Subject: Add possibility to anonymous to refresh feeds Obviously, it's optional! (and deactivate by default) Need some more tests? See #351 --- app/Controllers/feedController.php | 4 +++- app/Controllers/usersController.php | 7 ++++++- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/layout/nav_menu.phtml | 4 +++- app/views/configure/users.phtml | 10 ++++++++++ lib/Minz/Configuration.php | 19 ++++++++++++++++++- 7 files changed, 42 insertions(+), 4 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 264607216..7114fc196 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -7,7 +7,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token == $token_param); $action = Minz_Request::actionName (); - if (!($token_is_ok && $action === 'actualize')) { + if (!(($token_is_ok || Minz_Configuration::allowAnonymousRefresh()) && + $action === 'actualize') + ) { Minz_Error::error ( 403, array ('error' => array (Minz_Translate::t ('access_denied'))) diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php index 8314b75fc..bb4f34c5e 100644 --- a/app/Controllers/usersController.php +++ b/app/Controllers/usersController.php @@ -54,11 +54,16 @@ class FreshRSS_users_Controller extends Minz_ActionController { $anon = Minz_Request::param('anon_access', false); $anon = ((bool)$anon) && ($anon !== 'no'); + $anon_refresh = Minz_Request::param('anon_refresh', false); + $anon_refresh = ((bool)$anon_refresh) && ($anon_refresh !== 'no'); $auth_type = Minz_Request::param('auth_type', 'none'); if ($anon != Minz_Configuration::allowAnonymous() || - $auth_type != Minz_Configuration::authType()) { + $auth_type != Minz_Configuration::authType() || + $anon_refresh != Minz_Configuration::allowAnonymousRefresh()) { + Minz_Configuration::_authType($auth_type); Minz_Configuration::_allowAnonymous($anon); + Minz_Configuration::_allowAnonymousRefresh($anon_refresh); $ok &= Minz_Configuration::writeFile(); } } diff --git a/app/i18n/en.php b/app/i18n/en.php index 369853610..fd51eb1ca 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -175,6 +175,7 @@ return array ( 'password_form' => 'Password
(for the Web-form login method)', 'persona_connection_email' => 'Login mail address
(for Mozilla Persona)', 'allow_anonymous' => 'Allow anonymous reading of the articles of the default user (%s)', + 'allow_anonymous_refresh' => 'Allow anonymous refresh of the articles', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output of the default user without authentication.
%s?output=rss&token=%s', 'login_configuration' => 'Login', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 275c3b1d8..17e26f493 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -175,6 +175,7 @@ return array ( 'default_user' => 'Nom de l’utilisateur par défaut (16 caractères alphanumériques maximum)', 'persona_connection_email' => 'Adresse courriel de connexion
(pour Mozilla Persona)', 'allow_anonymous' => 'Autoriser la lecture anonyme des articles de l’utilisateur par défaut (%s)', + 'allow_anonymous_refresh' => 'Autoriser le rafraîchissement anonyme des flux', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS de l’utilisateur par défaut sans besoin de s’authentifier.
%s?output=rss&token=%s', 'login_configuration' => 'Identification', diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index c807e6dd5..98064a6f7 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -6,9 +6,11 @@ - loginOk) { ?> + loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?> + + loginOk) { ?>
+
+
+ +
+
+
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 572b9984d..b3de9e39e 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -52,6 +52,7 @@ class Minz_Configuration { private static $delay_cache = 3600; private static $default_user = ''; private static $allow_anonymous = false; + private static $allow_anonymous_refresh = false; private static $auth_type = 'none'; private static $db = array ( @@ -118,6 +119,9 @@ class Minz_Configuration { public static function allowAnonymous() { return self::$allow_anonymous; } + public static function allowAnonymousRefresh() { + return self::$allow_anonymous_refresh; + } public static function authType() { return self::$auth_type; } @@ -131,6 +135,9 @@ class Minz_Configuration { public static function _allowAnonymous($allow = false) { self::$allow_anonymous = ((bool)$allow) && self::canLogIn(); } + public static function _allowAnonymousRefresh($allow = false) { + self::$allow_anonymous_refresh = ((bool)$allow) && self::allowAnonymous(); + } public static function _authType($value) { $value = strtolower($value); switch ($value) { @@ -170,6 +177,7 @@ class Minz_Configuration { 'title' => self::$title, 'default_user' => self::$default_user, 'allow_anonymous' => self::$allow_anonymous, + 'allow_anonymous_refresh' => self::$allow_anonymous_refresh, 'auth_type' => self::$auth_type, ), 'db' => self::$db, @@ -276,7 +284,16 @@ class Minz_Configuration { self::_authType($general['auth_type']); } if (isset ($general['allow_anonymous'])) { - self::$allow_anonymous = ((bool)($general['allow_anonymous'])) && ($general['allow_anonymous'] !== 'no'); + self::$allow_anonymous = ( + ((bool)($general['allow_anonymous'])) && + ($general['allow_anonymous'] !== 'no') + ); + } + if (isset ($general['allow_anonymous_refresh'])) { + self::$allow_anonymous_refresh = ( + ((bool)($general['allow_anonymous_refresh'])) && + ($general['allow_anonymous_refresh'] !== 'no') + ); } // Base de données -- cgit v1.2.3 From fb7bc50673f226070c5399bd6bbf07b91eeda01e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 10:44:37 +0100 Subject: Fix bug token The token should appear in RSS feed url when anonymous are not allowed --- app/Controllers/indexController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 986a322a1..af08edb46 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -5,18 +5,15 @@ class FreshRSS_index_Controller extends Minz_ActionController { public function indexAction () { $output = Minz_Request::param ('output'); - $token = ''; + $token = $this->view->conf->token; // check if user is logged in - if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) - { - $token = $this->view->conf->token; + if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) { $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token === $token_param); if (!($output === 'rss' && $token_is_ok)) { return; } - $params['token'] = $token; } // construction of RSS url of this feed @@ -25,6 +22,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { if (isset ($params['search'])) { $params['search'] = urlencode ($params['search']); } + if (!Minz_Configuration::allowAnonymous()) { + $params['token'] = $token; + } $this->view->rss_url = array ( 'c' => 'index', 'a' => 'index', -- cgit v1.2.3 From a34941f41875bcc9d260c8dfcf9d44a00f835bc9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 11:43:07 +0100 Subject: Improve code redirection for indexController - add comments - forward request is done in the controller (no Minz_Request::forward() in the view, please) - "soft" forward to the login form (no need of 302) - show a 403 page (no authenticated) for rss output when token is wrong --- app/Controllers/feedController.php | 5 ++++- app/Controllers/indexController.php | 11 ++++++++++- app/views/index/index.phtml | 19 +++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 7114fc196..c718fcd5c 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -3,7 +3,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { public function firstAction () { if (!$this->view->loginOk) { - $token = $this->view->conf->token; //TODO: check the token logic again, and if it is still needed + // Token is useful in the case that anonymous refresh is forbidden + // and CRON task cannot be used with php command so the user can + // set a CRON task to refresh his feeds by using token inside url + $token = $this->view->conf->token; $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token == $token_param); $action = Minz_Request::actionName (); diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index af08edb46..a680c914a 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -11,7 +11,16 @@ class FreshRSS_index_Controller extends Minz_ActionController { if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) { $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token === $token_param); - if (!($output === 'rss' && $token_is_ok)) { + if ($output === 'rss' && !$token_is_ok) { + Minz_Error::error ( + 403, + array ('error' => array (Minz_Translate::t ('access_denied'))) + ); + return; + } elseif ($output !== 'rss') { + // "hard" redirection is not required, just ask dispatcher to + // forward to the login form without 302 redirection + Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin')); return; } } diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 1810a95b3..78271291e 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -3,9 +3,7 @@ $output = Minz_Request::param ('output', 'normal'); if ($this->loginOk || Minz_Configuration::allowAnonymous()) { - if ($output === 'normal') { - $this->renderHelper ('view/normal_view'); - } elseif ($output === 'rss') { + if ($output === 'rss') { $this->renderHelper ('view/rss_view'); } elseif ($output === 'reader') { $this->renderHelper ('view/reader_view'); @@ -17,16 +15,9 @@ if ($this->loginOk || Minz_Configuration::allowAnonymous()) { $this->renderHelper ('view/normal_view'); } } elseif ($output === 'rss') { - // TODO: verification of token and redirection must be done in the - // controller, not in the view - $token = $this->conf->token; - $token_param = Minz_Request::param ('token', ''); - $token_is_ok = ($token != '' && $token == $token_param); - if ($token_is_ok) { - $this->renderHelper ('view/rss_view'); - } else { - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin'), true); - } + // token has already been checked in the controller so we can show the view + $this->renderHelper ('view/rss_view'); } else { - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin'), true); + // Normally, it should not happen, but log it anyway + Minz_Log::record ('Something is wrong in ' . __FILE__ . ' line ' . __LINE__, Minz_Log::ERROR); } -- cgit v1.2.3 From cddec2d76f2c5d25d3008d5e2a60fddad6028a5d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 12:25:06 +0100 Subject: Improve login page - if user cannot log in, a 403 error is showed (and it is done in controller) - 403 error message has been changed to match with the error - add blank spaces on persona login page --- app/Controllers/indexController.php | 5 ++++ app/i18n/en.php | 3 +- app/i18n/fr.php | 3 +- app/views/error/index.phtml | 10 ++++++- app/views/index/formLogin.phtml | 56 ++++++++++++++++++------------------- p/themes/Dark/global.css | 30 ++++++++++---------- p/themes/Flat/global.css | 30 ++++++++++---------- p/themes/Origine/global.css | 30 ++++++++++---------- 8 files changed, 93 insertions(+), 74 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index a680c914a..38f4c0e7c 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -351,6 +351,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { } $this->view->_useLayout(false); Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); + } elseif (!Minz_Configuration::canLogIn()) { + Minz_Error::error ( + 403, + array ('error' => array (Minz_Translate::t ('access_denied'))) + ); } invalidateHttpCache(); } diff --git a/app/i18n/en.php b/app/i18n/en.php index fd51eb1ca..790e853f5 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Login', + 'login_with_persona' => 'Login with Persona', 'logout' => 'Logout', 'search' => 'Search words or #tags', 'search_short' => 'Search', @@ -276,7 +277,7 @@ return array ( 'logs_empty' => 'Log file is empty', 'clear_logs' => 'Clear the logs', - 'forbidden_access' => 'Access forbidden! (%s)', + 'forbidden_access' => 'Access is forbidden!', 'login_required' => 'Login required:', 'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 17e26f493..572bc1628 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Connexion', + 'login_with_persona' => 'Connexion avec Persona', 'logout' => 'Déconnexion', 'search' => 'Rechercher des mots ou des #tags', 'search_short' => 'Rechercher', @@ -276,7 +277,7 @@ return array ( 'logs_empty' => 'Les logs sont vides', 'clear_logs' => 'Effacer les logs', - 'forbidden_access' => 'Accès interdit ! (%s)', + 'forbidden_access' => 'L’accès vous est interdit !', 'login_required' => 'Accès protégé par mot de passe :', 'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !', diff --git a/app/views/error/index.phtml b/app/views/error/index.phtml index 36fcb56f9..6a09c3aa2 100644 --- a/app/views/error/index.phtml +++ b/app/views/error/index.phtml @@ -3,7 +3,15 @@

code; ?>

-
+

diff --git a/app/views/index/formLogin.phtml b/app/views/index/formLogin.phtml index e4560c1a0..cc925ea59 100644 --- a/app/views/index/formLogin.phtml +++ b/app/views/index/formLogin.phtml @@ -1,34 +1,32 @@
-

-

- - -

- - -
- -

- -

-
+
+ + +
+
+ + +
+ +
+
+ +
+

FreshRSS

-

+ case 'persona': + ?>

+ + +

-

+

diff --git a/p/themes/Dark/global.css b/p/themes/Dark/global.css index a6acd740a..e296f2188 100644 --- a/p/themes/Dark/global.css +++ b/p/themes/Dark/global.css @@ -512,18 +512,20 @@ input, select, textarea { } /* Prompt (centré) */ -.prompt > h1, .prompt > p { - text-align:center; -} -.prompt > form { - margin:1em auto 2.5em auto; - width:10em; -} -.prompt .btn { - display:block; - margin:.5em auto; -} -.prompt input { - margin:.4em auto 1.1em auto; - width:99%; +.prompt { + text-align: center; } + .prompt label { + text-align: left; + } + .prompt form { + margin: 1em auto 2.5em auto; + width: 10em; + } + .prompt input { + margin: .4em auto 1.1em auto; + width: 100%; + } + .prompt p { + margin: 20px 0; + } diff --git a/p/themes/Flat/global.css b/p/themes/Flat/global.css index 75c328fcb..4044dd781 100644 --- a/p/themes/Flat/global.css +++ b/p/themes/Flat/global.css @@ -515,18 +515,20 @@ input, select, textarea { } /* Prompt (centré) */ -.prompt > h1, .prompt > p { - text-align:center; -} -.prompt > form { - margin:1em auto 2.5em auto; - width:10em; -} -.prompt .btn { - display:block; - margin:.5em auto; -} -.prompt input { - margin:.4em auto 1.1em auto; - width:99%; +.prompt { + text-align: center; } + .prompt label { + text-align: left; + } + .prompt form { + margin: 1em auto 2.5em auto; + width: 10em; + } + .prompt input { + margin: .4em auto 1.1em auto; + width: 100%; + } + .prompt p { + margin: 20px 0; + } diff --git a/p/themes/Origine/global.css b/p/themes/Origine/global.css index c1892d042..5792c9e4d 100644 --- a/p/themes/Origine/global.css +++ b/p/themes/Origine/global.css @@ -528,18 +528,20 @@ input, select, textarea { } /* Prompt (centré) */ -.prompt > h1, .prompt > p { - text-align:center; -} -.prompt > form { - margin:1em auto 2.5em auto; - width:10em; -} -.prompt .btn { - display:block; - margin:.5em auto; -} -.prompt input { - margin:.4em auto 1.1em auto; - width:99%; +.prompt { + text-align: center; } + .prompt label { + text-align: left; + } + .prompt form { + margin: 1em auto 2.5em auto; + width: 10em; + } + .prompt input { + margin: .4em auto 1.1em auto; + width: 100%; + } + .prompt p { + margin: 20px 0; + } -- cgit v1.2.3