From 007e97463bbeec7749985925f61342ff0d8417c0 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 15:56:10 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/ContentsPage/ContentsPage.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index f3621baa..c24d8044 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -63,8 +63,8 @@
-
- +
+
JPG
@@ -112,7 +112,7 @@ class ContentsPage extends Vue { contents = []; images = []; imageSrc = []; - imageLoaded = false; + imageLoaded = []; created() { } @@ -220,16 +220,16 @@ class ContentsPage extends Vue { //асинхронная загрузка изображений this.imageSrc = []; - this.imageLoaded = false; + this.imageLoaded = []; await utils.sleep(50); (async() => { for (i = 0; i < ims.length; i++) { const id = ims[i].id; const bin = this.parsed.binary[id]; this.$set(this.imageSrc, id, (bin ? `data:${bin.type};base64,${bin.data}` : '')); + this.imageLoaded[id] = true; await utils.sleep(5); } - this.imageLoaded = true; })(); } From 32b83826411e57399e26d10eb5a0e43094fd6238 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 16:09:35 +0700 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/ContentsPage/ContentsPage.vue | 17 ++++++++++++----- client/components/Reader/share/BookParser.js | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index c24d8044..94dbc937 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -63,12 +63,13 @@
-
- +
+
JPG
PNG
+
INET
@@ -210,7 +211,7 @@ class ContentsPage extends Vue { const p = parsed.para[image.paraIndex]; newImages.push({perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset, - indentStyle, labelStyle, type, imageId: image.id}); + indentStyle, labelStyle, type, id: image.id, local: image.local}); } this.images = newImages; @@ -224,9 +225,12 @@ class ContentsPage extends Vue { await utils.sleep(50); (async() => { for (i = 0; i < ims.length; i++) { - const id = ims[i].id; + const {id, local} = ims[i]; const bin = this.parsed.binary[id]; - this.$set(this.imageSrc, id, (bin ? `data:${bin.type};base64,${bin.data}` : '')); + if (local) + this.$set(this.imageSrc, id, (bin ? `data:${bin.type};base64,${bin.data}` : '')); + else + this.$set(this.imageSrc, id, id); this.imageLoaded[id] = true; await utils.sleep(5); } @@ -323,6 +327,9 @@ class ContentsPage extends Vue { .it-png-color { background: linear-gradient(to right, #4bc4e5, #6bf4ff); } +.it-net-color { + background: linear-gradient(to right, #00c400, #00f400); +} .image-thumb-box { width: 120px; diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 67f575c1..89127123 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -204,7 +204,7 @@ export default class BookParser { let attrs = sax.getAttrsSync(tail); if (attrs.href && attrs.href.value) { const href = attrs.href.value; - const {id} = this.imageHrefToId(href); + const {id, local} = this.imageHrefToId(href); if (href[0] == '#') {//local imageNum++; @@ -213,7 +213,7 @@ export default class BookParser { else newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); - this.images.push({paraIndex, num: imageNum, id}); + this.images.push({paraIndex, num: imageNum, id, local}); if (inPara && this.showInlineImagesInCenter) newParagraph(' ', 1); @@ -223,7 +223,7 @@ export default class BookParser { dimPromises.push(getExternalImageDimensions(href)); newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); - this.images.push({paraIndex, num: imageNum, id}); + this.images.push({paraIndex, num: imageNum, id, local}); } } } From 8cb67d29762d86393d8ec8615a1905605e4c3fdf Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 16:41:51 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/BookParser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 89127123..b1f60615 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -196,6 +196,7 @@ export default class BookParser { if (tag == 'binary') { let attrs = sax.getAttrsSync(tail); binaryType = (attrs['content-type'] && attrs['content-type'].value ? attrs['content-type'].value : ''); + binaryType = (binaryType == 'image/jpg' ? 'image/jpeg' : binaryType); if (binaryType == 'image/jpeg' || binaryType == 'image/png' || binaryType == 'application/octet-stream') binaryId = (attrs.id.value ? attrs.id.value : ''); } From 298e8928cfb713f9805fca88afa704e893f9dd37 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 17:10:44 +0700 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B9=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Reader/BookConverter/ConvertFb2.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/core/Reader/BookConverter/ConvertFb2.js b/server/core/Reader/BookConverter/ConvertFb2.js index 1d1ec8b9..2bc3cb52 100644 --- a/server/core/Reader/BookConverter/ConvertFb2.js +++ b/server/core/Reader/BookConverter/ConvertFb2.js @@ -24,6 +24,11 @@ class ConvertFb2 extends ConvertBase { if (!this.check(newData, opts)) return false; + //Корректируем пробелы, всякие файлы попадаются :( + if (newData[0] == 32) { + newData = Buffer.from(newData.toString().trim()); + } + return this.checkEncoding(newData); } From c8af4b907bed7d255b9f88f772cc1e29c13ad762 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 21:06:27 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B9?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B7=D0=B8=D1=86=D0=B8=D0=B8=20=D0=B2=20=D0=BE?= =?UTF-8?q?=D0=B3=D0=BB=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/ContentsPage/ContentsPage.vue | 82 +++++++++++++++++-- client/components/Reader/Reader.vue | 2 +- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index 94dbc937..c90cde27 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -26,7 +26,7 @@
-
+
@@ -41,7 +41,7 @@
-
+
@@ -60,7 +60,7 @@
-
+
@@ -101,14 +101,23 @@ import Component from 'vue-class-component'; import Window from '../../share/Window.vue'; import * as utils from '../../../share/utils'; +const ContentsPageProps = Vue.extend({ + props: { + bookPos: Number + } +}); + export default @Component({ components: { Window, }, watch: { + bookPos: function(newValue) { + this.updateBookPosSelection(newValue); + } }, }) -class ContentsPage extends Vue { +class ContentsPage extends ContentsPageProps { selectedTab = 'contents'; contents = []; images = []; @@ -123,10 +132,12 @@ class ContentsPage extends Vue { //закладки - //далее формирование оглавления - if (this.parsed == parsed) + //проверим, надо ли обновлять списки + if (this.parsed == parsed) { return; + } + //далее формирование оглавления this.parsed = parsed; this.contents = []; await this.$nextTick(); @@ -219,6 +230,9 @@ class ContentsPage extends Vue { if (this.selectedTab == 'contents' && !this.contents.length && this.images.length) this.selectedTab = 'images'; + //выделим на bookPos + this.updateBookPosSelection(currentBook.bookPos); + //асинхронная загрузка изображений this.imageSrc = []; this.imageLoaded = []; @@ -237,6 +251,44 @@ class ContentsPage extends Vue { })(); } + async updateBookPosSelection(bp) { + await utils.sleep(100); + for (let i = 0; i < this.contents.length; i++) { + const item = this.contents[i]; + const nextOffset = (i < this.contents.length - 1 ? this.contents[i + 1].offset : this.parsed.textLength); + + for (let j = 0; j < item.list.length; j++) { + const subitem = item.list[j]; + const nextSubOffset = (j < item.list.length - 1 ? item.list[j + 1].offset : nextOffset); + + if (bp >= subitem.offset && bp < nextSubOffset) { + subitem.isBookPos = true; + this.$set(this.contents, i, Object.assign(item, {list: item.list})); + } else if (subitem.isBookPos) { + subitem.isBookPos = false; + this.$set(this.contents, i, Object.assign(item, {list: item.list})); + } + } + + if (bp >= item.offset && bp < nextOffset) { + this.$set(this.contents, i, Object.assign(item, {isBookPos: true})); + } else if (item.isBookPos) { + this.$set(this.contents, i, Object.assign(item, {isBookPos: false})); + } + } + + for (let i = 0; i < this.images.length; i++) { + const img = this.images[i]; + const nextOffset = (i < this.images.length - 1 ? this.images[i + 1].offset : this.parsed.textLength); + + if (bp >= img.offset && bp < nextOffset) { + this.$set(this.images, i, Object.assign(img, {isBookPos: true})); + } else if (img.isBookPos) { + this.$set(this.images, i, Object.assign(img, {isBookPos: false})); + } + } + } + async expandClick(key) { const item = this.contents[key]; const expanded = !item.expanded; @@ -288,7 +340,7 @@ class ContentsPage extends Vue { padding: 10px 0 10px 0; } -.item, .subitem { +.item, .subitem, .item-book-pos, .subitem-book-pos { border-bottom: 1px solid #e0e0e0; } @@ -296,6 +348,22 @@ class ContentsPage extends Vue { background-color: #f0f0f0; } +.item-book-pos { + background-color: #b0f0b0; +} + +.subitem-book-pos { + background-color: #d0f5d0; +} + +.item-book-pos:hover { + background-color: #b0e0b0; +} + +.subitem-book-pos:hover { + background-color: #d0f0d0; +} + .expand-button, .no-expand-button { width: 40px; } diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index f1ee8e8b..ec93ca48 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -99,7 +99,7 @@ - +