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 1/2] 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" }, { From 6b8f9aa6ab8121483d8789b6dd540d02bc88fb50 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Mon, 6 Feb 2023 05:41:29 +0530 Subject: [PATCH 2/2] Add specific link for Kiwix RSS Feed Added an image of rss logo on the welcome page which links to the RSS feed with current filters --- static/resources_list.txt | 1 + static/skin/feed.png | Bin 0 -> 497 bytes static/skin/index.css | 11 +++++++++++ static/skin/index.js | 4 +++- static/templates/index.html | 5 ++++- test/server.cpp | 9 +++++---- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 static/skin/feed.png diff --git a/static/resources_list.txt b/static/resources_list.txt index cf11aa3d8..4d48e7287 100644 --- a/static/resources_list.txt +++ b/static/resources_list.txt @@ -1,6 +1,7 @@ skin/caret.png skin/bittorrent.png skin/magnet.png +skin/feed.png skin/download.png skin/hash.png skin/search-icon.svg diff --git a/static/skin/feed.png b/static/skin/feed.png new file mode 100644 index 0000000000000000000000000000000000000000..5176e7bf6dcc99240e2d9e40881feb0107075aad GIT binary patch literal 497 zcmV`2Y9t{Mfnt(ysZXUHP3(_>egGjx+x0 z*ZaPS`l@F6sbl~B`u_6h{_WoW?A-m}$NR&Q`@oL<-oyI2fcTU@_lqz7@8bN`v;5Dg z{LQ8Mvv&HeZ1|W&{p8R5*0uV&gZj36_?Sodm`1a}db9ul0U}96K~yNuwUO7Ff+OW%GAftOP4e+4CnrI?{Fx>RV2zSp`Bv*B0?)BD)Z3(1Xkry} zg)B_0VlD`NA9<14e(8<{`|AS+Kyhg8M}dr<6+m>&j`_CMIc1kD?|Ab_4m{JZQmIeJ zAS9r-UDm&1i4T+OAAp)I`+JAhJ-N>Lgq#JmnBAT}yn%af0=;CVLR-I&?A^d~AmU7# zn!VX|sixN4?%;0kBw&6fbVn7frT55*1ro{fs?Aa{O>Q(fdv02Yaq2}NbeHOA3@(qy zwlYRss`w49sW1Z{i=>R`I5d= nm&<)$E`BR$E+wKly!`zE1=9`MiO9AO00000NkvXXu0mjfJ--S+ literal 0 HcmV?d00001 diff --git a/static/skin/index.css b/static/skin/index.css index f6e16be20..ae9294fa2 100644 --- a/static/skin/index.css +++ b/static/skin/index.css @@ -441,6 +441,13 @@ body { width: auto; } +.feedLogo { + margin: 16px 12px 0 0; + height: 30px; + float: right; + border-radius: 5px; +} + @media screen and (max-width: 1100px) { .kiwixHomeBody { @@ -482,4 +489,8 @@ body { .kiwixNav__filters { grid-template-columns: 1fr; } + + .feedLogo { + display: none; + } } diff --git a/static/skin/index.js b/static/skin/index.js index ec54a098a..036e18516 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -26,7 +26,9 @@ filteredParams.append(key, value); } } - document.querySelector('#feed_link').href = `${root}/catalog/v2/entries?${filteredParams.toString()}`; + const feedLink = `${root}/catalog/v2/entries?${filteredParams.toString()}`; + document.querySelector('#headFeedLink').href = feedLink; + document.querySelector('#feedLink').href = feedLink; } function queryUrlBuilder() { diff --git a/static/templates/index.html b/static/templates/index.html index 652bc69fb..0274e9a3a 100644 --- a/static/templates/index.html +++ b/static/templates/index.html @@ -14,7 +14,7 @@ rel="alternate" type="application/atom+xml" title="Library OPDS Feed" - id="feed_link" + id="headFeedLink" href="{{root}}/catalog/v2/entries" /> @@ -42,6 +42,9 @@ + + +
diff --git a/test/server.cpp b/test/server.cpp index 6a660fe3a..00519fbf9 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -61,9 +61,9 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/i18n.js" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/i18n.js?cacheid=6da2bca0" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" }, - { STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=0f9ba34e" }, + { STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=316dbc21" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" }, - { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=3f19d670" }, + { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=b0cc9d6b" }, { 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" }, @@ -268,7 +268,7 @@ TEST_F(ServerTest, CacheIdsOfStaticResources) const std::vector testData{ { /* url */ "/ROOT%23%3F/", -R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=0f9ba34e" +R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=316dbc21" @@ -280,7 +280,8 @@ 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" }, {