mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #936 from kiwix/opds_xml_fix
This commit is contained in:
commit
bf1d207651
|
@ -150,17 +150,17 @@ string OPDSDumper::dumpOPDSFeedV2(const std::vector<std::string>& bookIds, const
|
|||
const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, partial);
|
||||
|
||||
const char* const endpoint = partial ? "/partial_entries" : "/entries";
|
||||
const std::string url = endpoint + (query.empty() ? "" : "?" + query);
|
||||
const kainjow::mustache::object template_data{
|
||||
{"date", gen_date_str()},
|
||||
{"endpoint_root", endpointRoot},
|
||||
{"feed_id", gen_uuid(libraryId + endpoint + "?" + query)},
|
||||
{"filter", onlyAsNonEmptyMustacheValue(query)},
|
||||
{"query", query.empty() ? "" : "?" + query},
|
||||
{"self_url", url},
|
||||
{"totalResults", to_string(m_totalResults)},
|
||||
{"startIndex", to_string(m_startIndex)},
|
||||
{"itemsPerPage", to_string(m_count)},
|
||||
{"books", booksData },
|
||||
{"dump_partial_entries", MustacheData(partial)}
|
||||
{"books", booksData }
|
||||
};
|
||||
|
||||
return render_template(RESOURCE::templates::catalog_v2_entries_xml, template_data);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<id>{{feed_id}}</id>
|
||||
|
||||
<link rel="self"
|
||||
href="{{endpoint_root}}/{{#dump_partial_entries}}partial_{{/dump_partial_entries}}entries{{{query}}}"
|
||||
href="{{endpoint_root}}{{self_url}}"
|
||||
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
|
||||
<link rel="start"
|
||||
href="{{endpoint_root}}/root.xml"
|
||||
|
|
|
@ -728,7 +728,7 @@ TEST_F(LibraryServerTest, catalog_v2_entries_filtered_by_range)
|
|||
const auto r = zfs1_->GET("/ROOT%23%3F/catalog/v2/entries?start=1&count=1");
|
||||
EXPECT_EQ(r->status, 200);
|
||||
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
|
||||
CATALOG_V2_ENTRIES_PREAMBLE("?start=1&count=1")
|
||||
CATALOG_V2_ENTRIES_PREAMBLE("?start=1&count=1")
|
||||
" <title>Filtered Entries (start=1&count=1)</title>\n"
|
||||
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n"
|
||||
" <totalResults>3</totalResults>\n"
|
||||
|
@ -793,6 +793,24 @@ TEST_F(LibraryServerTest, catalog_v2_entries_filtered_by_language)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(LibraryServerTest, catalog_v2_entries_multiple_filters)
|
||||
{
|
||||
{
|
||||
const auto r = zfs1_->GET("/ROOT%23%3F/catalog/v2/entries?lang=fra&category=jazz");
|
||||
EXPECT_EQ(r->status, 200);
|
||||
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
|
||||
CATALOG_V2_ENTRIES_PREAMBLE("?lang=fra&category=jazz")
|
||||
" <title>Filtered Entries (lang=fra&category=jazz)</title>\n"
|
||||
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n"
|
||||
" <totalResults>1</totalResults>\n"
|
||||
" <startIndex>0</startIndex>\n"
|
||||
" <itemsPerPage>1</itemsPerPage>\n"
|
||||
CHARLES_RAY_CATALOG_ENTRY
|
||||
"</feed>\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LibraryServerTest, catalog_v2_individual_entry_access)
|
||||
{
|
||||
const auto r = zfs1_->GET("/ROOT%23%3F/catalog/v2/entry/raycharles");
|
||||
|
@ -1193,7 +1211,7 @@ TEST_F(LibraryServerTest, noJS) {
|
|||
FILTERS_HTML("")
|
||||
HOME_BODY_0_RESULTS
|
||||
FINAL_HTML_TEXT);
|
||||
|
||||
|
||||
// no_js_download
|
||||
r = zfs1_->GET("/ROOT%23%3F/nojs/download/zimfile");
|
||||
EXPECT_EQ(r->status, 200);
|
||||
|
|
Loading…
Reference in New Issue