From e3a211e41c83abdd3c31ec35dfdcad6ea43a31ff Mon Sep 17 00:00:00 2001
From: Nikhil Tanwar <2002nikhiltanwar@gmail.com>
Date: Sun, 5 Feb 2023 17:27:49 +0530
Subject: [PATCH] Add RSS Feed extension in head
This change adds a element in the head node of welcome page.
Browsers with extensions for RSS will show a sign to navigate to the feed.
The link changes based on current set filters.
---
static/skin/index.js | 13 +++++++++++++
static/templates/index.html | 7 +++++++
test/server.cpp | 4 ++--
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/static/skin/index.js b/static/skin/index.js
index 7f29b316e..ec54a098a 100644
--- a/static/skin/index.js
+++ b/static/skin/index.js
@@ -18,6 +18,17 @@
let timer;
let languages = {};
+ function updateFeedLink() {
+ const inputParams = new URLSearchParams(window.location.search);
+ const filteredParams = new URLSearchParams();
+ for (const [key, value] of inputParams) {
+ if ( value != '' ) {
+ filteredParams.append(key, value);
+ }
+ }
+ document.querySelector('#feed_link').href = `${root}/catalog/v2/entries?${filteredParams.toString()}`;
+ }
+
function queryUrlBuilder() {
let url = `${root}/catalog/search?`;
url += Object.keys(incrementalLoadingParams).map(key => `${key}=${incrementalLoadingParams[key]}`).join("&");
@@ -363,6 +374,7 @@
setCookie(filterCookieName, params.toString());
}
updateFilterColors();
+ updateFeedLink();
await loadAndDisplayBooks(true);
}
@@ -492,6 +504,7 @@
langFilter.dispatchEvent(new Event('change'));
}
}
+ updateFeedLink();
setCookie(filterCookieName, params.toString());
}
})();
diff --git a/static/templates/index.html b/static/templates/index.html
index 2bd067a23..652bc69fb 100644
--- a/static/templates/index.html
+++ b/static/templates/index.html
@@ -10,6 +10,13 @@
href="{{root}}/skin/index.css?KIWIXCACHEID"
rel="Stylesheet"
/>
+
diff --git a/test/server.cpp b/test/server.cpp
index c99e960e9..6a660fe3a 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=0f9ba34e" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" },
- { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=2f5a81ac" },
+ { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=3f19d670" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" },
@@ -280,7 +280,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=0f9ba34e"
src: url("/ROOT%23%3F/skin/fonts/Roboto.ttf?cacheid=84d10248") format("truetype");
-
+
)EXPECTEDRESULT"
},
{