Работа над opds

This commit is contained in:
Book Pauk
2022-11-23 14:38:23 +07:00
parent 8cf370c79d
commit a6d9df7dec
4 changed files with 43 additions and 26 deletions

View File

@@ -1,3 +1,4 @@
const path = require('path');
const BasePage = require('./BasePage');
class BookPage extends BasePage {
@@ -16,21 +17,29 @@ class BookPage extends BasePage {
if (bookUid) {
const {bookInfo} = await this.webWorker.getBookInfo(bookUid);
if (bookInfo) {
entry.push(
this.makeEntry({
id: bookUid,
title: bookInfo.book.title || 'Без названия',
link: [
//this.imgLink({href: bookInfo.cover, type: coverType}),
this.acqLink({href: bookInfo.link, type: `application/${bookInfo.book.ext}+gzip`}),
],
})
);
const e = this.makeEntry({
id: bookUid,
title: bookInfo.book.title || 'Без названия',
link: [
this.downLink({href: bookInfo.link, type: `application/${bookInfo.book.ext}+zip`}),
],
});
if (bookInfo.cover) {
let coverType = 'image/jpeg';
if (path.extname(bookInfo.cover) == '.png')
coverType = 'image/png';
e.link.push(this.imgLink({href: bookInfo.cover, type: coverType}));
e.link.push(this.imgLink({href: bookInfo.cover, type: coverType, thumb: true}));
}
entry.push(e);
}
}
result.entry = entry;
return this.makeBody(result);
return this.makeBody(result, req);
}
}