From a0f64e188bb6ac3e9f96a37ff6e814a5196c774c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 3 Jan 2020 15:59:00 +0700 Subject: [PATCH 1/9] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + docs/omnireader/README.md | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index bad76aaf..03ce9764 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Для разворачивания читалки на чистом VPS с нуля смотрите [docs/omnireader](docs/omnireader/README.md) ## Сборка проекта +Необходима версия node.js не ниже 10. ``` $ git clone https://github.com/bookpauk/liberama diff --git a/docs/omnireader/README.md b/docs/omnireader/README.md index f7c4a01c..f458f25b 100644 --- a/docs/omnireader/README.md +++ b/docs/omnireader/README.md @@ -39,6 +39,8 @@ sudo apt install poppler-utils ``` ### nginx, server config +Для своего домена необходимо будет подправить docs/omnireader/omnireader. +Можно также настроить сервер для HTTP, без SSL. ``` sudo apt install nginx sudo cp docs/omnireader/omnireader /etc/nginx/sites-available/omnireader @@ -48,6 +50,8 @@ sudo service nginx reload sudo chown -R www-data.www-data /var/www ``` +### certbot +Следовать инструкции установки certbot https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx ### old.omnireader ``` sudo apt install php7.2 php7.2-curl php7.2-mbstring php7.2-fpm From 4d1df66025394443bd5d2e5dc19dd334dd240d87 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 3 Jan 2020 16:58:37 +0700 Subject: [PATCH 2/9] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index fbf5ca7d..a81ef4fe 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -225,30 +225,23 @@ class TextPage extends Vue { //scrolling page const pageSpace = this.scrollHeight - this.pageLineCount*this.lineHeight; - let y = pageSpace/2; + let top = pageSpace/2; if (this.showStatusBar) - y += this.statusBarHeight*(this.statusBarTop ? 1 : 0); - let page1 = this.$refs.scrollBox1; - let page2 = this.$refs.scrollBox2; + top += this.statusBarHeight*(this.statusBarTop ? 1 : 0); + let page1 = this.$refs.scrollBox1.style; + let page2 = this.$refs.scrollBox2.style; - page1.style.perspective = '3072px'; - page2.style.perspective = '3072px'; + page1.perspective = page2.perspective = '3072px'; - page1.style.width = this.w + this.indentLR + 'px'; - page2.style.width = this.w + this.indentLR + 'px'; - page1.style.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px'; - page2.style.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px'; - page1.style.top = y + 'px'; - page2.style.top = y + 'px'; - page1.style.left = this.indentLR + 'px'; - page2.style.left = this.indentLR + 'px'; + page1.width = page2.width = this.w + this.indentLR + 'px'; + page1.height = page2.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px'; + page1.top = page2.top = top + 'px'; + page1.left = page2.left = this.indentLR + 'px'; - page1 = this.$refs.scrollingPage1; - page2 = this.$refs.scrollingPage2; - page1.style.width = this.w + this.indentLR + 'px'; - page2.style.width = this.w + this.indentLR + 'px'; - page1.style.height = this.scrollHeight + this.lineHeight + 'px'; - page2.style.height = this.scrollHeight + this.lineHeight + 'px'; + page1 = this.$refs.scrollingPage1.style; + page2 = this.$refs.scrollingPage2.style; + page1.width = page2.width = this.w + this.indentLR + 'px'; + page1.height = page2.height = this.scrollHeight + this.lineHeight + 'px'; } async checkLoadedFonts() { From 9981e1f3bd241acc4152cd26556986a6c60f8415 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 3 Jan 2020 17:06:03 +0700 Subject: [PATCH 3/9] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/omnireader/README.md | 4 ++-- docs/omnireader/deploy.sh | 2 ++ docs/omnireader/run_server.sh | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/omnireader/README.md b/docs/omnireader/README.md index f458f25b..fa1046da 100644 --- a/docs/omnireader/README.md +++ b/docs/omnireader/README.md @@ -65,8 +65,8 @@ sudo -u www-data cp -r docs/omnireader/old/* /home/oldreader ## Деплой и запуск ``` cd docs/omnireader -sh deploy.sh -sh run_server.sh +./deploy.sh +./run_server.sh ``` После первого запуска будет создан конфигурационный файл `/home/liberama/data/config.json`. diff --git a/docs/omnireader/deploy.sh b/docs/omnireader/deploy.sh index 2ace417c..15efc847 100755 --- a/docs/omnireader/deploy.sh +++ b/docs/omnireader/deploy.sh @@ -1,2 +1,4 @@ +#!/bin/sh + npm run build:linux sudo -u www-data cp -r ../../dist/linux/* /home/liberama diff --git a/docs/omnireader/run_server.sh b/docs/omnireader/run_server.sh index d137bf12..a75e2bb5 100755 --- a/docs/omnireader/run_server.sh +++ b/docs/omnireader/run_server.sh @@ -1 +1,3 @@ +#!/bin/sh + sudo -H -u www-data sh -c "cd /var/www; /home/liberama/liberama" \ No newline at end of file From 03914883bc46733da849cd2e1eb3f80ce9a523dc Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 5 Jan 2020 13:37:09 +0700 Subject: [PATCH 4/9] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/omnireader/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/omnireader/README.md b/docs/omnireader/README.md index fa1046da..2f1308b5 100644 --- a/docs/omnireader/README.md +++ b/docs/omnireader/README.md @@ -9,7 +9,7 @@ git clone https://github.com/bookpauk/liberama ### node.js ``` sudo apt install -y curl -curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - +curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt install -y nodejs ``` From ecd8400a34b7b51822c1d15c17d5dac77c63b114 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 5 Jan 2020 15:15:55 +0700 Subject: [PATCH 5/9] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83?= =?UTF-8?q?=D0=B5=D0=BC=D1=8B=D0=B5=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 12 ------------ package.json | 2 -- 2 files changed, 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c987cbd..15c120cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3610,12 +3610,6 @@ "path-type": "^3.0.0" } }, - "disable-output-webpack-plugin": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/disable-output-webpack-plugin/-/disable-output-webpack-plugin-1.0.1.tgz", - "integrity": "sha512-fT4qiosyTqteTKDbYLXISMKzMVbl2dMXbMpUN3VPAUxX9JL81MmOilisbX555W1XS4B6FRzQt9zMtqg1T6Jx9Q==", - "dev": true - }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -7500,12 +7494,6 @@ "boolbase": "~1.0.0" } }, - "null-loader": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/null-loader/-/null-loader-0.1.1.tgz", - "integrity": "sha1-F76av80/8OFRL2/Er8sfUDk3j64=", - "dev": true - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", diff --git a/package.json b/package.json index e379fb4d..9fc08b59 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "clean-webpack-plugin": "^1.0.1", "copy-webpack-plugin": "^5.1.1", "css-loader": "^1.0.0", - "disable-output-webpack-plugin": "^1.0.1", "element-theme-chalk": "^2.12.0", "eslint": "^5.16.0", "eslint-plugin-html": "^5.0.5", @@ -42,7 +41,6 @@ "file-loader": "^3.0.1", "html-webpack-plugin": "^3.2.0", "mini-css-extract-plugin": "^0.5.0", - "null-loader": "^0.1.1", "optimize-css-assets-webpack-plugin": "^5.0.3", "pkg": "^4.4.2", "terser-webpack-plugin": "^1.4.1", From da55996e229b046d7e5f436361128953ba5629d7 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 5 Jan 2020 15:28:35 +0700 Subject: [PATCH 6/9] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83?= =?UTF-8?q?=D0=B5=D0=BC=D1=8B=D0=B5=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 6 ------ package.json | 1 - 2 files changed, 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15c120cb..1b496bee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4173,12 +4173,6 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, - "event-hooks-webpack-plugin": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/event-hooks-webpack-plugin/-/event-hooks-webpack-plugin-2.1.4.tgz", - "integrity": "sha512-TmxHNmRHPIG4XVDtAKT6i/rXNTAR6EnFQlSVsBFMkQ1f0MT2Me9RBNLw4E1JvdH433ag1VF9tPkp5sjTOfZM4Q==", - "dev": true - }, "events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", diff --git a/package.json b/package.json index 9fc08b59..466e43a0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "eslint-plugin-html": "^5.0.5", "eslint-plugin-node": "^8.0.0", "eslint-plugin-vue": "^5.2.3", - "event-hooks-webpack-plugin": "^2.1.4", "file-loader": "^3.0.1", "html-webpack-plugin": "^3.2.0", "mini-css-extract-plugin": "^0.5.0", From ccfb6a6d73e202371600ca3258d80f1ca5db187c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 7 Jan 2020 20:31:52 +0700 Subject: [PATCH 7/9] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=B0=20"Request?= =?UTF-8?q?=20path=20contains=20unescaped=20characters"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index aef9a36f..0a6dab35 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -824,7 +824,8 @@ class Reader extends Vue { return; } - let url = opts.url; + let url = encodeURI(decodeURI(opts.url)); + if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) && (url.indexOf('file://') != 0)) url = 'http://' + url; From f68c610c0d4347e21133132a3d56ebfc3d784591 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 7 Jan 2020 22:52:28 +0700 Subject: [PATCH 8/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B0=20FB3=20"?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B3=D0=B0=D0=BB=D0=BE=D1=87=D0=BA=D0=B8?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/Reader/BookConverter/ConvertDocX.js | 7 +-- .../core/Reader/BookConverter/ConvertFb3.js | 52 +++++++++++++++++++ server/core/Reader/BookConverter/index.js | 1 + 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 server/core/Reader/BookConverter/ConvertFb3.js diff --git a/server/core/Reader/BookConverter/ConvertDocX.js b/server/core/Reader/BookConverter/ConvertDocX.js index 11ab67f7..d8c85b78 100644 --- a/server/core/Reader/BookConverter/ConvertDocX.js +++ b/server/core/Reader/BookConverter/ConvertDocX.js @@ -4,14 +4,15 @@ const path = require('path'); const ConvertBase = require('./ConvertBase'); class ConvertDocX extends ConvertBase { - check(data, opts) { + async check(data, opts) { const {inputFiles} = opts; if (this.config.useExternalBookConverter && inputFiles.sourceFileType && inputFiles.sourceFileType.ext == 'zip') { //ищем файл '[Content_Types].xml' for (const file of inputFiles.files) { if (file.path == '[Content_Types].xml') { - return true; + const contentTypes = await fs.readFile(`${inputFiles.filesDir}/${file.path}`, 'utf8'); + return contentTypes.indexOf('/word/document.xml') >= 0; } } } @@ -30,7 +31,7 @@ class ConvertDocX extends ConvertBase { } async run(data, opts) { - if (!this.check(data, opts)) + if (!(await this.check(data, opts))) return false; await this.checkExternalConverterPresent(); diff --git a/server/core/Reader/BookConverter/ConvertFb3.js b/server/core/Reader/BookConverter/ConvertFb3.js new file mode 100644 index 00000000..ef2123d6 --- /dev/null +++ b/server/core/Reader/BookConverter/ConvertFb3.js @@ -0,0 +1,52 @@ +const fs = require('fs-extra'); + +const ConvertHtml = require('./ConvertHtml'); + +class ConvertDocX extends ConvertHtml { + async check(data, opts) { + const {inputFiles} = opts; + if (this.config.useExternalBookConverter && + inputFiles.sourceFileType && inputFiles.sourceFileType.ext == 'zip') { + //ищем файл '[Content_Types].xml' + for (const file of inputFiles.files) { + if (file.path == '[Content_Types].xml') { + const contentTypes = await fs.readFile(`${inputFiles.filesDir}/${file.path}`, 'utf8'); + return contentTypes.indexOf('/fb3/body.xml') >= 0; + } + } + } + + return false; + } + + getTitle(text) { + let title = ''; + const m = text.match(/([\s\S]*?)<\/title>/); + if (m) + title = m[1]; + + return title.trim(); + } + + async run(data, opts) { + if (!(await this.check(data, opts))) + return false; + await this.checkExternalConverterPresent(); + + const {inputFiles} = opts; + + let text = await fs.readFile(`${inputFiles.filesDir}/fb3/body.xml`, 'utf8'); + + const title = this.getTitle(text) + .replace(/<\/?p>/g, '') + ; + text = `<title>${title}` + text + .replace(//g, '<br><b>') + .replace(/<\/title>/g, '</b><br>') + .replace(/<subtitle>/g, '<br><br><subtitle>') + ; + return await super.run(Buffer.from(text), {skipCheck: true, cutTitle: true}); + } +} + +module.exports = ConvertDocX; diff --git a/server/core/Reader/BookConverter/index.js b/server/core/Reader/BookConverter/index.js index ebb4c1da..89b73f5a 100644 --- a/server/core/Reader/BookConverter/index.js +++ b/server/core/Reader/BookConverter/index.js @@ -7,6 +7,7 @@ const convertClassFactory = [ require('./ConvertPdf'), require('./ConvertRtf'), require('./ConvertDocX'), + require('./ConvertFb3'), require('./ConvertDoc'), require('./ConvertMobi'), require('./ConvertFb2'), From 7d5310af427c23402153e1871fa942b0c0b6cba7 Mon Sep 17 00:00:00 2001 From: Book Pauk <bookpauk@gmail.com> Date: Tue, 7 Jan 2020 22:57:06 +0700 Subject: [PATCH 9/9] =?UTF-8?q?=D0=92=D0=B5=D1=80=D1=81=D0=B8=D1=8F=200.8.?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/versionHistory.js | 14 +++++++++++++- package.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/components/Reader/versionHistory.js b/client/components/Reader/versionHistory.js index 56826cd3..7d7f0afb 100644 --- a/client/components/Reader/versionHistory.js +++ b/client/components/Reader/versionHistory.js @@ -1,6 +1,18 @@ export const versionHistory = [ { - showUntil: '2020-01-15', + showUntil: '2020-01-06', + header: '0.8.1 (2020-01-07)', + content: +` +<ul> + <li>добавлена частичная поддержка формата FB3</li> + <li>исправлен баг "Request path contains unescaped characters"</li> +</ul> +` +}, + +{ + showUntil: '2020-01-05', header: '0.8.0 (2020-01-02)', content: ` diff --git a/package.json b/package.json index 466e43a0..7a8de918 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Liberama", - "version": "0.8.0", + "version": "0.8.1", "author": "Book Pauk <bookpauk@gmail.com>", "license": "CC0-1.0", "repository": "bookpauk/liberama",