From 2736a46cfe0333ba332c7cbaa6b2c04c6b1a0fee Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 25 May 2021 17:30:05 +0200 Subject: [PATCH] Revert "Kiwix Serve welcome page dynamic and subset loading (OPDS based)" --- .gitignore | 1 - src/server/internalServer.cpp | 2 +- static/resources_list.txt | 1 - static/skin/index.js | 76 ----------------- static/templates/index.html | 154 ++++++++++++++-------------------- 5 files changed, 63 insertions(+), 171 deletions(-) delete mode 100644 static/skin/index.js diff --git a/.gitignore b/.gitignore index 4f46d8e43..1a8f75003 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ subprojects/googletest-release* *.class build/ .vscode/ -builddir/ diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 3d9739f63..f28c3df03 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -658,7 +658,7 @@ std::vector InternalServer::search_catalog(const RequestContext& request, kiwix::OPDSDumper& opdsDumper) { - auto filter = kiwix::Filter().valid(true).local(true); + auto filter = kiwix::Filter().valid(true).local(true).remote(true); string query(""); size_t count(10); size_t startIndex(0); diff --git a/static/resources_list.txt b/static/resources_list.txt index 6c0570442..d31c323ba 100644 --- a/static/resources_list.txt +++ b/static/resources_list.txt @@ -19,7 +19,6 @@ skin/jquery-ui/jquery-ui.theme.min.css skin/jquery-ui/jquery-ui.min.css skin/caret.png skin/taskbar.js -skin/index.js skin/taskbar.css skin/block_external.js templates/search_result.html diff --git a/static/skin/index.js b/static/skin/index.js deleted file mode 100644 index 1865c65b6..000000000 --- a/static/skin/index.js +++ /dev/null @@ -1,76 +0,0 @@ -(function() { - const root = $(`link[type='root']`).attr('href'); - let isFetching = false; - const incrementalLoadingParams = { - start: 0, - count: viewPortToCount() - }; - - function queryUrlBuilder() { - let url = `${root}/catalog/search?`; - url += Object.keys(incrementalLoadingParams).map(key => `${key}=${incrementalLoadingParams[key]}`).join("&"); - return url; - } - - function viewPortToCount(){ - return Math.floor(window.innerHeight/100 + 1)*(window.innerWidth>1000 ? 3 : 2); - } - - function getInnerHtml(node, query) { - return node.querySelector(query).innerHTML; - } - - function generateBookHtml(book) { - const link = book.querySelector('link').getAttribute('href'); - const title = getInnerHtml(book, 'title'); - const description = getInnerHtml(book, 'summary'); - const id = getInnerHtml(book, 'id'); - const iconUrl = getInnerHtml(book, 'icon'); - const articleCount = getInnerHtml(book, 'articleCount'); - const mediaCount = getInnerHtml(book, 'mediaCount'); - - return `
-
-
${title}
-
${description}
-
${articleCount} articles, ${mediaCount} medias
-
-
`; - } - - async function loadAndDisplayBooks() { - isFetching = true; - fetch(queryUrlBuilder()).then(async (resp) => { - const data = new window.DOMParser().parseFromString(await resp.text(), 'application/xml'); - const books = data.querySelectorAll('entry'); - let bookHtml = ''; - books.forEach((book) => {bookHtml += generateBookHtml(book)}); - document.querySelector('.book__list').innerHTML += bookHtml; - incrementalLoadingParams.start += books.length; - if (books.length < incrementalLoadingParams.count) { - incrementalLoadingParams.count = 0; - } - isFetching = false; - }); - } - - async function loadSubset() { - if (!isFetching && - incrementalLoadingParams.count && - window.innerHeight + window.scrollY >= document.body.offsetHeight - ) { - loadAndDisplayBooks(); - } - } - - window.addEventListener('resize', async () => { - incrementalLoadingParams.count = incrementalLoadingParams.count && viewPortToCount(); - loadSubset(); - }); - - window.addEventListener('scroll', loadSubset); - - window.onload = async () => { - loadAndDisplayBooks(); - } -})(); diff --git a/static/templates/index.html b/static/templates/index.html index 09ac8068c..dc355aa63 100644 --- a/static/templates/index.html +++ b/static/templates/index.html @@ -1,96 +1,66 @@ - - - Welcome to Kiwix Server - - - - - - - - -
-
-
+ + + Welcome to Kiwix Server + + + + + + + + -
Powered by Kiwix
- + + +
+ Powered by Kiwix +
+ +