mirror of https://github.com/kiwix/libkiwix.git
Add a potential search description link in the opds stream.
This commit is contained in:
parent
b48428e443
commit
2164faba44
|
@ -77,6 +77,13 @@ class OPDSDumper
|
|||
*/
|
||||
void setRootLocation(const std::string& rootLocation) { this->rootLocation = rootLocation; }
|
||||
|
||||
/**
|
||||
* Set the search url.
|
||||
*
|
||||
* @param searchUrl the search url to use.
|
||||
*/
|
||||
void setSearchDescriptionUrl(const std::string& searchDescriptionUrl) { this->searchDescriptionUrl = searchDescriptionUrl; }
|
||||
|
||||
/**
|
||||
* Set the library to dump.
|
||||
*
|
||||
|
@ -90,6 +97,7 @@ class OPDSDumper
|
|||
std::string title;
|
||||
std::string date;
|
||||
std::string rootLocation;
|
||||
std::string searchDescriptionUrl;
|
||||
|
||||
private:
|
||||
pugi::xml_node handleBook(Book book, pugi::xml_node root_node);
|
||||
|
|
|
@ -117,6 +117,14 @@ string OPDSDumper::dumpOPDSFeed()
|
|||
self_link_node.append_attribute("href") = "";
|
||||
self_link_node.append_attribute("type") = "application/atom+xml";
|
||||
|
||||
|
||||
if (!searchDescriptionUrl.empty() ) {
|
||||
auto search_link = root_node.append_child("link");
|
||||
search_link.append_attribute("rel") = "search";
|
||||
search_link.append_attribute("type") = "application/opensearchdescription+xml";
|
||||
search_link.append_attribute("href") = searchDescriptionUrl.c_str();
|
||||
}
|
||||
|
||||
for (auto book: library.books) {
|
||||
handleBook(book, root_node);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue