mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #99 from kiwix/better_search_result_html
Better search result html
This commit is contained in:
commit
281b136ea8
|
@ -56,7 +56,7 @@ struct SearcherInternal;
|
||||||
class Searcher
|
class Searcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Searcher();
|
Searcher(const string& humanReadableName = "");
|
||||||
Searcher(const string& xapianDirectoryPath,
|
Searcher(const string& xapianDirectoryPath,
|
||||||
Reader* reader,
|
Reader* reader,
|
||||||
const string& humanReadableName);
|
const string& humanReadableName);
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
* MA 02110-1301, USA.
|
* MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "searcher.h"
|
#include "searcher.h"
|
||||||
#include "kiwixlib-resources.h"
|
#include "kiwixlib-resources.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
|
@ -85,17 +88,17 @@ Searcher::Searcher(const string& xapianDirectoryPath,
|
||||||
resultCountPerPage(0),
|
resultCountPerPage(0),
|
||||||
estimatedResultCount(0),
|
estimatedResultCount(0),
|
||||||
resultStart(0),
|
resultStart(0),
|
||||||
resultEnd(0)
|
resultEnd(0),
|
||||||
|
contentHumanReadableId(humanReadableName)
|
||||||
{
|
{
|
||||||
loadICUExternalTables();
|
loadICUExternalTables();
|
||||||
if (!reader || !reader->hasFulltextIndex()) {
|
if (!reader || !reader->hasFulltextIndex()) {
|
||||||
internal->_xapianSearcher = new XapianSearcher(xapianDirectoryPath, reader);
|
internal->_xapianSearcher = new XapianSearcher(xapianDirectoryPath, reader);
|
||||||
}
|
}
|
||||||
this->contentHumanReadableId = humanReadableName;
|
|
||||||
this->humanReaderNames.push_back(humanReadableName);
|
this->humanReaderNames.push_back(humanReadableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Searcher::Searcher()
|
Searcher::Searcher(const std::string& humanReadableName)
|
||||||
: internal(new SearcherInternal()),
|
: internal(new SearcherInternal()),
|
||||||
searchPattern(""),
|
searchPattern(""),
|
||||||
protocolPrefix("zim://"),
|
protocolPrefix("zim://"),
|
||||||
|
@ -103,7 +106,8 @@ Searcher::Searcher()
|
||||||
resultCountPerPage(0),
|
resultCountPerPage(0),
|
||||||
estimatedResultCount(0),
|
estimatedResultCount(0),
|
||||||
resultStart(0),
|
resultStart(0),
|
||||||
resultEnd(0)
|
resultEnd(0),
|
||||||
|
contentHumanReadableId(humanReadableName)
|
||||||
{
|
{
|
||||||
loadICUExternalTables();
|
loadICUExternalTables();
|
||||||
}
|
}
|
||||||
|
@ -431,7 +435,7 @@ string Searcher::getHtml()
|
||||||
oData["resultRange"] = this->resultCountPerPage;
|
oData["resultRange"] = this->resultCountPerPage;
|
||||||
oData["resultLastPageStart"]
|
oData["resultLastPageStart"]
|
||||||
= this->estimatedResultCount > this->resultCountPerPage
|
= this->estimatedResultCount > this->resultCountPerPage
|
||||||
? this->estimatedResultCount - this->resultCountPerPage
|
? std::round(this->estimatedResultCount / this->resultCountPerPage) * this->resultCountPerPage
|
||||||
: 0;
|
: 0;
|
||||||
oData["protocolPrefix"] = this->protocolPrefix;
|
oData["protocolPrefix"] = this->protocolPrefix;
|
||||||
oData["searchProtocolPrefix"] = this->searchProtocolPrefix;
|
oData["searchProtocolPrefix"] = this->searchProtocolPrefix;
|
||||||
|
|
Loading…
Reference in New Issue