mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-28 05:49:35 +00:00
Make the search_rendered handle multizim search.
This introduce a intermediate mustache object to store information about the request made by the user.
This commit is contained in:
@ -71,9 +71,9 @@ void SearchRenderer::setSearchPattern(const std::string& pattern)
|
||||
searchPattern = pattern;
|
||||
}
|
||||
|
||||
void SearchRenderer::setSearchContent(const std::string& content)
|
||||
void SearchRenderer::setSearchBookIds(const std::set<std::string>& bookIds)
|
||||
{
|
||||
searchContent = content;
|
||||
searchBookIds = bookIds;
|
||||
}
|
||||
|
||||
void SearchRenderer::setProtocolPrefix(const std::string& prefix)
|
||||
@ -90,13 +90,15 @@ kainjow::mustache::data buildQueryData
|
||||
(
|
||||
const std::string& searchProtocolPrefix,
|
||||
const std::string& pattern,
|
||||
const std::string& searchContent
|
||||
const std::set<std::string>& bookIds
|
||||
) {
|
||||
kainjow::mustache::data query;
|
||||
query.set("pattern", kiwix::encodeDiples(pattern));
|
||||
std::ostringstream ss;
|
||||
ss << searchProtocolPrefix << "?pattern=" << urlEncode(pattern, true);
|
||||
ss << "&content=" << urlEncode(searchContent, true);
|
||||
for (auto& bookId: bookIds) {
|
||||
ss << "&books.id="<<urlEncode(bookId, true);
|
||||
}
|
||||
query.set("unpaginatedQuery", ss.str());
|
||||
return query;
|
||||
}
|
||||
@ -197,7 +199,7 @@ std::string SearchRenderer::getHtml()
|
||||
kainjow::mustache::data query = buildQueryData(
|
||||
searchProtocolPrefix,
|
||||
searchPattern,
|
||||
searchContent
|
||||
searchBookIds
|
||||
);
|
||||
|
||||
std::string template_str = RESOURCE::templates::search_result_html;
|
||||
|
Reference in New Issue
Block a user