From 951e15c665d3bf5ca0439c5999a339337cd38d57 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Mon, 27 Feb 2023 23:54:53 +0530 Subject: [PATCH] No results display in /nojs Shows a link to reset filter if there are no books. --- src/html_dumper.cpp | 4 +++- static/skin/i18n/en.json | 2 +- static/skin/i18n/test.json | 2 +- static/skin/index.js | 2 +- static/templates/no_js_library_page.html | 18 ++++++++++++++++++ test/server.cpp | 4 ++-- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/html_dumper.cpp b/src/html_dumper.cpp index a50315bd8..4896821bf 100644 --- a/src/html_dumper.cpp +++ b/src/html_dumper.cpp @@ -99,7 +99,8 @@ std::string HTMLDumper::dumpPlainHTML(kiwix::Filter filter) const getTranslation("book-filtering-all-languages"), getTranslation("powered-by-kiwix-html"), getTranslation("welcome-to-kiwix-server"), - getTranslation("preview-book") + getTranslation("preview-book"), + getTranslation("welcome-page-overzealous-filter", {{"URL", "?lang="}}) }; return render_template( @@ -110,6 +111,7 @@ std::string HTMLDumper::dumpPlainHTML(kiwix::Filter filter) const {"searchQuery", searchQuery}, {"languages", languages}, {"categories", categories}, + {"noResults", filteredBooks.size() == 0}, {"translations", translations} } ); diff --git a/static/skin/i18n/en.json b/static/skin/i18n/en.json index e8a3d26b1..aaea04978 100644 --- a/static/skin/i18n/en.json +++ b/static/skin/i18n/en.json @@ -28,7 +28,7 @@ , "random-page-button-text": "Go to a randomly selected page" , "searchbox-tooltip": "Search '{{BOOK_TITLE}}'" , "confusion-of-tongues": "Two or more books in different languages would participate in search, which may lead to confusing results." - , "welcome-page-overzealous-filter": "No result. Would you like to reset filter?" + , "welcome-page-overzealous-filter": "No result. Would you like to reset filter?" , "powered-by-kiwix-html": "Powered by Kiwix" , "search": "Search" , "book-filtering-all-categories": "All categories" diff --git a/static/skin/i18n/test.json b/static/skin/i18n/test.json index c48c181a9..7686471ab 100644 --- a/static/skin/i18n/test.json +++ b/static/skin/i18n/test.json @@ -17,7 +17,7 @@ , "home-button-text": "[I18N TESTING] Jump to the main page of '{{BOOK_TITLE}}'" , "random-page-button-text": "[I18N TESTING] I am tired of determinism" , "searchbox-tooltip": "[I18N TESTING] Let's search in '{{BOOK_TITLE}}'" - , "welcome-page-overzealous-filter": "[I18N TESTING] Nothing found. Reset filter" + , "welcome-page-overzealous-filter": "[I18N TESTING] Nothing found. Reset filter" , "powered-by-kiwix-html": "[I18N TESTING] Powered by Kiwix (nominal power: 1.23 kW)" , "search": "[I18N Search TESTING]" , "book-filtering-all-categories": "All [I18N TESTING] categories" diff --git a/static/skin/index.js b/static/skin/index.js index 1f3bd448b..43854ba97 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -315,7 +315,7 @@ const kiwixHomeBody = document.querySelector('.kiwixHomeBody'); const divTag = document.createElement('div'); divTag.setAttribute('class', 'noResults'); - divTag.innerHTML = $t("welcome-page-overzealous-filter"); + divTag.innerHTML = $t("welcome-page-overzealous-filter", {URL: '#lang='}); kiwixHomeBody.append(divTag); kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center'); loader.setAttribute('style', 'position: absolute; top: 50%'); diff --git a/static/templates/no_js_library_page.html b/static/templates/no_js_library_page.html index 728eb251f..edab66fc6 100644 --- a/static/templates/no_js_library_page.html +++ b/static/templates/no_js_library_page.html @@ -90,6 +90,24 @@