From 20223b8b01f47fba0858d854c5744fad5900b9cc Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Jan 2019 12:33:18 +0100 Subject: Automatic API test (#2207) * Automatic API test Easier for end-user, smarter, and the guess testing of greader authorization token was not reliable. * Travis + minor --- p/scripts/api.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 p/scripts/api.js (limited to 'p/scripts') diff --git a/p/scripts/api.js b/p/scripts/api.js new file mode 100644 index 000000000..841b16a6a --- /dev/null +++ b/p/scripts/api.js @@ -0,0 +1,62 @@ +"use strict"; +/* jshint esversion:6, strict:global */ + +function check(url, next) { + if (!url || !next) { + return; + } + const req = new XMLHttpRequest(); + req.open('GET', url, true); + req.setRequestHeader('Authorization', 'GoogleLogin auth=test/1'); + req.onerror = function (e) { + next('FAIL: HTTP ' + e); + }; + req.onload = function () { + if (this.status == 200) { + next(this.response); + } else { + next('FAIL: HTTP error ' + this.status + ' ' + this.statusText); + } + }; + req.send(); +} + +const jsonVars = JSON.parse(document.getElementById('jsonVars').innerHTML); + +check(jsonVars.greader + '/check/compatibility', function next(result1) { + const greaderOutput = document.getElementById('greaderOutput'); + if (result1 === 'PASS') { + greaderOutput.innerHTML = '✔️ ' + result1; + } else { + check(jsonVars.greader + '/check%2Fcompatibility', function next(result2) { + if (result2 === 'PASS') { + greaderOutput.innerHTML = '⚠️ WARN: no %2F support, so some clients will not work!'; + } else { + check('./greader.php/check/compatibility', function next(result3) { + if (result3 === 'PASS') { + greaderOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php'; + } else { + greaderOutput.innerHTML = '❌ ' + result1; + } + }); + } + }); + } + }); + +check(jsonVars.fever + '?api', function next(result1) { + const feverOutput = document.getElementById('feverOutput'); + try { + JSON.parse(result1); + feverOutput.innerHTML = '✔️ PASS'; + } catch (ex) { + check('./fever.php?api', function next(result2) { + try { + JSON.parse(result2); + feverOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php'; + } catch (ex) { + feverOutput.innerHTML = '❌ ' + result1; + } + }); + } + }); -- cgit v1.2.3 From 9214eeecff363883d3d396490e8f1c7adf523c05 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 15 Jan 2019 18:51:13 +0100 Subject: Comment about Gecko scrollbar bug in Firefox 64 https://bugzilla.mozilla.org/show_bug.cgi?id=1514498 --- 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 4ba329dc1..b12b3cf26 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -543,7 +543,7 @@ function init_column_categories() { } }); $(this).parent().next(".tree-folder-items").slideToggle(300, function () { - //Workaround for Gecko bug in Firefox 64-65(+?): + //Workaround for Gecko bug 1514498 in Firefox 64 var sidebar = document.getElementById('sidebar'); if (sidebar && sidebar.scrollHeight > sidebar.clientHeight && //if needs scrollbar sidebar.scrollWidth >= sidebar.offsetWidth) { //but no scrollbar -- cgit v1.2.3 From da4a80b88a64855bd62d996baabaaf25497c5f42 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 24 Jan 2019 19:43:28 +0100 Subject: Add a JavaScript event when opening an article (#2222) * Add a JavaScript event when opening an article https://framagit.org/nicofrand/xextension-threepanesview/issues/4 ```javascript document.body.addEventListener('freshrss:openArticle', function (e) { console.log('freshrss:openArticle'); console.log(e.target); }); ``` --- CHANGELOG.md | 2 ++ p/scripts/main.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'p/scripts') diff --git a/CHANGELOG.md b/CHANGELOG.md index badc66e79..3a0188431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ * New `TZ` timezone environment variable [#2153](https://github.com/FreshRSS/FreshRSS/issues/2153) * Run Docker cron job with Apache user instead of root [#2208](https://github.com/FreshRSS/FreshRSS/pull/2208) * Accept HTTP header `X-WebAuth-User` for delegated HTTP Authentication [#2204](https://github.com/FreshRSS/FreshRSS/pull/2204) +* Extensions + * Trigger a `freshrss:openArticle` JavaScript event [#2222](https://github.com/FreshRSS/FreshRSS/pull/2222) * API * Automatic test of API configuration [#2207](https://github.com/FreshRSS/FreshRSS/pull/2207) * Performance + compatibility: Use Apache `SetEnvIf` module if available and fall-back to `RewriteRule` [#2202](https://github.com/FreshRSS/FreshRSS/pull/2202) diff --git a/p/scripts/main.js b/p/scripts/main.js index b12b3cf26..6cab2e55a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -237,6 +237,9 @@ function mark_favorite(active) { }); } +var freshrssOpenArticleEvent = document.createEvent('Event'); +freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true); + function toggleContent(new_active, old_active, skipping) { // If skipping, move current without activating or marking as read if (new_active.length === 0) { @@ -299,8 +302,11 @@ function toggleContent(new_active, old_active, skipping) { } } - if (context.auto_mark_article && new_active.hasClass('active') && !skipping) { - mark_read(new_active, true); + if (new_active.hasClass('active') && !skipping) { + if (context.auto_mark_article) { + mark_read(new_active, true); + } + new_active[0].dispatchEvent(freshrssOpenArticleEvent); } } -- cgit v1.2.3