From 6eb7828b628faecc314c7acfee0860fb24635737 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 1 Feb 2014 11:40:20 -0500 Subject: Modification du partage au clavier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le raccourci de partage a été modifié pour partager automatiquement un article s'il n'existe qu'un mode de partage. Les modes de partage sont rendus accessibles au clavier en utilisant les chiffres de 1 à 9. Quand un article est partagé, la liste des modes est cachée automatiquement. --- p/scripts/main.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index f0d2bbf7b..ee729b9e5 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -252,10 +252,27 @@ function collapse_entry() { $(".flux.current").toggleClass("active"); } -function auto_share() { +function auto_share(key) { var share = $(".flux.current.active").find('.dropdown-target[id^="dropdown-share"]'); - if (share.length) { + var shares = share.siblings('.dropdown-menu').find('.item a'); + if (typeof key === "undefined") { + if (!share.length) { + return; + } + // Display the share div window.location.hash = share.attr('id'); + // Force the key value if there is only one action, so we can trigger it automatically + if (shares.length === 1) { + key = 1; + } else { + return; + } + } + // Trigger selected share action and hide the share div + key = parseInt(key); + if (key <= shares.length) { + shares[key - 1].click(); + share.siblings('.dropdown-menu').find('.dropdown-close a')[0].click(); } } @@ -390,6 +407,13 @@ function init_shortcuts() { }, { 'disable_in_input': true }); + for(var i = 1; i < 10; i++){ + shortcut.add(i.toString(), function (e) { + auto_share(String.fromCharCode(e.keyCode)); + }, { + 'disable_in_input': true + }); + } // Touches de navigation shortcut.add(shortcuts.prev_entry, prev_entry, { -- 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 'p/scripts') 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 2c6d010dbae050d8ba140e69ecff3376b36d039f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 3 Feb 2014 08:48:16 +0100 Subject: Ne pas boucler à la fin de la navigation dans les articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/407 Alternative à https://github.com/marienfressinaud/FreshRSS/pull/409 qui conserve le fait que l'article se ferme, et plus simple. --- p/scripts/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index f0d2bbf7b..48386b1d6 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -172,12 +172,14 @@ function mark_favorite(active) { } function toggleContent(new_active, old_active) { - old_active.removeClass("active").removeClass("current"); + old_active.removeClass("active"); if (new_active.length === 0) { return; } + old_active.removeClass("current"); + if (does_lazyload) { new_active.find('img[data-original], iframe[data-original]').each(function () { this.setAttribute('src', this.getAttribute('data-original')); -- cgit v1.2.3 From 12247b2ce3e49382524ef67feec0ba7622a47066 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 3 Feb 2014 19:53:43 +0100 Subject: Ne pas déplier l'article lors du clic sur l'icône lien externe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige http://marienfressinaud.fr/index.php?article141/freshrss-0-7-ca-casse-et-ca-passe#c1391357481-1 --- p/scripts/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 48386b1d6..2345bf531 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -443,7 +443,7 @@ function init_shortcuts() { function init_stream(divStream) { divStream.on('click', '.flux_header', function (e) { //flux_header_toggle - if ($(e.target).closest('.item.website > a').length > 0) { + if ($(e.target).closest('.item.website, .item.link').length > 0) { return; } var old_active = $(".flux.current"), @@ -470,7 +470,7 @@ function init_stream(divStream) { return false; }); - divStream.on('click', '.item.title>a', function (e) { + divStream.on('click', '.item.title > a', function (e) { if (e.ctrlKey) { return true; //Allow default control-click behaviour such as open in backround-tab } @@ -483,7 +483,7 @@ function init_stream(divStream) { }); if (auto_mark_site) { - divStream.on('click', '.flux .link a', function () { + divStream.on('click', '.flux .link > a', function () { mark_read($(this).parent().parent().parent(), true); }); } -- cgit v1.2.3 From 797dd21282214c2da6c422d7192dfe8c1de2c824 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 4 Feb 2014 17:47:01 +0100 Subject: Si nécessaire, défile lors du raccourci pour partager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige http://marienfressinaud.fr/index.php?article141/freshrss-0-7-ca-casse-et-ca-passe#c1391357481-1 --- p/scripts/main.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 2345bf531..c4c0db21a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -20,6 +20,16 @@ function redirect(url, new_tab) { } } +function needsScroll($elem) { + var $win = $(window), + winTop = $win.scrollTop(), + winHeight = $win.height(), + winBottom = winTop + winHeight, + elemTop = $elem.offset().top, + elemBottom = elemTop + $elem.outerHeight(); + return (elemTop < winTop || elemBottom > winBottom) ? elemTop - (winHeight / 2) : 0; +} + function str2int(str) { if (str == '') { return 0; @@ -255,9 +265,13 @@ function collapse_entry() { } function auto_share() { - var share = $(".flux.current.active").find('.dropdown-target[id^="dropdown-share"]'); - if (share.length) { - window.location.hash = share.attr('id'); + var $share = $(".flux.current").find('.dropdown-target[id^="dropdown-share"]'); + if ($share.length) { + window.location.hash = $share.attr('id'); + var scroll = needsScroll($share.closest('.bottom')); + if (scroll != 0) { + $('html,body').scrollTop(scroll); + } } } -- cgit v1.2.3 From beceedd87819fd67f3cd81e65ba981c202ba2cd4 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 4 Feb 2014 23:09:55 -0500 Subject: Corrige l'ouverture d'un lien MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lors de l'ouverture d'un lien au clavier quand les articles sont fermés, le lien ne s'ouvre pas. Avec la correction, le lien s'ouvre correctement. --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 5a4fb5fb8..53a365076 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -548,7 +548,7 @@ function init_shortcuts() { }); shortcut.add(shortcuts.go_website, function () { - var url_website = $(".flux.active .link a").attr("href"); + var url_website = $(".flux.current .link a").attr("href"); if (auto_mark_site) { $(".flux.current").each(function () { -- cgit v1.2.3 From 7d9a813ed3465ef7175a05355e1ccaef878ab667 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 6 Feb 2014 18:48:49 +0100 Subject: Petite simplification mise à jour JavaScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/marienfressinaud/FreshRSS/pull/414 --- app/views/javascript/actualize.phtml | 19 ++++++++++--------- p/scripts/main.js | 6 ++---- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'p/scripts') diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index 272d1b419..58c3b7c8f 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -1,10 +1,11 @@ "use strict"; -var feeds = []; -feeds as $feed) { ?> -feeds.push(" 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); - -var feed_count = feeds.length; -var feed_processed = 0; +var feeds = [feeds as $feed) { + echo "'", Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'), "',\n"; + } + ?>], + feed_processed = 0, + feed_count = feeds.length; function initProgressBar(init) { if (init) { @@ -33,10 +34,10 @@ function updateFeeds() { } function updateFeed() { - if (feeds.length === 0) { + var feed = feeds.pop(); + if (feed == undefined) { return; } - var feed = feeds.pop(); $.ajax({ type: 'POST', url: feed, @@ -50,4 +51,4 @@ function updateFeed() { updateFeed(); } }); -} \ No newline at end of file +} diff --git a/p/scripts/main.js b/p/scripts/main.js index 53a365076..8cda62d26 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -648,10 +648,8 @@ function init_actualize() { return false; }); - if(auto_actualize_feeds) { - $.getScript('./?c=javascript&a=actualize').done(function () { - updateFeeds(); - }); + if (auto_actualize_feeds) { + $("#actualize").click(); } } -- cgit v1.2.3 From c33b13809ef4e1941d3655479db8c5fcf5731013 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 13 Feb 2014 19:51:38 +0100 Subject: Add a "locker" to mark_read action In order to prevent multiple requests while another one is still pending. It is based on a list of pending actions (in fact, in a list of pending feeds) Fix #423 --- p/scripts/main.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 8cda62d26..e94df2a39 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1,6 +1,7 @@ "use strict"; var $stream = null, - isCollapsed = true; + isCollapsed = true, + pending_feed = []; function is_normal_mode() { return $stream.hasClass('normal'); @@ -107,7 +108,8 @@ function incUnreadsFeed(article, feed_id, nb) { } function mark_read(active, only_not_read) { - if (active.length === 0 || (only_not_read === true && !active.hasClass("not_read"))) { + if (active.length === 0 || + (only_not_read === true && !active.hasClass("not_read"))) { return false; } @@ -116,6 +118,16 @@ function mark_read(active, only_not_read) { return false; } + var feed_url = active.find(".website>a").attr("href"), + feed_id = feed_url.substr(feed_url.lastIndexOf('f_')), + index_pending = pending_feed.indexOf(feed_id); + + if (index_pending !== -1) { + return false; + } + + pending_feed.push(feed_id); + $.ajax({ type: 'POST', url: url, @@ -132,9 +144,9 @@ function mark_read(active, only_not_read) { } $r.find('.icon').replaceWith(data.icon); - var feed_url = active.find(".website>a").attr("href"), - feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); incUnreadsFeed(active, feed_id, inc); + + pending_feed.splice(index_pending, 1); }); } -- 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 'p/scripts') 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 cabac73b552a8bec4ca284dd40fb27872d6694c6 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 14:03:17 +0100 Subject: Fix bug auto_actualize When auto_actualize was true and there was no feed to refresh, a message was always showed. Now we check size of array "feeds" and if size is zero, we don't perform auto_actualize action --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 88ef670cd..44517eb6c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -660,7 +660,7 @@ function init_actualize() { return false; }); - if (auto_actualize_feeds) { + if (auto_actualize_feeds && feed_count > 0) { $("#actualize").click(); } } -- cgit v1.2.3 From 69ce70be35c511921cf0bfe05f21c3ba44c0f17a Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 14:57:18 +0100 Subject: Add locker to mark_favorite action Similar to c33b13809ef4e1941d3655479db8c5fcf5731013 See #423 --- p/scripts/main.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 44517eb6c..39b780bd7 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1,7 +1,6 @@ "use strict"; var $stream = null, - isCollapsed = true, - pending_feed = []; + isCollapsed = true; function is_normal_mode() { return $stream.hasClass('normal'); @@ -107,6 +106,7 @@ function incUnreadsFeed(article, feed_id, nb) { return isCurrentView; } +var pending_feeds = []; function mark_read(active, only_not_read) { if (active.length === 0 || (only_not_read === true && !active.hasClass("not_read"))) { @@ -120,13 +120,13 @@ function mark_read(active, only_not_read) { var feed_url = active.find(".website>a").attr("href"), feed_id = feed_url.substr(feed_url.lastIndexOf('f_')), - index_pending = pending_feed.indexOf(feed_id); + index_pending = pending_feeds.indexOf(feed_id); if (index_pending !== -1) { return false; } - pending_feed.push(feed_id); + pending_feeds.push(feed_id); $.ajax({ type: 'POST', @@ -146,7 +146,7 @@ function mark_read(active, only_not_read) { incUnreadsFeed(active, feed_id, inc); - pending_feed.splice(index_pending, 1); + pending_feeds.splice(index_pending, 1); }); } @@ -160,6 +160,16 @@ function mark_favorite(active) { return false; } + var feed_url = active.find(".website>a").attr("href"), + feed_id = feed_url.substr(feed_url.lastIndexOf('f_')), + index_pending = pending_feeds.indexOf(feed_id); + + if (index_pending !== -1) { + return false; + } + + pending_feeds.push(feed_id); + $.ajax({ type: 'POST', url: url, @@ -190,6 +200,8 @@ function mark_favorite(active) { elem.setAttribute('data-unread', numberFormat(feed_unreads + inc)); } } + + pending_feeds.splice(index_pending, 1); }); } -- cgit v1.2.3 From 0a5a7d780722f0dc9e12a7cad43a3b74ea812257 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 15:19:03 +0100 Subject: Fix bug auto_actualize feed_count was not known in main.js See cabac73b552a8bec4ca284dd40fb27872d6694c6 --- p/scripts/main.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 39b780bd7..ba1f9cf9d 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -665,14 +665,23 @@ function init_nav_entries() { } function init_actualize() { + var auto = false; + $("#actualize").click(function () { $.getScript('./?c=javascript&a=actualize').done(function () { + if (auto && feed_count < 1) { + return; + } + updateFeeds(); + + auto = false; }); return false; }); - if (auto_actualize_feeds && feed_count > 0) { + if (auto_actualize_feeds) { + auto = true; $("#actualize").click(); } } -- cgit v1.2.3 From 7fd04c046a3c70b9ec52a04dd9b397f39b26c487 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 15:29:00 +0100 Subject: Oops, fix bug auto_actualize_feeds See 0a5a7d780722f0dc9e12a7cad43a3b74ea812257 --- p/scripts/main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index ba1f9cf9d..92f98ab28 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -670,12 +670,11 @@ function init_actualize() { $("#actualize").click(function () { $.getScript('./?c=javascript&a=actualize').done(function () { if (auto && feed_count < 1) { + auto = false; return; } updateFeeds(); - - auto = false; }); return false; }); -- cgit v1.2.3 From 9e23ced0bf50c8af96d39dd68068e0564d593a92 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Feb 2014 20:24:07 +0100 Subject: Improve behaviour category / feed shortcuts - code improved - possibility to move directly from "all" category - when there is no selected feed and we want the "next one", first feed is selected (last before). Same for categories See #256 --- app/layout/aside_flux.phtml | 4 +-- p/scripts/main.js | 69 +++++++++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 27 deletions(-) (limited to 'p/scripts') diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 8454b4459..817dae676 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -20,7 +20,7 @@ } ?>
  • -
  • -
    +
    nb_favorites['all'])); ?> diff --git a/p/scripts/main.js b/p/scripts/main.js index 92f98ab28..130407f2c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -284,64 +284,83 @@ 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(); + var active_feed = $("#aside_flux .feeds li.active"); + if (active_feed.length > 0) { + var prev_feed = active_feed.prev().find('a.feed'); + if (prev_feed.length > 0) { + prev_feed[0].click(); } } else { - first_feed(); + last_feed(); } } function next_feed() { - if ($('li.active').length > 0) { - var nf = $('li.active').next().find('a.feed'); - if (nf.length > 0) { - nf[0].click(); + var active_feed = $("#aside_flux .feeds li.active"); + if (active_feed.length > 0) { + var next_feed = active_feed.next().find('a.feed'); + if (next_feed.length > 0) { + next_feed[0].click(); } } else { - last_feed(); + first_feed(); } } function first_feed() { - $('.feeds.active li').first().find('a')[1].click(); + var feed = $("#aside_flux .feeds.active li:first"); + if (feed.length > 0) { + feed.find('a')[1].click(); + } } function last_feed() { - $('.feeds.active li').last().find('a')[1].click(); + var feed = $("#aside_flux .feeds.active li:last"); + if (feed.length > 0) { + feed.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; + var active_cat = $("#aside_flux .category.active"); + + if (active_cat.length > 0) { + var prev_cat = active_cat.parent('li').prev().find('.category a.btn'); + if (prev_cat.length > 0) { + prev_cat[0].click(); } } else { - first_category(); + last_category(); } + return; } 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(); + var active_cat = $("#aside_flux .category.active"); + + if (active_cat.length > 0) { + var next_cat = active_cat.parent('li').next().find('.category a.btn'); + if (next_cat.length > 0) { + next_cat[0].click(); } } else { - last_category(); + first_category(); } + return; } function first_category() { - $('div.category.stick').first().find('a.btn')[0].click(); + var cat = $("#aside_flux .category:first"); + if (cat.length > 0) { + cat.find('a.btn')[0].click(); + } } function last_category() { - $('div.category.stick').last().find('a.btn')[0].click(); + var cat = $("#aside_flux .category:last"); + if (cat.length > 0) { + cat.find('a.btn')[0].click(); + } } function collapse_entry() { -- cgit v1.2.3 From 7ed7722c274e38c97511481fdd68138e463cfbc4 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 16 Feb 2014 11:31:06 -0500 Subject: Change category modifier for shortcuts The modifier to change the focus of categories was Ctrl. It was changed to avoid interference with browser shortcuts. See #256 --- app/i18n/en.php | 2 +- app/i18n/fr.php | 2 +- p/scripts/main.js | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'p/scripts') diff --git a/app/i18n/en.php b/app/i18n/en.php index 790e853f5..932513588 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -80,7 +80,7 @@ return array ( '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_navigation_help' => 'With the "Shift" modifier, navigation shortcuts apply on feeds.
    With the "Alt" 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', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 572bc1628..ab7843d12 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -80,7 +80,7 @@ return array ( '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_navigation_help' => 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.
    Avec le modificateur "Alt", 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', diff --git a/p/scripts/main.js b/p/scripts/main.js index 130407f2c..bd8eb0b2b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -322,10 +322,10 @@ function last_feed() { } function prev_category() { - var active_cat = $("#aside_flux .category.active"); + var active_cat = $("#aside_flux .category.stick.active"); if (active_cat.length > 0) { - var prev_cat = active_cat.parent('li').prev().find('.category a.btn'); + var prev_cat = active_cat.parent('li').prev().find('.category.stick a.btn'); if (prev_cat.length > 0) { prev_cat[0].click(); } @@ -336,10 +336,10 @@ function prev_category() { } function next_category() { - var active_cat = $("#aside_flux .category.active"); + var active_cat = $("#aside_flux .category.stick.active"); if (active_cat.length > 0) { - var next_cat = active_cat.parent('li').next().find('.category a.btn'); + var next_cat = active_cat.parent('li').next().find('.category.stick a.btn'); if (next_cat.length > 0) { next_cat[0].click(); } @@ -350,14 +350,14 @@ function next_category() { } function first_category() { - var cat = $("#aside_flux .category:first"); + var cat = $("#aside_flux .category.stick:first"); if (cat.length > 0) { cat.find('a.btn')[0].click(); } } function last_category() { - var cat = $("#aside_flux .category:last"); + var cat = $("#aside_flux .category.stick:last"); if (cat.length > 0) { cat.find('a.btn')[0].click(); } @@ -577,16 +577,16 @@ function init_shortcuts() { 'disable_in_input': true }); // Touches de navigation pour les categories - shortcut.add("ctrl+" + shortcuts.prev_entry, prev_category, { + shortcut.add("alt+" + shortcuts.prev_entry, prev_category, { 'disable_in_input': true }); - shortcut.add("ctrl+" + shortcuts.next_entry, next_category, { + shortcut.add("alt+" + shortcuts.next_entry, next_category, { 'disable_in_input': true }); - shortcut.add("ctrl+" + shortcuts.first_entry, first_category, { + shortcut.add("alt+" + shortcuts.first_entry, first_category, { 'disable_in_input': true }); - shortcut.add("ctrl+" + shortcuts.last_entry, last_category, { + shortcut.add("alt+" + shortcuts.last_entry, last_category, { 'disable_in_input': true }); -- cgit v1.2.3 From 166f3a20c7ae42d930c060371529f262bcbd2ebb Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 16 Feb 2014 13:22:43 -0500 Subject: Change syntax to have less tests --- p/scripts/main.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index bd8eb0b2b..34042c945 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -286,10 +286,7 @@ function next_entry() { function prev_feed() { var active_feed = $("#aside_flux .feeds li.active"); if (active_feed.length > 0) { - var prev_feed = active_feed.prev().find('a.feed'); - if (prev_feed.length > 0) { - prev_feed[0].click(); - } + active_feed.prev().find('a.feed').each(function(){this.click();}); } else { last_feed(); } @@ -298,10 +295,7 @@ function prev_feed() { function next_feed() { var active_feed = $("#aside_flux .feeds li.active"); if (active_feed.length > 0) { - var next_feed = active_feed.next().find('a.feed'); - if (next_feed.length > 0) { - next_feed[0].click(); - } + active_feed.next().find('a.feed').each(function(){this.click();}); } else { first_feed(); } -- cgit v1.2.3 From 7afd9e398a505aebf540ab32c3c6a29bb94a9514 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 21 Feb 2014 20:48:43 +0100 Subject: Bug "mark all as read" when using DESC and pagination https://github.com/marienfressinaud/FreshRSS/issues/431#issuecomment-35710258 --- app/views/helpers/javascript_vars.phtml | 1 + p/scripts/main.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 3d7c8a98f..afe0ab258 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -5,6 +5,7 @@ echo '"use strict";', "\n"; $mark = $this->conf->mark_when; echo 'var ', 'hide_posts=', ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'false' : 'true', + ',display_order="', Minz_Request::param('order', $this->conf->sort_order), '"', ',auto_mark_article=', $mark['article'] ? 'true' : 'false', ',auto_mark_site=', $mark['site'] ? 'true' : 'false', ',auto_mark_scroll=', $mark['scroll'] ? 'true' : 'false', diff --git a/p/scripts/main.js b/p/scripts/main.js index 34042c945..beb77a19c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -774,7 +774,11 @@ function load_more_posts() { $.get(url_load_more, function (data) { box_load_more.children('.flux:last').after($('#stream', data).children('.flux, .day')); $('.pagination').replaceWith($('.pagination', data)); - $('#bigMarkAsRead').attr('href', $('#nav_menu_read_all>a').attr('href')); + if (display_order === 'ASC') { + $('#nav_menu_read_all>a').attr('href', $('#bigMarkAsRead').attr('href')); + } else { + $('#bigMarkAsRead').attr('href', $('#nav_menu_read_all>a').attr('href')); + } $('[id^=day_]').each(function (i) { var ids = $('[id="' + this.id + '"]'); -- cgit v1.2.3 From 27764b36353b3066a9e92da2a96ac17b546295be Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 22 Feb 2014 16:53:51 -0500 Subject: Improve sharing Previously, the share page can handle only a limited number of shares and only one of each type. Now the configuration has been change to be more flexible and allows an unlimited number of shares. The share description is located in an array and the share configuration is stored along with the user configuration. Note: I tried to include the specific javascript code in a separate file but I did not succeded to import it. --- app/Controllers/configureController.php | 12 +---- app/Models/Configuration.php | 56 ++++++++++------------- app/Models/Share.php | 44 ++++++++++++++++++ app/i18n/en.php | 3 ++ app/i18n/fr.php | 3 ++ app/views/configure/sharing.phtml | 77 +++++++++++++------------------- app/views/helpers/view/normal_view.phtml | 73 +++++------------------------- data/shares.php | 75 +++++++++++++++++++++++++++++++ p/scripts/main.js | 28 +++++++++++- 9 files changed, 219 insertions(+), 152 deletions(-) create mode 100644 app/Models/Share.php create mode 100644 data/shares.php (limited to 'p/scripts') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index ad8bc546a..104fa8900 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -192,16 +192,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function sharingAction () { if (Minz_Request::isPost ()) { - $this->view->conf->_sharing (array( - 'shaarli' => Minz_Request::param ('shaarli', false), - 'wallabag' => Minz_Request::param ('wallabag', false), - 'diaspora' => Minz_Request::param ('diaspora', false), - 'twitter' => Minz_Request::param ('twitter', false), - 'g+' => Minz_Request::param ('g+', false), - 'facebook' => Minz_Request::param ('facebook', false), - 'email' => Minz_Request::param ('email', false), - 'print' => Minz_Request::param ('print', false), - )); + $params = Minz_Request::params(); + $this->view->conf->_sharing ($params['share']); $this->view->conf->save(); invalidateHttpCache(); diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 2b719c370..052e28ba8 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -48,16 +48,7 @@ class FreshRSS_Configuration { 'bottomline_tags' => true, 'bottomline_date' => true, 'bottomline_link' => true, - 'sharing' => array( - 'shaarli' => '', - 'wallabag' => '', - 'diaspora' => '', - 'twitter' => true, - 'g+' => true, - 'facebook' => true, - 'email' => true, - 'print' => true, - ), + 'sharing' => array(), ); private $available_languages = array( @@ -65,8 +56,10 @@ class FreshRSS_Configuration { 'fr' => 'Français', ); - public function __construct ($user) { - $this->filename = DATA_PATH . '/' . $user . '_user.php'; + private $shares; + + public function __construct($user) { + $this->filename = DATA_PATH . DIRECTORY_SEPARATOR . $user . '_user.php'; $data = @include($this->filename); if (!is_array($data)) { @@ -80,10 +73,20 @@ class FreshRSS_Configuration { } } $this->data['user'] = $user; + + $this->shares = DATA_PATH . DIRECTORY_SEPARATOR . 'shares.php'; + + $shares = @include($this->shares); + if (!is_array($shares)) { + throw new Minz_PermissionDeniedException($this->shares); + } + + $this->data['shares'] = $shares; } public function save() { @rename($this->filename, $this->filename . '.bak.php'); + unset($this->data['shares']); // Remove shares because it is not intended to be stored in user configuration if (file_put_contents($this->filename, "data, true) . ';', LOCK_EX) === false) { throw new Minz_PermissionDeniedException($this->filename); } @@ -104,16 +107,6 @@ class FreshRSS_Configuration { } } - public function sharing($key = false) { - if ($key === false) { - return $this->data['sharing']; - } - if (isset($this->data['sharing'][$key])) { - return $this->data['sharing'][$key]; - } - return false; - } - public function availableLanguages() { return $this->available_languages; } @@ -187,24 +180,23 @@ class FreshRSS_Configuration { } } public function _sharing ($values) { - $are_url = array ('shaarli', 'wallabag', 'diaspora'); - foreach ($values as $key => $value) { - if (in_array($key, $are_url)) { + $this->data['sharing'] = array(); + foreach ($values as $value) { + if (array_key_exists('url', $value)) { $is_url = ( - filter_var ($value, FILTER_VALIDATE_URL) || + filter_var ($value['url'], FILTER_VALIDATE_URL) || (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && ($value === filter_var($value, FILTER_SANITIZE_URL))) ); //PHP bug #51192 - if (!$is_url) { - $value = ''; + continue; + } + if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) { + $value['name'] = $value['type']; } - } elseif (!is_bool($value)) { - $value = true; } - - $this->data['sharing'][$key] = $value; + $this->data['sharing'][] = $value; } } public function _theme($value) { diff --git a/app/Models/Share.php b/app/Models/Share.php new file mode 100644 index 000000000..b146db722 --- /dev/null +++ b/app/Models/Share.php @@ -0,0 +1,44 @@ + 'HTTP username', 'http_password' => 'HTTP password', 'blank_to_disable' => 'Leave blank to disable', + 'share_name' => 'Share name to display', + 'share_url' => 'Share URL to use', 'not_yet_implemented' => 'Not yet implemented', 'access_protected_feeds' => 'Connection allows to access HTTP protected RSS feeds', 'no_selected_feed' => 'No feed selected.', @@ -230,6 +232,7 @@ return array ( 'more_information' => 'More information', 'activate_sharing' => 'Activate sharing', 'shaarli' => 'Shaarli', + 'blogotext' => 'Blogotext', 'wallabag' => 'wallabag', 'diaspora' => 'Diaspora*', 'twitter' => 'Twitter', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index ab7843d12..7420e2fdd 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -166,6 +166,8 @@ return array ( 'http_username' => 'Identifiant HTTP', 'http_password' => 'Mot de passe HTTP', 'blank_to_disable' => 'Laissez vide pour désactiver', + 'share_name' => 'Nom du partage à afficher', + 'share_url' => 'URL du partage à utiliser', 'not_yet_implemented' => 'Pas encore implémenté', 'access_protected_feeds' => 'La connexion permet d’accéder aux flux protégés par une authentification HTTP', 'no_selected_feed' => 'Aucun flux sélectionné.', @@ -230,6 +232,7 @@ return array ( 'more_information' => 'Plus d’informations', 'activate_sharing' => 'Activer le partage', 'shaarli' => 'Shaarli', + 'blogotext' => 'Blogotext', 'wallabag' => 'wallabag', 'diaspora' => 'Diaspora*', 'twitter' => 'Twitter', diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index e3ea11665..e46284955 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -3,54 +3,41 @@
    -
    + +
    ' + data-advanced='
    + + + +
    '> -
    - -
    - - - -
    -
    - -
    - -
    - - - -
    -
    - -
    - -
    - - - + conf->sharing as $key => $sharing): ?> + conf->shares[$sharing['type']]; ?> +
    + +
    + + ' /> + + + + + +
    -
    + -
    - +
    - - - + +
    @@ -61,4 +48,4 @@
    -
    +
  • \ No newline at end of file diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index ae93b627c..f27984025 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -8,19 +8,10 @@ if (!empty($this->entries)) { $display_yesterday = true; $display_others = true; if ($this->loginOk) { - $shaarli = $this->conf->sharing ('shaarli'); - $wallabag = $this->conf->sharing ('wallabag'); - $diaspora = $this->conf->sharing ('diaspora'); + $sharing = $this->conf->sharing; } else { - $shaarli = ''; - $wallabag = ''; - $diaspora = ''; + $sharing = array(); } - $twitter = $this->conf->sharing ('twitter'); - $google_plus = $this->conf->sharing ('g+'); - $facebook = $this->conf->sharing ('facebook'); - $email = $this->conf->sharing ('email'); - $print = $this->conf->sharing ('print'); $hidePosts = !$this->conf->display_posts; $lazyload = $this->conf->lazyload; $topline_read = $this->conf->topline_read; @@ -29,9 +20,7 @@ if (!empty($this->entries)) { $topline_link = $this->conf->topline_link; $bottomline_read = $this->conf->bottomline_read; $bottomline_favorite = $this->conf->bottomline_favorite; - $bottomline_sharing = $this->conf->bottomline_sharing && ( - $shaarli || $wallabag || $diaspora || $twitter || - $google_plus || $facebook || $email || $print); + $bottomline_sharing = $this->conf->bottomline_sharing && (count($sharing)); $bottomline_tags = $this->conf->bottomline_tags; $bottomline_date = $this->conf->bottomline_date; $bottomline_link = $this->conf->bottomline_link; @@ -146,55 +135,13 @@ if (!empty($this->entries)) { diff --git a/data/shares.php b/data/shares.php new file mode 100644 index 000000000..44176f1bf --- /dev/null +++ b/data/shares.php @@ -0,0 +1,75 @@ + array( + 'url' => '~URL~?post=~LINK~&title=~TITLE~&source=FreshRSS', + 'transform' => array('urlencode'), + 'help' => 'http://sebsauvage.net/wiki/doku.php?id=php:shaarli', + 'form' => 'advanced', + ), + 'blogotext' => array( + 'url' => '~URL~/admin/links.php?url=~LINK~', + 'transform' => array(), + 'help' => 'http://lehollandaisvolant.net/blogotext/fr/', + 'form' => 'advanced', + ), + 'wallabag' => array( + 'url' => '~URL~?action=add&url=~LINK~', + 'transform' => array( + 'link' => array('base64_encode'), + 'title' => array(), + ), + 'help' => 'http://www.wallabag.org/', + 'form' => 'advanced', + ), + 'diaspora' => array( + 'url' => '~URL~/bookmarklet?url=~LINK~&title=~TITLE~', + 'transform' => array('urlencode'), + 'help' => 'https://diasporafoundation.org/', + 'form' => 'advanced', + ), + 'twitter' => array( + 'url' => 'https://twitter.com/share?url=~LINK~&text=~TITLE~', + 'transform' => array('urlencode'), + 'form' => 'simple', + ), + 'g+' => array( + 'url' => 'https://plus.google.com/share?url=~LINK~', + 'transform' => array('urlencode'), + 'form' => 'simple', + ), + 'facebook' => array( + 'url' => 'https://www.facebook.com/sharer.php?u=~LINK~&t=~TITLE~', + 'transform' => array('urlencode'), + 'form' => 'simple', + ), + 'email' => array( + 'url' => 'mailto:?subject=~TITLE~&body=~LINK~', + 'transform' => array( + 'link' => array('urlencode'), + 'title' => array(), + ), + 'form' => 'simple', + ), + 'print' => array( + 'url' => '#', + 'transform' => array(), + 'form' => 'simple', + ), +); diff --git a/p/scripts/main.js b/p/scripts/main.js index beb77a19c..ec27bd50c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1,6 +1,7 @@ "use strict"; var $stream = null, - isCollapsed = true; + isCollapsed = true, + shares = 0; function is_normal_mode() { return $stream.hasClass('normal'); @@ -945,7 +946,7 @@ function init_confirm_action() { } function init_print_action() { - $('.print-article').click(function () { + $('.item.share > a[href="#"]').click(function () { var content = "