Merge pull request #99 from kiwix/better_search_result_html

Better search result html
This commit is contained in:
Matthieu Gautier 2017-11-27 12:46:17 +00:00 committed by GitHub
commit 281b136ea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -56,7 +56,7 @@ struct SearcherInternal;
class Searcher
{
public:
Searcher();
Searcher(const string& humanReadableName = "");
Searcher(const string& xapianDirectoryPath,
Reader* reader,
const string& humanReadableName);

View File

@ -17,6 +17,9 @@
* MA 02110-1301, USA.
*/
#include <cmath>
#include "searcher.h"
#include "kiwixlib-resources.h"
#include "reader.h"
@ -85,17 +88,17 @@ Searcher::Searcher(const string& xapianDirectoryPath,
resultCountPerPage(0),
estimatedResultCount(0),
resultStart(0),
resultEnd(0)
resultEnd(0),
contentHumanReadableId(humanReadableName)
{
loadICUExternalTables();
if (!reader || !reader->hasFulltextIndex()) {
internal->_xapianSearcher = new XapianSearcher(xapianDirectoryPath, reader);
}
this->contentHumanReadableId = humanReadableName;
this->humanReaderNames.push_back(humanReadableName);
}
Searcher::Searcher()
Searcher::Searcher(const std::string& humanReadableName)
: internal(new SearcherInternal()),
searchPattern(""),
protocolPrefix("zim://"),
@ -103,7 +106,8 @@ Searcher::Searcher()
resultCountPerPage(0),
estimatedResultCount(0),
resultStart(0),
resultEnd(0)
resultEnd(0),
contentHumanReadableId(humanReadableName)
{
loadICUExternalTables();
}
@ -431,7 +435,7 @@ string Searcher::getHtml()
oData["resultRange"] = this->resultCountPerPage;
oData["resultLastPageStart"]
= this->estimatedResultCount > this->resultCountPerPage
? this->estimatedResultCount - this->resultCountPerPage
? std::round(this->estimatedResultCount / this->resultCountPerPage) * this->resultCountPerPage
: 0;
oData["protocolPrefix"] = this->protocolPrefix;
oData["searchProtocolPrefix"] = this->searchProtocolPrefix;