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 --- p/scripts/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') 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/main.js') 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 = "" - + $(".flux.current .content").html() - + ""; + var content = "" + + $(".flux.current .content").html() + + ""; var tmp_window = window.open(); tmp_window.document.writeln(content); @@ -1291,6 +1295,22 @@ function parseJsonVars() { window.icons = json.icons; } +function init_normal() { + $stream = $('#stream'); + if ($stream.length < 1) { + if (window.console) { + console.log('FreshRSS waiting for content…'); + } + window.setTimeout(init_normal, 50); + return; + } + init_column_categories(); + init_stream($stream); + init_shortcuts(); + init_actualize(); + faviconNbUnread(); +} + function init_beforeDOM() { if (!window.$) { if (window.console) { @@ -1300,20 +1320,8 @@ function init_beforeDOM() { return; } init_confirm_action(); - if (['normal', 'reader', 'global'].indexOf(context['current_view']) >= 0) { - $stream = $('#stream'); - if ($stream.length < 1) { - if (window.console) { - console.log('FreshRSS waiting for content…'); - } - window.setTimeout(init_beforeDOM, 50); - return; - } - init_column_categories(); - init_stream($stream); - init_shortcuts(); - init_actualize(); - faviconNbUnread(); + if (['normal', 'reader', 'global'].indexOf(context.current_view) >= 0) { + init_normal(); } } diff --git a/p/scripts/repartition.js b/p/scripts/repartition.js index a391de2f2..be70456fa 100644 --- a/p/scripts/repartition.js +++ b/p/scripts/repartition.js @@ -1,4 +1,7 @@ "use strict"; +/* globals Flotr, numberFormat */ +/* jshint globalstrict: true */ + function initStats() { if (!window.Flotr) { if (window.console) { @@ -19,9 +22,8 @@ function initStats() { { grid: {verticalLines: false}, xaxis: {noTicks: 23, - tickFormatter: function(x) { - var x = parseInt(x); - return x + 1; + tickFormatter: function(x1) { + return 1 + parseInt(x1); }, min: -0.9, max: 23.9, @@ -38,9 +40,8 @@ function initStats() { { grid: {verticalLines: false}, xaxis: {noTicks: 6, - tickFormatter: function(x) { - var x = parseInt(x); - return stats.days[x]; + tickFormatter: function(x2) { + return stats.days[parseInt(x2)]; }, min: -0.9, max: 6.9, @@ -57,9 +58,8 @@ function initStats() { { grid: {verticalLines: false}, xaxis: {noTicks: 12, - tickFormatter: function(x) { - var x = parseInt(x); - return stats.months[(x - 1)]; + tickFormatter: function(x3) { + return stats.months[parseInt(x3) - 1]; }, min: 0.1, max: 12.9, diff --git a/p/scripts/stats.js b/p/scripts/stats.js index 2e8ab6e27..9cd14721c 100644 --- a/p/scripts/stats.js +++ b/p/scripts/stats.js @@ -1,4 +1,7 @@ "use strict"; +/* globals Flotr, numberFormat */ +/* jshint globalstrict: true */ + function initStats() { if (!window.Flotr) { if (window.console) { -- cgit v1.2.3 From a051970d5b15a60e79ac2428280652486644c11c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Aug 2016 14:13:03 +0200 Subject: jQuery 3 compatibility https://jquery.com/upgrade-guide/3.0/ * event.props removed https://jquery.com/upgrade-guide/3.0/#breaking-change-jquery-event-props-and-jquery-event-fixhooks-removed https://github.com/jquery/api.jquery.com/issues/405 * jqXHR.success(), jqXHR.error(), and jqXHR.complete() removed --- p/scripts/category.js | 18 ++++++++---------- p/scripts/main.js | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/category.js b/p/scripts/category.js index c33e68528..8c7ba37b0 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -34,15 +34,13 @@ function init_draggable() { return; } - $.event.props.push('dataTransfer'); - var draggable = '[draggable="true"]', dropzone = '[dropzone="move"]'; $('.drop-section').on('dragstart', draggable, function(e) { - e.dataTransfer.effectAllowed = 'move'; - e.dataTransfer.setData('text/html', e.target.outerHTML); - e.dataTransfer.setData('text', e.target.getAttribute('data-feed-id')); + e.originalEvent.dataTransfer.effectAllowed = 'move'; + e.originalEvent.dataTransfer.setData('text/html', e.target.outerHTML); + e.originalEvent.dataTransfer.setData('text', e.target.getAttribute('data-feed-id')); e.target.style.opacity = 0.3; dnd_successful = false; @@ -74,13 +72,13 @@ function init_draggable() { $(this).removeClass('drag-hover'); }); $('.drop-section').on('dragover', dropzone, function(e) { - e.dataTransfer.dropEffect = "move"; + e.originalEvent.dataTransfer.dropEffect = "move"; e.preventDefault(); return false; }); $('.drop-section').on('drop', dropzone, function(e) { - var feed_id = e.dataTransfer.getData('text'), + var feed_id = e.originalEvent.dataTransfer.getData('text'), cat_id = e.target.parentNode.getAttribute('data-cat-id'); loading = true; @@ -92,13 +90,13 @@ function init_draggable() { f_id: feed_id, c_id: cat_id } - }).success(function() { - $(e.target).after(e.dataTransfer.getData('text/html')); + }).done(function() { + $(e.target).after(e.originalEvent.dataTransfer.getData('text/html')); if ($(e.target).hasClass('disabled')) { $(e.target).remove(); } dnd_successful = true; - }).complete(function() { + }).always(function() { loading = false; }); diff --git a/p/scripts/main.js b/p/scripts/main.js index 01c8c9cf5..c95df54fa 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -772,7 +772,7 @@ function updateFeed(feeds, feeds_count) { $.ajax({ type: 'POST', url: feed['url'], - }).complete(function (data) { + }).always(function (data) { feed_processed++; $("#actualizeProgress .progress").html(feed_processed + " / " + feeds_count); $("#actualizeProgress .title").html(feed['title']); -- cgit v1.2.3 From e6fd34bdda5d067a9e74714aaae10c89ed998a46 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 13 Aug 2016 17:49:31 +0200 Subject: CSRF token, update HTTP Referrer policy to same-origin https://www.w3.org/TR/referrer-policy/#referrer-policy-no-referrer https://github.com/FreshRSS/FreshRSS/issues/570 https://github.com/FreshRSS/FreshRSS/issues/955 https://github.com/FreshRSS/FreshRSS/issues/1198 https://github.com/FreshRSS/FreshRSS/issues/565 https://github.com/FreshRSS/FreshRSS/issues/554 --- app/FreshRSS.php | 2 +- app/Models/Auth.php | 21 +++++++++++++ app/layout/aside_feed.phtml | 1 + app/layout/layout.phtml | 2 +- app/layout/nav_menu.phtml | 1 + app/views/auth/formLogin.phtml | 1 + app/views/auth/index.phtml | 1 + app/views/auth/register.phtml | 55 +++++++++++++++++---------------- app/views/configure/archiving.phtml | 2 ++ app/views/configure/display.phtml | 1 + app/views/configure/queries.phtml | 1 + app/views/configure/reading.phtml | 1 + app/views/configure/sharing.phtml | 1 + app/views/configure/shortcut.phtml | 1 + app/views/configure/system.phtml | 1 + app/views/extension/index.phtml | 1 + app/views/feed/add.phtml | 1 + app/views/helpers/feed/update.phtml | 1 + app/views/helpers/javascript_vars.phtml | 1 + app/views/helpers/pagination.phtml | 1 + app/views/importExport/index.phtml | 2 ++ app/views/index/logs.phtml | 1 + app/views/stats/idle.phtml | 1 + app/views/subscription/index.phtml | 7 ++++- app/views/user/manage.phtml | 2 ++ app/views/user/profile.phtml | 2 ++ lib/lib_rss.php | 2 +- p/scripts/main.js | 13 ++++++-- 28 files changed, 94 insertions(+), 33 deletions(-) (limited to 'p/scripts/main.js') diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 20640266e..f9c371d27 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -57,7 +57,7 @@ class FreshRSS extends Minz_FrontController { private static function initAuth() { FreshRSS_Auth::init(); - if (Minz_Request::isPost() && !is_referer_from_same_domain()) { + if (Minz_Request::isPost() && !(is_referer_from_same_domain() && FreshRSS_Auth::isCsrfOk())) { // Basic protection against XSRF attacks FreshRSS_Auth::removeAccess(); $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; diff --git a/app/Models/Auth.php b/app/Models/Auth.php index d689f7cdb..f0e8db5a2 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -124,6 +124,7 @@ class FreshRSS_Auth { self::$login_ok = false; $conf = Minz_Configuration::get('system'); Minz_Session::_param('currentUser', $conf->default_user); + Minz_Session::_param('csrf'); switch ($conf->auth_type) { case 'form': @@ -156,6 +157,26 @@ class FreshRSS_Auth { $auth_type = $conf->auth_type; return $auth_type === 'form'; } + + public static function csrfToken() { + $csrf = Minz_Session::param('csrf'); + if ($csrf == '') { + $salt = FreshRSS_Context::$system_conf->salt; + $csrf = sha1($salt . uniqid(mt_rand(), true)); + Minz_Session::_param('csrf', $csrf); + } + return $csrf; + } + public static function isCsrfOk($token = null) { + $csrf = Minz_Session::param('csrf'); + if ($csrf == '') { + return true; //Not logged in yet + } + if ($token === null) { + $token = Minz_Request::param('_csrf'); + } + return $token === $csrf; + } } diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 67507b88d..e8fdbf842 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -20,6 +20,7 @@
+
  • diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index 2aeba40a9..189d93fbe 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -42,7 +42,7 @@ ?> allow_referrer) { ?> - + allow_robots) { ?> diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 92268ff67..17655acbf 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -88,6 +88,7 @@ type="submit">
    diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index b7e8f68cd..bf87a255a 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -37,7 +37,7 @@
    - +
    @@ -46,10 +46,10 @@
    - +
    - +
    diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml index 3af7436c3..a9d5a80ca 100644 --- a/app/views/helpers/index/normal/entry_bottom.phtml +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -52,7 +52,7 @@ $share_options['title'] = $title; $share->update($share_options); ?>
@@ -81,6 +81,6 @@ ?>
  • entry->date(); ?>
  • diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml index dc544298f..86298e59f 100644 --- a/app/views/helpers/index/normal/entry_header.phtml +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -27,7 +27,7 @@ } } ?>
  • ✇ feed->name(); ?>
  • -
  • entry->title(); ?>
  • +
  • entry->title(); ?>
  • entry->date(); ?> 
  • - + diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 91ebcebd3..6fda11ed9 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -66,7 +66,7 @@ if (!empty($this->entries)) { ?>
    -

    entry->title(); ?>

    +

    entry->title(); ?>

    entry->author(); echo $author != '' ? '
    ' . _t('gen.short.by_author', $author) . '
    ' : '', diff --git a/p/scripts/main.js b/p/scripts/main.js index 8980fe2f6..74631451a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -752,7 +752,7 @@ function init_stream(divStream) { }); divStream.on('click', '.flux .content a', function () { - $(this).attr('target', '_blank'); + $(this).attr('target', '_blank').attr('rel', 'noreferrer'); }); if (context.auto_mark_site) { -- cgit v1.2.3 From 7adcc0d29d54461222d57924d5d2875d639ca698 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 6 Oct 2016 19:07:54 +0200 Subject: FreshRSS custom event 'freshrss:load-more' https://github.com/FreshRSS/FreshRSS/issues/1278 --- p/scripts/main.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 74631451a..2ebd09bcb 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1021,6 +1021,9 @@ function focus_search() { $('#search').focus(); } +var freshrssLoadMoreEvent = document.createEvent('Event'); +freshrssLoadMoreEvent.initEvent('freshrss:load-more', true, true); + function init_load_more(box) { box_load_more = box; @@ -1030,6 +1033,8 @@ function init_load_more(box) { }); } + document.body.dispatchEvent(freshrssLoadMoreEvent); + var $next_link = $("#load_more"); if (!$next_link.length) { // no more article to load -- cgit v1.2.3 From 6bc37cef47b41821055fc9e2c1ecb0ffbcc5d0d3 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 8 Oct 2016 21:45:47 +0200 Subject: W3C resource-priorities have been abandonned https://github.com/FreshRSS/FreshRSS/issues/1222 --- app/Models/Feed.php | 2 +- lib/lib_rss.php | 7 +++---- p/scripts/main.js | 6 ------ 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'p/scripts/main.js') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f435620c8..21c1ef93d 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -309,7 +309,7 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = '1'; $mime = strtolower($enclosure->get_type()); if (strpos($mime, 'image/') === 0) { - $content .= '

    '; + $content .= '

    '; } elseif (strpos($mime, 'audio/') === 0) { $content .= '

    💾

    '; } elseif (strpos($mime, 'video/') === 0) { diff --git a/lib/lib_rss.php b/lib/lib_rss.php index a4cd8e782..b18512484 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -182,10 +182,9 @@ function customSimplePie() { 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless', 'sizes', 'srcset'))); $simplePie->add_attributes(array( - 'img' => array('lazyload' => '', 'postpone' => ''), //http://www.w3.org/TR/resource-priorities/ - 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), - 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), - 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), + 'audio' => array('preload' => 'none'), + 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), + 'video' => array('preload' => 'none'), )); $simplePie->set_url_replacements(array( 'a' => 'href', diff --git a/p/scripts/main.js b/p/scripts/main.js index 2ebd09bcb..3c0a36629 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1027,12 +1027,6 @@ freshrssLoadMoreEvent.initEvent('freshrss:load-more', true, true); function init_load_more(box) { box_load_more = box; - if (!context.does_lazyload) { - $('img[postpone], audio[postpone], iframe[postpone], video[postpone]').each(function () { - this.removeAttribute('postpone'); - }); - } - document.body.dispatchEvent(freshrssLoadMoreEvent); var $next_link = $("#load_more"); -- cgit v1.2.3 From 189692e6adea2acb098bae5bc9ce75844080d040 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 10 Oct 2016 21:57:33 +0200 Subject: Fix bug share https://github.com/FreshRSS/FreshRSS/issues/1289 Was using deprecated non-standard parameter in string.replace() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Firefox-specific_notes --- p/scripts/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 3c0a36629..d42704f7a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1153,10 +1153,10 @@ function init_share_observers() { $('.share.add').on('click', function(e) { var opt = $(this).siblings('select').find(':selected'); var row = $(this).parents('form').data(opt.data('form')); - row = row.replace('##label##', opt.html().trim(), 'g'); - row = row.replace('##type##', opt.val(), 'g'); - row = row.replace('##help##', opt.data('help'), 'g'); - row = row.replace('##key##', shares, 'g'); + row = row.replace(/##label##/g, opt.html().trim()); + row = row.replace(/##type##/g, opt.val()); + row = row.replace(/##help##/g, opt.data('help')); + row = row.replace(/##key##/g, shares); $(this).parents('.form-group').before(row); shares++; -- cgit v1.2.3 From b4298f498f8afb5c5ac0bfa65bb628cf47561a21 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:33:42 +0200 Subject: Scroll as read https://github.com/FreshRSS/FreshRSS/issues/1258 --- p/scripts/main.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index d42704f7a..b2bd994ad 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -116,21 +116,18 @@ function incUnreadsFeed(article, feed_id, nb) { var pending_entries = {}; function mark_read(active, only_not_read) { - if (active.length === 0 || + if (active.length === 0 || active.attr('id') == '' || (only_not_read === true && !active.hasClass("not_read"))) { return false; } - var url = active.find("a.read").attr("href"); - if (url === undefined) { - return false; - } - if (pending_entries[active.attr('id')]) { return false; } pending_entries[active.attr('id')] = true; + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + $.ajax({ type: 'POST', url: url, @@ -150,10 +147,11 @@ 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); + var feed_url = active.find(".website>a").attr("href"); + if (feed_url) { + var feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); + incUnreadsFeed(active, feed_id, inc); + } faviconNbUnread(); delete pending_entries[active.attr('id')]; @@ -451,14 +449,9 @@ function auto_share(key) { } function inMarkViewport(flux, box_to_follow) { - var top = flux.offset().top; - var height = flux.height(), - begin = top + 3 * height / 4, - bot = Math.min(begin + 75, top + height), - windowTop = box_to_follow.scrollTop(), - windowBot = windowTop + box_to_follow.height() / 2; - - return (windowBot >= begin && bot >= windowBot); + var bottom = flux.offset().top + flux.height(), + windowTop = box_to_follow.scrollTop(); + return bottom < windowTop + 40; } function init_posts() { @@ -470,7 +463,7 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if ($(this).children(".flux_content").is(':visible') && inMarkViewport($(this), box_to_follow)) { + if (inMarkViewport($(this), box_to_follow)) { mark_read($(this), true); } }); -- cgit v1.2.3 From f766f34775c7162058b929b397ac7fd20dc885b2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:38:25 +0200 Subject: Scroll as read minor variable --- p/scripts/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index b2bd994ad..75d194906 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -463,8 +463,9 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if (inMarkViewport($(this), box_to_follow)) { - mark_read($(this), true); + var $this = $(this); + if (inMarkViewport($this, box_to_follow)) { + mark_read($this, true); } }); }); -- cgit v1.2.3 From 626d9cbccbd0a52c7ece4ffeaab9bd09f62a3761 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 14 Oct 2016 09:20:11 +0200 Subject: Scroll as read: mark as unread bug --- p/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 75d194906..b3531e884 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -126,7 +126,8 @@ function mark_read(active, only_not_read) { } pending_entries[active.attr('id')] = true; - var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, '') + + (active.hasClass('not_read') ? '' : '&is_read=0'); $.ajax({ type: 'POST', -- cgit v1.2.3 From ce14841cc05e500819c0cdb2c594be8b44e91e2d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 12:31:13 +0200 Subject: Scroll as read for Global view + throttle event https://github.com/FreshRSS/FreshRSS/issues/1317 https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index b3531e884..400abf947 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -449,26 +449,22 @@ function auto_share(key) { } } -function inMarkViewport(flux, box_to_follow) { - var bottom = flux.offset().top + flux.height(), - windowTop = box_to_follow.scrollTop(); - return bottom < windowTop + 40; -} - function init_posts() { - var box_to_follow = $(window); - if (context.current_view === 'global') { - box_to_follow = $("#panel"); - } + var box_to_follow = context.current_view === 'global' ? $("#panel") : $(window); if (context.auto_mark_scroll) { + var lastScroll = 0; //Throttle box_to_follow.scroll(function () { - $('.not_read:visible').each(function () { - var $this = $(this); - if (inMarkViewport($this, box_to_follow)) { - mark_read($this, true); - } - }); + if (lastScroll + 500 < Date.now()) { + lastScroll = Date.now(); + $('.not_read:visible').each(function () { + var $this = $(this), + minTop = (context.current_view === 'global') ? box_to_follow.offset().top : box_to_follow.scrollTop(); + if ($this.offset().top + $this.height() < minTop + 40) { + mark_read($this, true); + } + }); + } }); } -- cgit v1.2.3 From eb88fee64bccfacbb8b1f5d84ba833d3a8286aa0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 15:10:21 +0200 Subject: Scroll performance Fewer events, and ensure an event is fired after the end of the scroll. https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 400abf947..47d651d5b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -449,21 +449,31 @@ function auto_share(key) { } } +function scrollAsRead(box_to_follow) { + var minTop = 40 + (context.current_view === 'global' ? box_to_follow.offset().top : box_to_follow.scrollTop()); + $('.not_read:visible').each(function () { + var $this = $(this); + if ($this.offset().top + $this.height() < minTop) { + mark_read($this, true); + } + }); +} + function init_posts() { var box_to_follow = context.current_view === 'global' ? $("#panel") : $(window); if (context.auto_mark_scroll) { - var lastScroll = 0; //Throttle + var lastScroll = 0, //Throttle + timerId = 0; box_to_follow.scroll(function () { + window.clearTimeout(timerId); if (lastScroll + 500 < Date.now()) { lastScroll = Date.now(); - $('.not_read:visible').each(function () { - var $this = $(this), - minTop = (context.current_view === 'global') ? box_to_follow.offset().top : box_to_follow.scrollTop(); - if ($this.offset().top + $this.height() < minTop + 40) { - mark_read($this, true); - } - }); + scrollAsRead(box_to_follow); + } else { + timerId = window.setTimeout(function() { + scrollAsRead(box_to_follow); + }, 500); } }); } -- cgit v1.2.3 From 3f78bad3970113f14b80db19808e2c58af8fb19e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 15:53:08 +0200 Subject: Scroll as read: keep unread function https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 47d651d5b..138a223de 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -144,6 +144,7 @@ function mark_read(active, only_not_read) { inc--; } else if (only_not_read !== true || active.hasClass("not_read")) { active.addClass("not_read"); + active.addClass("keep_unread"); inc++; } $r.find('.icon').replaceWith(data.icon); @@ -451,7 +452,7 @@ function auto_share(key) { function scrollAsRead(box_to_follow) { var minTop = 40 + (context.current_view === 'global' ? box_to_follow.offset().top : box_to_follow.scrollTop()); - $('.not_read:visible').each(function () { + $('.not_read:not(.keep_unread):visible').each(function () { var $this = $(this); if ($this.offset().top + $this.height() < minTop) { mark_read($this, true); -- cgit v1.2.3 From 6cd38d73d0b41ea7cd4da1fe611d761d7d442f2b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 16:10:58 +0200 Subject: mark_read optimisation --- p/scripts/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 138a223de..51323a969 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -116,8 +116,8 @@ function incUnreadsFeed(article, feed_id, nb) { var pending_entries = {}; function mark_read(active, only_not_read) { - if (active.length === 0 || active.attr('id') == '' || - (only_not_read === true && !active.hasClass("not_read"))) { + if ((active.length === 0) || (!active.attr('id')) || + (only_not_read && !active.hasClass("not_read"))) { return false; } @@ -142,7 +142,7 @@ function mark_read(active, only_not_read) { if (active.hasClass("not_read")) { active.removeClass("not_read"); inc--; - } else if (only_not_read !== true || active.hasClass("not_read")) { + } else { active.addClass("not_read"); active.addClass("keep_unread"); inc++; -- cgit v1.2.3 From 00f446d1557165cba90d0d3ec17404d3fdce84cd Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 29 Oct 2016 13:11:37 +0200 Subject: Disable "mark all as read" before confirmation script is loaded https://github.com/FreshRSS/FreshRSS/issues/1342 --- CHANGELOG.md | 1 + app/layout/aside_feed.phtml | 2 +- app/layout/nav_menu.phtml | 2 +- app/views/helpers/pagination.phtml | 2 +- p/scripts/main.js | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) (limited to 'p/scripts/main.js') diff --git a/CHANGELOG.md b/CHANGELOG.md index acec03f39..6873530f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * Fix some messages during installation [#1339](https://github.com/FreshRSS/FreshRSS/pull/1339) * UI * Fix CSS line-height bug with `` in dates (English, Russian, Turkish) [#1340](https://github.com/FreshRSS/FreshRSS/pull/1340) + * Disable *Mark all as read* before confirmation script is loaded [#1342](https://github.com/FreshRSS/FreshRSS/issues/1342) * Download icon 💾 for podcasts [#1236](https://github.com/FreshRSS/FreshRSS/issues/1236) * SimplePie * Fix auto-discovery of RSS feeds in Web pages served as `text/xml` [#1264](https://github.com/FreshRSS/FreshRSS/issues/1264) diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 94c281b7f..3e1ee44dd 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -85,7 +85,7 @@
  • - reading_confirm ? 'confirm' : ''; ?> + reading_confirm ? 'confirm" disabled="disabled' : ''; ?>