Работа над BookInfoDialog
This commit is contained in:
@@ -8,8 +8,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
|
<div ref="box" class="fit column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
|
||||||
<div v-html="annotation" />
|
<div class="row" style="height: 300px">
|
||||||
|
<div style="height: 300px">
|
||||||
|
<img v-if="coverSrc" :src="coverSrc" style="height: 100%;" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="q-mt-md" v-html="annotation" />
|
||||||
|
<pre>{{ annotation }}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -25,7 +32,7 @@
|
|||||||
import vueComponent from '../../vueComponent.js';
|
import vueComponent from '../../vueComponent.js';
|
||||||
|
|
||||||
import Dialog from '../../share/Dialog.vue';
|
import Dialog from '../../share/Dialog.vue';
|
||||||
import XmlParser from '../../../../server/core/xml/XmlParser';
|
import Fb2Parser from '../../../../server/core/fb2/Fb2Parser';
|
||||||
|
|
||||||
const componentOptions = {
|
const componentOptions = {
|
||||||
components: {
|
components: {
|
||||||
@@ -53,6 +60,7 @@ class BookInfoDialog {
|
|||||||
dialogVisible = false;
|
dialogVisible = false;
|
||||||
|
|
||||||
//info props
|
//info props
|
||||||
|
coverSrc = '';
|
||||||
annotation = '';
|
annotation = '';
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
@@ -65,21 +73,29 @@ class BookInfoDialog {
|
|||||||
|
|
||||||
parseBookInfo() {
|
parseBookInfo() {
|
||||||
const bookInfo = this.bookInfo;
|
const bookInfo = this.bookInfo;
|
||||||
const xml = new XmlParser();
|
const parser = new Fb2Parser();
|
||||||
|
|
||||||
//defaults
|
//defaults
|
||||||
|
this.coverSrc = '';
|
||||||
this.annotation = '';
|
this.annotation = '';
|
||||||
|
|
||||||
if (bookInfo.fb2) {
|
//cover
|
||||||
const desc = xml.navigator(bookInfo.fb2);
|
if (bookInfo.cover)
|
||||||
|
this.coverSrc = bookInfo.cover;
|
||||||
|
|
||||||
|
//fb2
|
||||||
|
if (bookInfo.fb2 && bookInfo.fb2.fictionbook && bookInfo.fb2.fictionbook.description) {
|
||||||
|
const desc = parser.inspector(bookInfo.fb2.fictionbook.description);
|
||||||
|
|
||||||
//annotation
|
//annotation
|
||||||
const annObj = desc.v('description/title-info/annotation');
|
const annObj = desc.v('title-info/annotation');
|
||||||
if (annObj) {
|
if (annObj) {
|
||||||
this.annotation = xml.fromObject(annObj).toString({noHeader: true});
|
this.annotation = parser.fromObject(annObj).toString({noHeader: true, format: true});
|
||||||
|
this.annotation = parser.toHtml(this.annotation);
|
||||||
this.annotation = this.annotation.replace(/<p>/g, `<p class="p-annotation">`);
|
this.annotation = this.annotation.replace(/<p>/g, `<p class="p-annotation">`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
okClick() {
|
okClick() {
|
||||||
|
|||||||
@@ -480,8 +480,8 @@ class WebWorker {
|
|||||||
result.fb2 = false;
|
result.fb2 = false;
|
||||||
|
|
||||||
if (book.ext == 'fb2') {
|
if (book.ext == 'fb2') {
|
||||||
const {desc, cover, coverExt} = await this.fb2Helper.getDescAndCover(bookFile);
|
const {fb2, cover, coverExt} = await this.fb2Helper.getDescAndCover(bookFile);
|
||||||
result.fb2 = desc;
|
result.fb2 = fb2;
|
||||||
|
|
||||||
if (cover) {
|
if (cover) {
|
||||||
result.cover = `${this.config.filesPathStatic}/${hash}${coverExt}`;
|
result.cover = `${this.config.filesPathStatic}/${hash}${coverExt}`;
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ class Fb2Helper {
|
|||||||
|
|
||||||
data = this.checkEncoding(data);
|
data = this.checkEncoding(data);
|
||||||
|
|
||||||
const fb2 = new Fb2Parser();
|
const parser = new Fb2Parser();
|
||||||
|
|
||||||
fb2.fromString(data.toString(), {
|
parser.fromString(data.toString(), {
|
||||||
lowerCase: true,
|
lowerCase: true,
|
||||||
pickNode: route => route.indexOf('fictionbook/body') !== 0,
|
pickNode: route => route.indexOf('fictionbook/body') !== 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const desc = fb2.$$('description').toObject();
|
const desc = parser.$$('description').toObject();
|
||||||
const coverImage = fb2.inspector(desc).$('description/title-info/coverpage/image');
|
const coverImage = parser.inspector(desc).$('description/title-info/coverpage/image');
|
||||||
|
|
||||||
let cover = null;
|
let cover = null;
|
||||||
let coverExt = '';
|
let coverExt = '';
|
||||||
@@ -79,7 +79,7 @@ class Fb2Helper {
|
|||||||
const binaryId = (href[0] == '#' ? href.substring(1) : href);
|
const binaryId = (href[0] == '#' ? href.substring(1) : href);
|
||||||
|
|
||||||
//найдем нужный image
|
//найдем нужный image
|
||||||
fb2.$$('binary').eachSelf(node => {
|
parser.$$('binary').eachSelf(node => {
|
||||||
let attrs = node.attrs();
|
let attrs = node.attrs();
|
||||||
if (!attrs)
|
if (!attrs)
|
||||||
return;
|
return;
|
||||||
@@ -95,7 +95,8 @@ class Fb2Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {desc, cover, coverExt};
|
parser.remove('binary');
|
||||||
|
return {fb2: parser.toObject(), cover, coverExt};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user