mirror of https://github.com/kiwix/libkiwix.git
+ template adaptation for using in kiwix-serve
This commit is contained in:
parent
8051ad4611
commit
4b5126ab75
|
@ -42,7 +42,9 @@ namespace kiwix {
|
|||
resultCountPerPage(0),
|
||||
estimatedResultCount(0),
|
||||
resultStart(0),
|
||||
resultEnd(0) {
|
||||
resultEnd(0),
|
||||
protocolPrefix("zim://"),
|
||||
searchProtocolPrefix("search://?") {
|
||||
}
|
||||
|
||||
/* Search strings in the database */
|
||||
|
@ -108,6 +110,16 @@ namespace kiwix {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Searcher::setProtocolPrefix(const std::string prefix) {
|
||||
this->protocolPrefix = prefix;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Searcher::setSearchProtocolPrefix(const std::string prefix) {
|
||||
this->searchProtocolPrefix = prefix;
|
||||
return true;
|
||||
}
|
||||
|
||||
string Searcher::getHtml() {
|
||||
|
||||
const STLW::string & sSourceFile = this->resultTemplatePath;
|
||||
|
@ -201,6 +213,8 @@ namespace kiwix {
|
|||
oData["searchPattern"] = this->searchPattern;
|
||||
oData["resultStart"] = this->resultStart;
|
||||
oData["resultEnd"] = (this->resultEnd > this->estimatedResultCount ? this->estimatedResultCount : this->resultEnd);
|
||||
oData["protocolPrefix"] = this->protocolPrefix;
|
||||
oData["searchProtocolPrefix"] = this->searchProtocolPrefix;
|
||||
|
||||
STLW::string sResult;
|
||||
StringOutputCollector oDataCollector(sResult);
|
||||
|
|
|
@ -70,6 +70,8 @@ namespace kiwix {
|
|||
bool getNextResult(string &url, string &title, unsigned int &score);
|
||||
unsigned int getEstimatedResultCount();
|
||||
bool setResultTemplatePath(const std::string path);
|
||||
bool setProtocolPrefix(const std::string prefix);
|
||||
bool setSearchProtocolPrefix(const std::string prefix);
|
||||
string getHtml();
|
||||
void reset();
|
||||
|
||||
|
@ -87,6 +89,8 @@ namespace kiwix {
|
|||
unsigned int estimatedResultCount;
|
||||
unsigned int resultStart;
|
||||
unsigned int resultEnd;
|
||||
std::string protocolPrefix;
|
||||
std::string searchProtocolPrefix;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
|
||||
<TMPL_loop results>
|
||||
<li>
|
||||
<a href="zim://<TMPL_var url>"><TMPL_var title></a>
|
||||
<a href="<TMPL_var protocolPrefix><TMPL_var url>"><TMPL_var title></a>
|
||||
<cite><TMPL_if snippet><TMPL_var snippet>...</TMPL_if></cite>
|
||||
<TMPL_if size><TMPL_if wordCount><div class="informations"><TMPL_var size> KB (<TMPL_var wordCount> words)</div></TMPL_if></TMPL_if>
|
||||
</li>
|
||||
|
@ -115,7 +115,7 @@
|
|||
<div class="footer">
|
||||
<ul>
|
||||
<TMPL_loop pages>
|
||||
<li><a <TMPL_if selected>class="selected"</TMPL_if> href="search://?pattern=<TMPL_var searchPattern>&start=<TMPL_var start>&end=<TMPL_var end>"><TMPL_var label></a></li>
|
||||
<li><a <TMPL_if selected>class="selected"</TMPL_if> href="<TMPL_var searchProtocolPrefix>pattern=<TMPL_var searchPattern>&start=<TMPL_var start>&end=<TMPL_var end>"><TMPL_var label></a></li>
|
||||
</TMPL_LOOP>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue