Browse Source

Merge branch 'release/0.8.1'

Book Pauk 5 năm trước cách đây
mục cha
commit
e4cb61bebe

+ 1 - 0
README.md

@@ -11,6 +11,7 @@
 Для разворачивания читалки на чистом VPS с нуля смотрите [docs/omnireader](docs/omnireader/README.md)
 
 ## Сборка проекта
+Необходима версия node.js не ниже 10.
 
 ```
 $ git clone https://github.com/bookpauk/liberama

+ 2 - 1
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;

+ 15 - 22
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.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 = 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.perspective = page2.perspective = '3072px';
+
+        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.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() {

+ 13 - 1
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:
 `

+ 7 - 3
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
 ```
 
@@ -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
@@ -61,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`.

+ 2 - 0
docs/omnireader/deploy.sh

@@ -1,2 +1,4 @@
+#!/bin/sh
+
 npm run build:linux
 sudo -u www-data cp -r ../../dist/linux/* /home/liberama

+ 2 - 0
docs/omnireader/run_server.sh

@@ -1 +1,3 @@
+#!/bin/sh
+
 sudo -H -u www-data sh -c "cd /var/www; /home/liberama/liberama"

+ 0 - 18
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",
@@ -4179,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",
@@ -7500,12 +7488,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",

+ 1 - 4
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",
@@ -32,17 +32,14 @@
     "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",
     "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",
-    "null-loader": "^0.1.1",
     "optimize-css-assets-webpack-plugin": "^5.0.3",
     "pkg": "^4.4.2",
     "terser-webpack-plugin": "^1.4.1",

+ 4 - 3
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();
 

+ 52 - 0
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(/<title>([\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}</title>` + text
+            .replace(/<title>/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;

+ 1 - 0
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'),