Support for multiple illustrations in OPDS entry

This commit is contained in:
Veloman Yunkan
2021-07-05 23:50:54 +04:00
parent b8aee8a42c
commit e5168d8b3d
4 changed files with 36 additions and 5 deletions

View File

@ -52,6 +52,22 @@ namespace
typedef kainjow::mustache::data MustacheData;
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)
{
@ -78,6 +94,7 @@ BookData getBookData(const Library* library, const std::vector<std::string>& boo
{"publisher_name", book.getPublisher()},
{"url", bookUrl},
{"size", to_string(book.getSize())},
{"icons", getBookIllustrationInfo(book)},
});
}