Merge pull request #765 from kiwix/unittests_for_search_results_page

This commit is contained in:
Matthieu Gautier 2022-05-23 10:55:28 +02:00 committed by GitHub
commit ff2c7b1fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1188 additions and 9 deletions

View File

@ -150,7 +150,7 @@ std::string SearchRenderer::getHtml()
allData.set("results", results); allData.set("results", results);
allData.set("pages", pages); allData.set("pages", pages);
allData.set("hasResults", estimatedResultCount != 0); allData.set("hasResults", estimatedResultCount != 0);
allData.set("hasPages", pageStart != pageEnd); allData.set("hasPages", pageStart + 1 < pageEnd);
allData.set("count", kiwix::beautifyInteger(estimatedResultCount)); allData.set("count", kiwix::beautifyInteger(estimatedResultCount));
allData.set("searchPattern", kiwix::encodeDiples(this->searchPattern)); allData.set("searchPattern", kiwix::encodeDiples(this->searchPattern));
allData.set("searchPatternEncoded", urlEncode(this->searchPattern)); allData.set("searchPatternEncoded", urlEncode(this->searchPattern));

View File

@ -2,6 +2,12 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" /> <meta content="text/html; charset=utf-8" http-equiv="content-type" />
{{!
The inline CSS below can be extracted into a standalone CSS resource
ONLY IF all clients of kiwix::SearchRenderer are required to provide
access to resources compiled into libkiwix.
}}
<style type="text/css"> <style type="text/css">
body{ body{
color: #000000; color: #000000;
@ -141,7 +147,8 @@
<ul> <ul>
{{#resultLastPageStart}} {{#resultLastPageStart}}
<li> <li>
<a href="{{searchProtocolPrefix}}pattern={{searchPatternEncoded}}{{#contentId}}&content={{.}}{{/contentId}}&start=0&pageLength={{pageLength}}"> <a {{! let the format of this tag be identical to the case below }}
href="{{searchProtocolPrefix}}pattern={{searchPatternEncoded}}{{#contentId}}&content={{.}}{{/contentId}}&start=0&pageLength={{pageLength}}">
</a> </a>
</li> </li>
@ -156,7 +163,8 @@
{{/pages}} {{/pages}}
{{#resultLastPageStart}} {{#resultLastPageStart}}
<li> <li>
<a href="{{searchProtocolPrefix}}pattern={{searchPatternEncoded}}{{#contentId}}&content={{.}}{{/contentId}}&start={{resultLastPageStart}}&pageLength={{pageLength}}"> <a {{! let the format of this tag be identical to the case above }}
href="{{searchProtocolPrefix}}pattern={{searchPatternEncoded}}{{#contentId}}&content={{.}}{{/contentId}}&start={{resultLastPageStart}}&pageLength={{pageLength}}">
</a> </a>
</li> </li>

File diff suppressed because it is too large Load Diff