mirror of https://github.com/kiwix/libkiwix.git
+ replace in the searcher the usage of dynamic loaded template file by the usage of a resource
This commit is contained in:
parent
359f386ebe
commit
040ace5091
|
@ -37,7 +37,6 @@ namespace kiwix {
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
Searcher::Searcher() :
|
Searcher::Searcher() :
|
||||||
resultTemplatePath(""),
|
|
||||||
searchPattern(""),
|
searchPattern(""),
|
||||||
resultCountPerPage(0),
|
resultCountPerPage(0),
|
||||||
estimatedResultCount(0),
|
estimatedResultCount(0),
|
||||||
|
@ -106,11 +105,6 @@ namespace kiwix {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Searcher::setResultTemplatePath(const std::string path) {
|
|
||||||
this->resultTemplatePath = path;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Searcher::setProtocolPrefix(const std::string prefix) {
|
bool Searcher::setProtocolPrefix(const std::string prefix) {
|
||||||
this->protocolPrefix = prefix;
|
this->protocolPrefix = prefix;
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,7 +121,6 @@ namespace kiwix {
|
||||||
|
|
||||||
string Searcher::getHtml() {
|
string Searcher::getHtml() {
|
||||||
|
|
||||||
const STLW::string & sSourceFile = this->resultTemplatePath;
|
|
||||||
VMOpcodeCollector oVMOpcodeCollector;
|
VMOpcodeCollector oVMOpcodeCollector;
|
||||||
StaticText oSyscalls;
|
StaticText oSyscalls;
|
||||||
StaticData oStaticData;
|
StaticData oStaticData;
|
||||||
|
@ -135,14 +128,15 @@ namespace kiwix {
|
||||||
HashTable oHashTable;
|
HashTable oHashTable;
|
||||||
CTPP2Compiler oCompiler(oVMOpcodeCollector, oSyscalls, oStaticData, oStaticText, oHashTable);
|
CTPP2Compiler oCompiler(oVMOpcodeCollector, oSyscalls, oStaticData, oStaticText, oHashTable);
|
||||||
|
|
||||||
// Load template
|
// Load template & create template parser
|
||||||
CTPP2FileSourceLoader oSourceLoader;
|
//cout << getResourceAsString("results.tmpl") << endl;
|
||||||
|
|
||||||
|
|
||||||
|
/* Parse template */
|
||||||
|
const STLW::string & sSourceFile = getResourceAsString("results.tmpl");
|
||||||
|
CTPP2TextLoader oSourceLoader;
|
||||||
oSourceLoader.LoadTemplate(sSourceFile.c_str());
|
oSourceLoader.LoadTemplate(sSourceFile.c_str());
|
||||||
|
CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, "template");
|
||||||
// Create template parser
|
|
||||||
CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, sSourceFile);
|
|
||||||
|
|
||||||
// Compile template
|
|
||||||
oCTPP2Parser.Compile();
|
oCTPP2Parser.Compile();
|
||||||
|
|
||||||
// Get program core
|
// Get program core
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unaccent.h>
|
#include <unaccent.h>
|
||||||
|
#include <resourceTools.h>
|
||||||
|
|
||||||
#include <CTPP2Parser.hpp>
|
#include <CTPP2Parser.hpp>
|
||||||
#include <CTPP2FileSourceLoader.hpp>
|
#include <CTPP2FileSourceLoader.hpp>
|
||||||
|
#include <CTPP2TextLoader.hpp>
|
||||||
#include <CTPP2ParserException.hpp>
|
#include <CTPP2ParserException.hpp>
|
||||||
#include <CTPP2HashTable.hpp>
|
#include <CTPP2HashTable.hpp>
|
||||||
#include <CTPP2VMDumper.hpp>
|
#include <CTPP2VMDumper.hpp>
|
||||||
|
@ -69,7 +71,6 @@ namespace kiwix {
|
||||||
const unsigned int resultEnd, const bool verbose=false);
|
const unsigned int resultEnd, const bool verbose=false);
|
||||||
bool getNextResult(string &url, string &title, unsigned int &score);
|
bool getNextResult(string &url, string &title, unsigned int &score);
|
||||||
unsigned int getEstimatedResultCount();
|
unsigned int getEstimatedResultCount();
|
||||||
bool setResultTemplatePath(const std::string path);
|
|
||||||
bool setProtocolPrefix(const std::string prefix);
|
bool setProtocolPrefix(const std::string prefix);
|
||||||
bool setSearchProtocolPrefix(const std::string prefix);
|
bool setSearchProtocolPrefix(const std::string prefix);
|
||||||
string getHtml();
|
string getHtml();
|
||||||
|
@ -84,7 +85,6 @@ namespace kiwix {
|
||||||
|
|
||||||
std::vector<Result> results;
|
std::vector<Result> results;
|
||||||
std::vector<Result>::iterator resultOffset;
|
std::vector<Result>::iterator resultOffset;
|
||||||
std::string resultTemplatePath;
|
|
||||||
std::string searchPattern;
|
std::string searchPattern;
|
||||||
unsigned int resultCountPerPage;
|
unsigned int resultCountPerPage;
|
||||||
unsigned int estimatedResultCount;
|
unsigned int estimatedResultCount;
|
||||||
|
|
Loading…
Reference in New Issue