From 2164faba44a2f1f813275b4cb28ec9ecf9c9e087 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 26 Mar 2018 21:28:44 +0200 Subject: [PATCH] Add a potential search description link in the opds stream. --- include/opds_dumper.h | 8 ++++++++ src/opds_dumper.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/opds_dumper.h b/include/opds_dumper.h index 9c5c4beaa..5c60b8c6a 100644 --- a/include/opds_dumper.h +++ b/include/opds_dumper.h @@ -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); diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index d5db57ebe..63dce8542 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -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); }