mirror of https://github.com/kiwix/libkiwix.git
Support for multiple illustrations in OPDS entry
This commit is contained in:
parent
b8aee8a42c
commit
e5168d8b3d
|
@ -52,6 +52,22 @@ namespace
|
||||||
|
|
||||||
typedef kainjow::mustache::data MustacheData;
|
typedef kainjow::mustache::data MustacheData;
|
||||||
typedef kainjow::mustache::list BookData;
|
typedef kainjow::mustache::list BookData;
|
||||||
|
typedef kainjow::mustache::list IllustrationInfo;
|
||||||
|
|
||||||
|
IllustrationInfo getBookIllustrationInfo(const Book& book)
|
||||||
|
{
|
||||||
|
kainjow::mustache::list illustrations;
|
||||||
|
if ( book.isPathValid() ) {
|
||||||
|
for ( auto illustration_size : zim::Archive(book.getPath()).getIllustrationSizes() ) {
|
||||||
|
illustrations.push_back(kainjow::mustache::object{
|
||||||
|
{"icon_width", to_string(illustration_size)},
|
||||||
|
{"icon_height", to_string(illustration_size)},
|
||||||
|
{"icon_scale", "1"},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return illustrations;
|
||||||
|
}
|
||||||
|
|
||||||
BookData getBookData(const Library* library, const std::vector<std::string>& bookIds)
|
BookData getBookData(const Library* library, const std::vector<std::string>& bookIds)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +94,7 @@ BookData getBookData(const Library* library, const std::vector<std::string>& boo
|
||||||
{"publisher_name", book.getPublisher()},
|
{"publisher_name", book.getPublisher()},
|
||||||
{"url", bookUrl},
|
{"url", bookUrl},
|
||||||
{"size", to_string(book.getSize())},
|
{"size", to_string(book.getSize())},
|
||||||
|
{"icons", getBookIllustrationInfo(book)},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,11 @@
|
||||||
<tags>{{tags}}</tags>
|
<tags>{{tags}}</tags>
|
||||||
<articleCount>{{article_count}}</articleCount>
|
<articleCount>{{article_count}}</articleCount>
|
||||||
<mediaCount>{{media_count}}</mediaCount>
|
<mediaCount>{{media_count}}</mediaCount>
|
||||||
<icon>/meta?name=favicon&content={{{content_id}}}</icon>
|
{{#icons}}
|
||||||
|
<link rel="http://opds-spec.org/image/thumbnail"
|
||||||
|
href="/meta?name=Illustration_{{icon_width}}x{{icon_height}}@{{icon_scale}}&content={{{content_id}}}"
|
||||||
|
type="image/png;width={{icon_width}};height={{icon_height}};scale={{icon_scale}}"/>
|
||||||
|
{{/icons}}
|
||||||
<link type="text/html" href="/{{{content_id}}}" />
|
<link type="text/html" href="/{{{content_id}}}" />
|
||||||
<author>
|
<author>
|
||||||
<name>{{author_name}}</name>
|
<name>{{author_name}}</name>
|
||||||
|
|
|
@ -34,7 +34,11 @@
|
||||||
<tags>{{tags}}</tags>
|
<tags>{{tags}}</tags>
|
||||||
<articleCount>{{article_count}}</articleCount>
|
<articleCount>{{article_count}}</articleCount>
|
||||||
<mediaCount>{{media_count}}</mediaCount>
|
<mediaCount>{{media_count}}</mediaCount>
|
||||||
<icon>/meta?name=favicon&content={{{content_id}}}</icon>
|
{{#icons}}
|
||||||
|
<link rel="http://opds-spec.org/image/thumbnail"
|
||||||
|
href="/meta?name=Illustration_{{icon_width}}x{{icon_height}}@{{icon_scale}}&content={{{content_id}}}"
|
||||||
|
type="image/png;width={{icon_width}};height={{icon_height}};scale={{icon_scale}}"/>
|
||||||
|
{{/icons}}
|
||||||
<link type="text/html" href="/{{{content_id}}}" />
|
<link type="text/html" href="/{{{content_id}}}" />
|
||||||
<author>
|
<author>
|
||||||
<name>{{author_name}}</name>
|
<name>{{author_name}}</name>
|
||||||
|
|
|
@ -626,7 +626,9 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
||||||
" <articleCount>284</articleCount>\n" \
|
" <articleCount>284</articleCount>\n" \
|
||||||
" <mediaCount>2</mediaCount>\n" \
|
" <mediaCount>2</mediaCount>\n" \
|
||||||
" <icon>/meta?name=favicon&content=zimfile</icon>\n" \
|
" <link rel=\"http://opds-spec.org/image/thumbnail\"\n" \
|
||||||
|
" href=\"/meta?name=Illustration_48x48@1&content=zimfile\"\n" \
|
||||||
|
" type=\"image/png;width=48;height=48;scale=1\"/>\n" \
|
||||||
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
||||||
" <author>\n" \
|
" <author>\n" \
|
||||||
" <name>Wikipedia</name>\n" \
|
" <name>Wikipedia</name>\n" \
|
||||||
|
@ -650,7 +652,9 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
" <tags>unittest;wikipedia;_category:wikipedia;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
" <tags>unittest;wikipedia;_category:wikipedia;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
||||||
" <articleCount>284</articleCount>\n" \
|
" <articleCount>284</articleCount>\n" \
|
||||||
" <mediaCount>2</mediaCount>\n" \
|
" <mediaCount>2</mediaCount>\n" \
|
||||||
" <icon>/meta?name=favicon&content=zimfile</icon>\n" \
|
" <link rel=\"http://opds-spec.org/image/thumbnail\"\n" \
|
||||||
|
" href=\"/meta?name=Illustration_48x48@1&content=zimfile\"\n" \
|
||||||
|
" type=\"image/png;width=48;height=48;scale=1\"/>\n" \
|
||||||
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
||||||
" <author>\n" \
|
" <author>\n" \
|
||||||
" <name>Wikipedia</name>\n" \
|
" <name>Wikipedia</name>\n" \
|
||||||
|
@ -674,7 +678,9 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
" <tags>unittest;wikipedia;_pictures:no;_videos:no;_details:no</tags>\n" \
|
" <tags>unittest;wikipedia;_pictures:no;_videos:no;_details:no</tags>\n" \
|
||||||
" <articleCount>284</articleCount>\n" \
|
" <articleCount>284</articleCount>\n" \
|
||||||
" <mediaCount>2</mediaCount>\n" \
|
" <mediaCount>2</mediaCount>\n" \
|
||||||
" <icon>/meta?name=favicon&content=zimfile</icon>\n" \
|
" <link rel=\"http://opds-spec.org/image/thumbnail\"\n" \
|
||||||
|
" href=\"/meta?name=Illustration_48x48@1&content=zimfile\"\n" \
|
||||||
|
" type=\"image/png;width=48;height=48;scale=1\"/>\n" \
|
||||||
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
" <link type=\"text/html\" href=\"/zimfile\" />\n" \
|
||||||
" <author>\n" \
|
" <author>\n" \
|
||||||
" <name>Wikipedia</name>\n" \
|
" <name>Wikipedia</name>\n" \
|
||||||
|
|
Loading…
Reference in New Issue