mirror of https://github.com/kiwix/libkiwix.git
kiwix::Suggestions gives up its temporary pedigree
This commit is contained in:
parent
abcd4ade99
commit
da78aae62b
|
@ -346,7 +346,7 @@ std::string makeFulltextSearchSuggestion(const std::string& lang,
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
kiwix::Suggestions::Suggestions()
|
kiwix::Suggestions::Suggestions()
|
||||||
: kainjow::mustache::data(kainjow::mustache::data::type::list)
|
: m_data(kainjow::mustache::data::type::list)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,8 +362,8 @@ void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion)
|
||||||
result.set("value", suggestion.getTitle());
|
result.set("value", suggestion.getTitle());
|
||||||
result.set("kind", "path");
|
result.set("kind", "path");
|
||||||
result.set("path", suggestion.getPath());
|
result.set("path", suggestion.getPath());
|
||||||
result.set("first", this->is_empty_list());
|
result.set("first", m_data.is_empty_list());
|
||||||
this->push_back(result);
|
m_data.push_back(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang,
|
void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang,
|
||||||
|
@ -373,14 +373,14 @@ void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang,
|
||||||
result.set("label", makeFulltextSearchSuggestion(uiLang, queryString));
|
result.set("label", makeFulltextSearchSuggestion(uiLang, queryString));
|
||||||
result.set("value", queryString + " ");
|
result.set("value", queryString + " ");
|
||||||
result.set("kind", "pattern");
|
result.set("kind", "pattern");
|
||||||
result.set("first", this->is_empty_list());
|
result.set("first", m_data.is_empty_list());
|
||||||
this->push_back(result);
|
m_data.push_back(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string kiwix::Suggestions::getJSON() const
|
std::string kiwix::Suggestions::getJSON() const
|
||||||
{
|
{
|
||||||
kainjow::mustache::data data;
|
kainjow::mustache::data data;
|
||||||
data.set("suggestions", *this);
|
data.set("suggestions", m_data);
|
||||||
|
|
||||||
return render_template(RESOURCE::templates::suggestion_json, data);
|
return render_template(RESOURCE::templates::suggestion_json, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace kiwix
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Suggestions : public kainjow::mustache::data
|
class Suggestions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Suggestions();
|
Suggestions();
|
||||||
|
@ -83,6 +83,9 @@ namespace kiwix
|
||||||
const std::string& query);
|
const std::string& query);
|
||||||
|
|
||||||
std::string getJSON() const;
|
std::string getJSON() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
kainjow::mustache::data m_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue