mirror of https://github.com/kiwix/libkiwix.git
kiwix::Suggestions::getJSON()
This commit is contained in:
parent
7a9780eb90
commit
abcd4ade99
|
@ -711,11 +711,7 @@ std::unique_ptr<Response> InternalServer::handle_suggest(const RequestContext& r
|
|||
results.addFTSearchSuggestion(request.get_user_language(), queryString);
|
||||
}
|
||||
|
||||
auto data = get_default_data();
|
||||
data.set("suggestions", results);
|
||||
|
||||
auto response = ContentResponse::build(*this, RESOURCE::templates::suggestion_json, data, "application/json; charset=utf-8");
|
||||
return std::move(response);
|
||||
return ContentResponse::build(*this, results.getJSON(), "application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
std::unique_ptr<Response> InternalServer::handle_viewer_settings(const RequestContext& request)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "tools/stringTools.h"
|
||||
#include "server/i18n.h"
|
||||
#include "libkiwix-resources.h"
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
@ -375,3 +376,11 @@ void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang,
|
|||
result.set("first", this->is_empty_list());
|
||||
this->push_back(result);
|
||||
}
|
||||
|
||||
std::string kiwix::Suggestions::getJSON() const
|
||||
{
|
||||
kainjow::mustache::data data;
|
||||
data.set("suggestions", *this);
|
||||
|
||||
return render_template(RESOURCE::templates::suggestion_json, data);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace kiwix
|
|||
|
||||
void addFTSearchSuggestion(const std::string& uiLang,
|
||||
const std::string& query);
|
||||
|
||||
std::string getJSON() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue