fossar / selfoss

multipurpose rss reader, live stream, mashup, aggregation web application
https://selfoss.aditu.de
GNU General Public License v3.0
2.36k stars 343 forks source link

Filter by using Url #1202

Closed phicha20224 closed 2 years ago

phicha20224 commented 4 years ago

Thank you To. Mr Jan Tojnar

This code allow selfoss to filter keyword by using url http://www.domain.com/selfoss/#newest/all?search=[keyword]

--- a/assets/js/selfoss-events.js
+++ b/assets/js/selfoss-events.js
@@ -82,6 +82,9 @@ selfoss.events = {

         // assume the hash is encoded
         hash = decodeURIComponent(location.href.split('#').splice(1).join('#'));
+        let hashQs;
+        [ hash, ...hashQs ] = hash.split('?');
+        const hashParams = new URLSearchParams(hashQs.join('?'));

         if (!selfoss.events.reloadSamePath &&
             hash == selfoss.events.lasthash) {
@@ -158,6 +161,7 @@ selfoss.events = {
             selfoss.filter.type = selfoss.events.section;
             selfoss.filter.tag = '';
             selfoss.filter.source = '';
+            selfoss.filter.search = hashParams.get('search') || '';
             if (selfoss.events.subsection) {
                 selfoss.events.lastSubsection = selfoss.events.subsection;
                 if (selfoss.events.subsection.substr(0, 4) == 'tag-') {
jtojnar commented 2 years ago

Thanks, this was implemented in https://github.com/fossar/selfoss/pull/1216.