mirror of https://github.com/kiwix/libkiwix.git
A slight simplification of the mustache template
Got rid of the partial vs full entries logic in the mustache template - now it is entirely contained in `OPDSDumper::dumpOPDSFeedV2()`.
This commit is contained in:
parent
ebe16f92a5
commit
6f0e55d603
|
@ -150,17 +150,17 @@ string OPDSDumper::dumpOPDSFeedV2(const std::vector<std::string>& bookIds, const
|
||||||
const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, partial);
|
const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, partial);
|
||||||
|
|
||||||
const char* const endpoint = partial ? "/partial_entries" : "/entries";
|
const char* const endpoint = partial ? "/partial_entries" : "/entries";
|
||||||
|
const std::string url = endpoint + (query.empty() ? "" : "?" + query);
|
||||||
const kainjow::mustache::object template_data{
|
const kainjow::mustache::object template_data{
|
||||||
{"date", gen_date_str()},
|
{"date", gen_date_str()},
|
||||||
{"endpoint_root", endpointRoot},
|
{"endpoint_root", endpointRoot},
|
||||||
{"feed_id", gen_uuid(libraryId + endpoint + "?" + query)},
|
{"feed_id", gen_uuid(libraryId + endpoint + "?" + query)},
|
||||||
{"filter", onlyAsNonEmptyMustacheValue(query)},
|
{"filter", onlyAsNonEmptyMustacheValue(query)},
|
||||||
{"query", query.empty() ? "" : "?" + query},
|
{"self_url", url},
|
||||||
{"totalResults", to_string(m_totalResults)},
|
{"totalResults", to_string(m_totalResults)},
|
||||||
{"startIndex", to_string(m_startIndex)},
|
{"startIndex", to_string(m_startIndex)},
|
||||||
{"itemsPerPage", to_string(m_count)},
|
{"itemsPerPage", to_string(m_count)},
|
||||||
{"books", booksData },
|
{"books", booksData }
|
||||||
{"dump_partial_entries", MustacheData(partial)}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return render_template(RESOURCE::templates::catalog_v2_entries_xml, template_data);
|
return render_template(RESOURCE::templates::catalog_v2_entries_xml, template_data);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<id>{{feed_id}}</id>
|
<id>{{feed_id}}</id>
|
||||||
|
|
||||||
<link rel="self"
|
<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"/>
|
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
|
||||||
<link rel="start"
|
<link rel="start"
|
||||||
href="{{endpoint_root}}/root.xml"
|
href="{{endpoint_root}}/root.xml"
|
||||||
|
|
Loading…
Reference in New Issue