No results display in /nojs

Shows a link to reset filter if there are no books.
This commit is contained in:
Nikhil Tanwar 2023-02-27 23:54:53 +05:30
parent cc35fe503f
commit 951e15c665
6 changed files with 26 additions and 6 deletions

View File

@ -99,7 +99,8 @@ std::string HTMLDumper::dumpPlainHTML(kiwix::Filter filter) const
getTranslation("book-filtering-all-languages"), getTranslation("book-filtering-all-languages"),
getTranslation("powered-by-kiwix-html"), getTranslation("powered-by-kiwix-html"),
getTranslation("welcome-to-kiwix-server"), getTranslation("welcome-to-kiwix-server"),
getTranslation("preview-book") getTranslation("preview-book"),
getTranslation("welcome-page-overzealous-filter", {{"URL", "?lang="}})
}; };
return render_template( return render_template(
@ -110,6 +111,7 @@ std::string HTMLDumper::dumpPlainHTML(kiwix::Filter filter) const
{"searchQuery", searchQuery}, {"searchQuery", searchQuery},
{"languages", languages}, {"languages", languages},
{"categories", categories}, {"categories", categories},
{"noResults", filteredBooks.size() == 0},
{"translations", translations} {"translations", translations}
} }
); );

View File

@ -28,7 +28,7 @@
, "random-page-button-text": "Go to a randomly selected page" , "random-page-button-text": "Go to a randomly selected page"
, "searchbox-tooltip": "Search '{{BOOK_TITLE}}'" , "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." , "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 <a href=\"#lang=\">reset filter</a>?" , "welcome-page-overzealous-filter": "No result. Would you like to <a href=\"{{URL}}\">reset filter</a>?"
, "powered-by-kiwix-html": "Powered by&nbsp;<a href=\"https://kiwix.org\">Kiwix</a>" , "powered-by-kiwix-html": "Powered by&nbsp;<a href=\"https://kiwix.org\">Kiwix</a>"
, "search": "Search" , "search": "Search"
, "book-filtering-all-categories": "All categories" , "book-filtering-all-categories": "All categories"

View File

@ -17,7 +17,7 @@
, "home-button-text": "[I18N TESTING] Jump to the main page of '{{BOOK_TITLE}}'" , "home-button-text": "[I18N TESTING] Jump to the main page of '{{BOOK_TITLE}}'"
, "random-page-button-text": "[I18N TESTING] I am tired of determinism" , "random-page-button-text": "[I18N TESTING] I am tired of determinism"
, "searchbox-tooltip": "[I18N TESTING] Let's search in '{{BOOK_TITLE}}'" , "searchbox-tooltip": "[I18N TESTING] Let's search in '{{BOOK_TITLE}}'"
, "welcome-page-overzealous-filter": "[I18N TESTING] Nothing found. <a href=\"?lang=\">Reset filter</a>" , "welcome-page-overzealous-filter": "[I18N TESTING] Nothing found. <a href=\"{{URL}}\">Reset filter</a>"
, "powered-by-kiwix-html": "[I18N TESTING] Powered by&nbsp;<a href=\"https://kiwix.org\">Kiwix</a> (nominal power: 1.23 kW)" , "powered-by-kiwix-html": "[I18N TESTING] Powered by&nbsp;<a href=\"https://kiwix.org\">Kiwix</a> (nominal power: 1.23 kW)"
, "search": "[I18N Search TESTING]" , "search": "[I18N Search TESTING]"
, "book-filtering-all-categories": "All [I18N TESTING] categories" , "book-filtering-all-categories": "All [I18N TESTING] categories"

View File

@ -315,7 +315,7 @@
const kiwixHomeBody = document.querySelector('.kiwixHomeBody'); const kiwixHomeBody = document.querySelector('.kiwixHomeBody');
const divTag = document.createElement('div'); const divTag = document.createElement('div');
divTag.setAttribute('class', 'noResults'); divTag.setAttribute('class', 'noResults');
divTag.innerHTML = $t("welcome-page-overzealous-filter"); divTag.innerHTML = $t("welcome-page-overzealous-filter", {URL: '#lang='});
kiwixHomeBody.append(divTag); kiwixHomeBody.append(divTag);
kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center'); kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center');
loader.setAttribute('style', 'position: absolute; top: 50%'); loader.setAttribute('style', 'position: absolute; top: 50%');

View File

@ -90,6 +90,24 @@
</form> </form>
</div> </div>
<div class="kiwixHomeBody"> <div class="kiwixHomeBody">
{{#noResults}}
<style>
.book__list {
display: none;
}
.kiwixHomeBody {
justify-content: center;
}
.noResults {
font-size: 16px;
font-family: roboto;
}
</style>
<div class="noResults">
{{{translations.welcome-page-overzealous-filter}}}
</div>
</style>
{{/noResults}}
<div class="book__list"> <div class="book__list">
<h3 class="kiwixHomeBody__results">{{translations.count-of-matching-books}}</h3> <h3 class="kiwixHomeBody__results">{{translations.count-of-matching-books}}</h3>
{{#books}} {{#books}}

View File

@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=e4d76d16" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=e4d76d16" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=78cfd6a2" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=d38d9ef1" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" },
@ -284,7 +284,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=e4d76d16"
<script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=b00b12db" defer></script> <script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=b00b12db" defer></script>
<script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script> <script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
<script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script> <script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
<script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=78cfd6a2" defer></script> <script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=d38d9ef1" defer></script>
<img src="/ROOT%23%3F/skin/feed.svg?cacheid=055b333f" <img src="/ROOT%23%3F/skin/feed.svg?cacheid=055b333f"
<img src="/ROOT%23%3F/skin/langSelector.svg?cacheid=00b59961" <img src="/ROOT%23%3F/skin/langSelector.svg?cacheid=00b59961"
)EXPECTEDRESULT" )EXPECTEDRESULT"