Added <dc:issued> field to OPDS entries

This commit is contained in:
Veloman Yunkan 2022-02-19 11:34:24 +04:00
parent 5c38300504
commit afb556bf64
5 changed files with 15 additions and 4 deletions

View File

@ -72,6 +72,7 @@ IllustrationInfo getBookIllustrationInfo(const Book& book)
kainjow::mustache::object getSingleBookData(const Book& book) kainjow::mustache::object getSingleBookData(const Book& book)
{ {
const auto bookDate = book.getDate() + "T00:00:00Z";
const MustacheData bookUrl = book.getUrl().empty() const MustacheData bookUrl = book.getUrl().empty()
? MustacheData(false) ? MustacheData(false)
: MustacheData(book.getUrl()); : MustacheData(book.getUrl());
@ -82,7 +83,8 @@ kainjow::mustache::object getSingleBookData(const Book& book)
{"description", book.getDescription()}, {"description", book.getDescription()},
{"language", book.getLanguage()}, {"language", book.getLanguage()},
{"content_id", urlEncode(book.getHumanReadableIdFromPath(), true)}, {"content_id", urlEncode(book.getHumanReadableIdFromPath(), true)},
{"updated", book.getDate() + "T00:00:00Z"}, {"updated", bookDate}, // XXX: this should be the entry update datetime
{"book_date", bookDate},
{"category", book.getCategory()}, {"category", book.getCategory()},
{"flavour", book.getFlavour()}, {"flavour", book.getFlavour()},
{"tags", book.getTags()}, {"tags", book.getTags()},

View File

@ -1,4 +1,6 @@
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:opds="http://opds-spec.org/2010/catalog"> <feed xmlns="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:opds="http://opds-spec.org/2010/catalog">
<id>{{feed_id}}</id> <id>{{feed_id}}</id>
<title>{{^filter}}All zims{{/filter}}{{#filter}}Filtered zims ({{filter}}){{/filter}}</title> <title>{{^filter}}All zims{{/filter}}{{#filter}}Filtered zims ({{filter}}){{/filter}}</title>
<updated>{{date}}</updated> <updated>{{date}}</updated>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" <feed xmlns="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:opds="https://specs.opds.io/opds-1.2" xmlns:opds="https://specs.opds.io/opds-1.2"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"> xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<id>{{feed_id}}</id> <id>{{feed_id}}</id>

View File

@ -25,6 +25,7 @@
<publisher> <publisher>
<name>{{publisher_name}}</name> <name>{{publisher_name}}</name>
</publisher> </publisher>
<dc:issued>{{book_date}}</dc:issued>
{{#url}} {{#url}}
<link rel="http://opds-spec.org/acquisition/open-access" type="application/x-zim" href="{{{url}}}" length="{{{size}}}" /> <link rel="http://opds-spec.org/acquisition/open-access" type="application/x-zim" href="{{{url}}}" length="{{{size}}}" />
{{/url}} {{/url}}

View File

@ -1081,7 +1081,8 @@ std::string maskVariableOPDSFeedData(std::string s)
} }
#define OPDS_FEED_TAG \ #define OPDS_FEED_TAG \
"<feed xmlns=\"http://www.w3.org/2005/Atom\"" \ "<feed xmlns=\"http://www.w3.org/2005/Atom\"\n" \
" xmlns:dc=\"http://purl.org/dc/terms/\"\n" \
" xmlns:opds=\"http://opds-spec.org/2010/catalog\">\n" " xmlns:opds=\"http://opds-spec.org/2010/catalog\">\n"
#define CATALOG_LINK_TAGS \ #define CATALOG_LINK_TAGS \
@ -1110,6 +1111,7 @@ std::string maskVariableOPDSFeedData(std::string s)
" <publisher>\n" \ " <publisher>\n" \
" <name>Kiwix</name>\n" \ " <name>Kiwix</name>\n" \
" </publisher>\n" \ " </publisher>\n" \
" <dc:issued>2020-03-31T00:00:00Z</dc:issued>\n" \
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile%26other.zim\" length=\"569344\" />\n" \ " <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile%26other.zim\" length=\"569344\" />\n" \
" </entry>\n" " </entry>\n"
@ -1136,6 +1138,7 @@ std::string maskVariableOPDSFeedData(std::string s)
" <publisher>\n" \ " <publisher>\n" \
" <name>Kiwix</name>\n" \ " <name>Kiwix</name>\n" \
" </publisher>\n" \ " </publisher>\n" \
" <dc:issued>2020-03-31T00:00:00Z</dc:issued>\n" \
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim\" length=\"569344\" />\n" \ " <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim\" length=\"569344\" />\n" \
" </entry>\n" " </entry>\n"
@ -1159,6 +1162,7 @@ std::string maskVariableOPDSFeedData(std::string s)
" <publisher>\n" \ " <publisher>\n" \
" <name>Kiwix</name>\n" \ " <name>Kiwix</name>\n" \
" </publisher>\n" \ " </publisher>\n" \
" <dc:issued>2020-03-31T00:00:00Z</dc:issued>\n" \
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim\" length=\"125952\" />\n" \ " <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim\" length=\"125952\" />\n" \
" </entry>\n" " </entry>\n"
@ -1574,6 +1578,7 @@ TEST_F(LibraryServerTest, catalog_v2_languages)
#define CATALOG_V2_ENTRIES_PREAMBLE0(x) \ #define CATALOG_V2_ENTRIES_PREAMBLE0(x) \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
"<feed xmlns=\"http://www.w3.org/2005/Atom\"\n" \ "<feed xmlns=\"http://www.w3.org/2005/Atom\"\n" \
" xmlns:dc=\"http://purl.org/dc/terms/\"\n" \
" xmlns:opds=\"https://specs.opds.io/opds-1.2\"\n" \ " xmlns:opds=\"https://specs.opds.io/opds-1.2\"\n" \
" xmlns:opensearch=\"http://a9.com/-/spec/opensearch/1.1/\">\n" \ " xmlns:opensearch=\"http://a9.com/-/spec/opensearch/1.1/\">\n" \
" <id>12345678-90ab-cdef-1234-567890abcdef</id>\n" \ " <id>12345678-90ab-cdef-1234-567890abcdef</id>\n" \