From d19824b919289ad63743f27da7861f2422da5baa Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 26 Jul 2014 13:56:44 +0200 Subject: Hide read feeds and read categories when in unread mode https://github.com/marienfressinaud/FreshRSS/issues/430 There are some repeated HTML attributes (`data-unread` and `active`) which could maybe be simplified. If some people do not like this behaviour, we could consider having an option. --- p/scripts/main.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index d0f3c27e9..1cc26f57f 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -69,6 +69,10 @@ function incUnreadsFeed(article, feed_id, nb) { feed_priority = elem ? str2int(elem.getAttribute('data-priority')) : 0; if (elem) { elem.setAttribute('data-unread', numberFormat(feed_unreads + nb)); + elem = $(elem).closest('li').get(0); + if (elem) { + elem.setAttribute('data-unread', feed_unreads + nb); + } } //Update unread: category @@ -76,6 +80,10 @@ function incUnreadsFeed(article, feed_id, nb) { feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0; if (elem) { elem.setAttribute('data-unread', numberFormat(feed_unreads + nb)); + elem = $(elem).closest('li').get(0); + if (elem) { + elem.setAttribute('data-unread', feed_unreads + nb); + } } //Update unread: all -- cgit v1.2.3 From 3ffa2e301850154c6d7959f70dbbd37dc7fbffc9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 31 Jul 2014 17:19:25 +0200 Subject: Fix bug collapse and mark_read Articles was not marked as read when open with shortcuts.collapse_entry Fix https://github.com/marienfressinaud/FreshRSS/issues/556 --- p/scripts/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index d0f3c27e9..adbd5eab8 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -361,7 +361,12 @@ function last_category() { function collapse_entry() { isCollapsed = !isCollapsed; - $(".flux.current").toggleClass("active"); + + var flux_current = $(".flux.current"); + flux_current.toggleClass("active"); + if (isCollapsed) { + mark_read(flux_current, true); + } } function auto_share(key) { -- cgit v1.2.3 From 8e5d98c4be836eed824260c01714e8d3624b9bef Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Aug 2014 01:33:33 +0200 Subject: Dynamic favicon showing the number of unread articles https://github.com/marienfressinaud/FreshRSS/issues/539 Works in Firefox 32 and Opera 12. Does not work in IE 11 but without error. We should test if icons still work in many contexts such as placing a shortcut on the desktop of various platforms. --- CHANGELOG | 3 ++- app/layout/layout.phtml | 2 +- p/scripts/main.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) (limited to 'p/scripts/main.js') diff --git a/CHANGELOG b/CHANGELOG index 901b17d92..33cb810c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,8 +2,9 @@ ## 2014-08-xx FreshRSS 0.7.4 -* New options +* UI * Hide categories/feeds with unread articles when showing only unread articles + * Dynamic favicon showing the number of unread articles * Statistics * New page with article repartition * Improvements diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index d2e1e4b3b..96a88d245 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -16,7 +16,7 @@ ?> - + url)) { diff --git a/p/scripts/main.js b/p/scripts/main.js index 5d7d60a35..6876a9995 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -160,6 +160,7 @@ function mark_read(active, only_not_read) { $r.find('.icon').replaceWith(data.icon); incUnreadsFeed(active, feed_id, inc); + faviconNbUnread(); pending_feeds.splice(index_pending, 1); }); @@ -793,6 +794,7 @@ function refreshUnreads() { $('#new-article').show(); }; }); + faviconNbUnread(); }); } @@ -1065,6 +1067,35 @@ function init_password_observers() { }); } +function faviconNbUnread(n) { + if (typeof n === 'undefined') { + n = parseInt($('.category.all>a').attr('data-unread')); + } + //http://remysharp.com/2010/08/24/dynamic-favicons/ + var canvas = document.createElement('canvas'), + link = document.getElementById('favicon').cloneNode(true); + if (canvas.getContext && link) { + canvas.height = canvas.width = 16; + var img = document.createElement('img'); + img.onload = function () { + var ctx = canvas.getContext('2d'), + text = n < 100 ? n : '99+'; + ctx.drawImage(this, 0, 0); + if (n > 0) { + ctx.font = 'bold 9px "Arial", sans-serif'; + ctx.fillStyle = 'rgba(255, 255, 255, 127)'; + ctx.fillRect(0, 8, 1 + ctx.measureText(text).width, 7); + ctx.fillStyle = '#F00'; + ctx.fillText(text, 0, 16); + } + link.href = canvas.toDataURL('image/png'); + $('link[rel~=icon]').remove(); + document.head.appendChild(link); + }; + img.src = '../favicon.ico'; + } +} + function init_all() { if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) { if (window.console) { @@ -1092,6 +1123,7 @@ function init_all() { init_stream($stream); init_nav_entries(); init_shortcuts(); + faviconNbUnread(); init_print_action(); window.setInterval(refreshUnreads, 120000); } else { -- cgit v1.2.3 From 0246d2340b2db208de3fad48e7d45608351e3ab5 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Aug 2014 02:12:20 +0200 Subject: Dynamic favicon large numbers https://github.com/marienfressinaud/FreshRSS/issues/539 --- p/scripts/main.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 6876a9995..d18a02668 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1069,7 +1069,7 @@ function init_password_observers() { function faviconNbUnread(n) { if (typeof n === 'undefined') { - n = parseInt($('.category.all>a').attr('data-unread')); + n = str2int($('.category.all>a').attr('data-unread')); } //http://remysharp.com/2010/08/24/dynamic-favicons/ var canvas = document.createElement('canvas'), @@ -1078,10 +1078,19 @@ function faviconNbUnread(n) { canvas.height = canvas.width = 16; var img = document.createElement('img'); img.onload = function () { - var ctx = canvas.getContext('2d'), - text = n < 100 ? n : '99+'; + var ctx = canvas.getContext('2d'); ctx.drawImage(this, 0, 0); if (n > 0) { + var text = ''; + if (n < 100) { + text = n; + } else if (n < 1000) { + text = Math.floor(n / 100) + 'h+'; + } else if (n < 10000) { + text = Math.floor(n / 1000) + 'k+'; + } else { + text = '10k+'; + } ctx.font = 'bold 9px "Arial", sans-serif'; ctx.fillStyle = 'rgba(255, 255, 255, 127)'; ctx.fillRect(0, 8, 1 + ctx.measureText(text).width, 7); -- cgit v1.2.3 From c685998768aae2177fabdba78f96bf5e790cf841 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Aug 2014 11:43:43 +0200 Subject: Dynamic favicon large numbers 2 https://github.com/marienfressinaud/FreshRSS/issues/539 --- p/scripts/main.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index d18a02668..5677e5bbc 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1082,14 +1082,12 @@ function faviconNbUnread(n) { ctx.drawImage(this, 0, 0); if (n > 0) { var text = ''; - if (n < 100) { + if (n < 1000) { text = n; - } else if (n < 1000) { - text = Math.floor(n / 100) + 'h+'; - } else if (n < 10000) { - text = Math.floor(n / 1000) + 'k+'; + } else if (n < 100000) { + text = Math.floor(n / 1000) + 'k'; } else { - text = '10k+'; + text = 'E' + Math.min(99, Math.floor(Math.log10(n))); } ctx.font = 'bold 9px "Arial", sans-serif'; ctx.fillStyle = 'rgba(255, 255, 255, 127)'; -- cgit v1.2.3 From 6bbf7d51cf19203517b5b0d3ba20b1cc30eb7628 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Aug 2014 15:33:00 +0200 Subject: Dynamic favicon quick fix Chrome https://github.com/marienfressinaud/FreshRSS/issues/539 Could be done better --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 5677e5bbc..b6214e508 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1079,7 +1079,7 @@ function faviconNbUnread(n) { var img = document.createElement('img'); img.onload = function () { var ctx = canvas.getContext('2d'); - ctx.drawImage(this, 0, 0); + ctx.drawImage(this, 0, 0, canvas.width, canvas.height); if (n > 0) { var text = ''; if (n < 1000) { -- cgit v1.2.3 From 274c8096e3ccc8ea008c1a038134ffddc302fd0d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Aug 2014 19:57:15 +0200 Subject: Experimental: Removed lazyload.js and use postpone attribute instead https://github.com/marienfressinaud/FreshRSS/issues/316 The performance of lazyload.js was not good enough, and not really needed anyway. This change mostly affects mainly situations when the content of articles is shown by default, not so much when they are collapsed Using HTML5 lazyload and postpone attributes by default on all img, audio, iframe, video. http://www.w3.org/TR/resource-priorities/#attr-postpone Postpone attribute is removed by JavaScript if the user does not want the lazyload behaviour. In the case when users do want the lazyload behaviour, in normal view with articles hidden, we furthermore use the data-original approach to be sure to support current browsers. +Corrected some bugs with enclosures, and some images not appearing before the first scroll. +Now faster regex processing img and iframe at once (was not practical with lazyload.js) --- CHANGELOG | 2 ++ README.md | 1 - app/FreshRSS.php | 10 +++------- app/Models/Feed.php | 6 +++--- app/views/configure/reading.phtml | 2 +- app/views/helpers/javascript_vars.phtml | 1 - app/views/helpers/view/normal_view.phtml | 10 +++------- app/views/helpers/view/reader_view.phtml | 18 ++++++------------ lib/lib_rss.php | 20 ++++++-------------- p/scripts/jquery.lazyload.min.js | 15 --------------- p/scripts/main.js | 25 ++++++++----------------- 11 files changed, 32 insertions(+), 78 deletions(-) delete mode 100644 p/scripts/jquery.lazyload.min.js (limited to 'p/scripts/main.js') diff --git a/CHANGELOG b/CHANGELOG index 33cb810c4..969af92a7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,8 @@ * Improvements * Security * Basic protection against XSRF (Cross-Site Request Forgery) based on HTTP Referer (POST requests only) +* Misc. + * Changed lazyload implementation * Bux fixes in export function, add/remove users, keyboard shortcuts, etc. diff --git a/README.md b/README.md index fff08472b..8963e040c 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,6 @@ mysqldump -u utilisateur -p --databases freshrss > freshrss.sql ## Uniquement pour certaines options * [bcrypt.js](https://github.com/dcodeIO/bcrypt.js) * [phpQuery](http://code.google.com/p/phpquery/) -* [Lazy Load](http://www.appelsiini.net/projects/lazyload) ## Si les fonctions natives ne sont pas disponibles * [Services_JSON](http://pear.php.net/pepr/pepr-proposal-show.php?id=198) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 3443589c6..7c333b090 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -136,13 +136,9 @@ class FreshRSS extends Minz_FrontController { Minz_View::appendScript('https://login.persona.org/include.js'); break; } - $includeLazyLoad = $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param ('output') === 'reader'); - Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad); - if ($includeLazyLoad) { - Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js'))); - } - Minz_View::appendScript (Minz_Url::display ('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); - Minz_View::appendScript (Minz_Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); } private function loadNotifications () { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 576f37760..fe1e52ea2 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -277,11 +277,11 @@ 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 .= '