diff --git a/src/common/kiwix/searcher.cpp b/src/common/kiwix/searcher.cpp index 4c31a76a7..360b7ceac 100644 --- a/src/common/kiwix/searcher.cpp +++ b/src/common/kiwix/searcher.cpp @@ -37,7 +37,6 @@ namespace kiwix { /* Constructor */ Searcher::Searcher() : - resultTemplatePath(""), searchPattern(""), resultCountPerPage(0), estimatedResultCount(0), @@ -106,11 +105,6 @@ namespace kiwix { return retVal; } - bool Searcher::setResultTemplatePath(const std::string path) { - this->resultTemplatePath = path; - return true; - } - bool Searcher::setProtocolPrefix(const std::string prefix) { this->protocolPrefix = prefix; return true; @@ -127,7 +121,6 @@ namespace kiwix { string Searcher::getHtml() { - const STLW::string & sSourceFile = this->resultTemplatePath; VMOpcodeCollector oVMOpcodeCollector; StaticText oSyscalls; StaticData oStaticData; @@ -135,14 +128,15 @@ namespace kiwix { HashTable oHashTable; CTPP2Compiler oCompiler(oVMOpcodeCollector, oSyscalls, oStaticData, oStaticText, oHashTable); - // Load template - CTPP2FileSourceLoader oSourceLoader; + // Load template & create template parser + //cout << getResourceAsString("results.tmpl") << endl; + + + /* Parse template */ + const STLW::string & sSourceFile = getResourceAsString("results.tmpl"); + CTPP2TextLoader oSourceLoader; oSourceLoader.LoadTemplate(sSourceFile.c_str()); - - // Create template parser - CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, sSourceFile); - - // Compile template + CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, "template"); oCTPP2Parser.Compile(); // Get program core diff --git a/src/common/kiwix/searcher.h b/src/common/kiwix/searcher.h index dba32a902..8c7e27fcc 100644 --- a/src/common/kiwix/searcher.h +++ b/src/common/kiwix/searcher.h @@ -32,9 +32,11 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -69,7 +71,6 @@ namespace kiwix { const unsigned int resultEnd, const bool verbose=false); 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(); @@ -84,7 +85,6 @@ namespace kiwix { std::vector results; std::vector::iterator resultOffset; - std::string resultTemplatePath; std::string searchPattern; unsigned int resultCountPerPage; unsigned int estimatedResultCount;