diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-09-03 20:12:27 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-09-03 20:12:27 +0100 |
commit | ed53a8d000c50f3c9969284d642fd15e12258772 (patch) | |
tree | 765f23a135b5aa43f2bc0b7419c734e59076e1a7 | |
parent | Add missing override attribute (diff) | |
download | gentoobrowse-2.1.6.tar.bz2 gentoobrowse-2.1.6.tar.xz gentoobrowse-2.1.6.zip |
Default sitemap to XMLgentoobrowse-2.1.6
-rw-r--r-- | gentoobrowse/src/search.cpp | 13 | ||||
-rw-r--r-- | gentoobrowse/src/test.cpp | 22 |
2 files changed, 27 insertions, 8 deletions
diff --git a/gentoobrowse/src/search.cpp b/gentoobrowse/src/search.cpp index d1241fa..52a5846 100644 --- a/gentoobrowse/src/search.cpp +++ b/gentoobrowse/src/search.cpp @@ -25,10 +25,10 @@ namespace GentooBrowse { public: sitemap(const IceSpider::Core * core) : IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/sitemap.xml"), - prx0(core->getProxy<Gentoo::Portage>()) + prx0(core->getProxy<Gentoo::Portage>()), + sitemaps {std::make_shared<IceSpider::XsltStreamSerializer::IceSpiderFactory>("xslt/sitemap.xslt")} { - addRouteSerializer({"application", "xml"}, - std::make_shared<IceSpider::XsltStreamSerializer::IceSpiderFactory>("xslt/sitemap.xslt")); + addRouteSerializer({"application", "xml"}, sitemaps); } void @@ -53,8 +53,15 @@ namespace GentooBrowse { request->response(this, _responseModel); } + IceSpider::ContentTypeSerializer + defaultSerializer(std::ostream & strm) const override + { + return {{"application", "xml"}, sitemaps->create(strm)}; + } + private: const Gentoo::PortagePrxPtr prx0; + StreamSerializerFactoryPtr sitemaps; }; } // namespace GentooBrowse diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp index 238efb4..aa49a07 100644 --- a/gentoobrowse/src/test.cpp +++ b/gentoobrowse/src/test.cpp @@ -86,12 +86,9 @@ public: } }; -class ChromiumRequestXml : public ChromiumRequest { +class ChromiumRequestDefaultXml : public ChromiumRequest { public: - ChromiumRequestXml(const Core * c, HttpMethod m, const std::string & p) : ChromiumRequest(c, m, p) - { - hdr["Accept"] = "application/xml"; - } + using ChromiumRequest::ChromiumRequest; virtual void standardAssertions(const char *) override @@ -104,6 +101,14 @@ public: } }; +class ChromiumRequestXml : public ChromiumRequestDefaultXml { +public: + ChromiumRequestXml(const Core * c, HttpMethod m, const std::string & p) : ChromiumRequestDefaultXml(c, m, p) + { + hdr["Accept"] = "application/xml"; + } +}; + class ChromiumRequestAtom : public ChromiumRequest { public: ChromiumRequestAtom(const Core * c, HttpMethod m, const std::string & p) : ChromiumRequest(c, m, p) @@ -255,6 +260,13 @@ BOOST_AUTO_TEST_CASE(search_sitemap) request.standardAssertions(typeid(*this).name()); } +BOOST_AUTO_TEST_CASE(search_sitemap_dfl) +{ + ChromiumRequestDefaultXml request(this, HttpMethod::GET, "/sitemap.xml"); + process(&request); + request.standardAssertions(typeid(*this).name()); +} + BOOST_AUTO_TEST_CASE(home_atom) { ChromiumRequestAtom request(this, HttpMethod::GET, "/"); |