From 4b5126ab754f4f773a5e55b2ae84ca6ff3f8ea54 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Fri, 8 Apr 2011 14:12:39 +0000 Subject: [PATCH] + template adaptation for using in kiwix-serve --- src/common/kiwix/searcher.cpp | 16 +++++++++++++++- src/common/kiwix/searcher.h | 4 ++++ static/results.tmpl | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/kiwix/searcher.cpp b/src/common/kiwix/searcher.cpp index 1a548ca4e..8e2912492 100644 --- a/src/common/kiwix/searcher.cpp +++ b/src/common/kiwix/searcher.cpp @@ -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); diff --git a/src/common/kiwix/searcher.h b/src/common/kiwix/searcher.h index bffe00ce4..1ed7afaa3 100644 --- a/src/common/kiwix/searcher.h +++ b/src/common/kiwix/searcher.h @@ -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; }; } diff --git a/static/results.tmpl b/static/results.tmpl index 7dccca558..f94baef41 100644 --- a/static/results.tmpl +++ b/static/results.tmpl @@ -104,7 +104,7 @@
  • - + ...
    KB ( words)
  • @@ -115,7 +115,7 @@