Browse Source

Merge branch 'release/1.5.2'

Book Pauk 2 years ago
parent
commit
0d52a9fd52

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+1.5.2 / 2023-02-05
+
+- Исправление проблемы чтения каталога opds для koreader
+
 1.5.1 / 2023-01-28
 1.5.1 / 2023-01-28
 ------------------
 ------------------
 
 

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "inpx-web",
   "name": "inpx-web",
-  "version": "1.5.1",
+  "version": "1.5.2",
   "lockfileVersion": 2,
   "lockfileVersion": 2,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "inpx-web",
       "name": "inpx-web",
-      "version": "1.5.1",
+      "version": "1.5.2",
       "hasInstallScript": true,
       "hasInstallScript": true,
       "license": "CC0-1.0",
       "license": "CC0-1.0",
       "dependencies": {
       "dependencies": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "inpx-web",
   "name": "inpx-web",
-  "version": "1.5.1",
+  "version": "1.5.2",
   "author": "Book Pauk <bookpauk@gmail.com>",
   "author": "Book Pauk <bookpauk@gmail.com>",
   "license": "CC0-1.0",
   "license": "CC0-1.0",
   "repository": "bookpauk/inpx-web",
   "repository": "bookpauk/inpx-web",

+ 7 - 2
server/core/opds/BasePage.js

@@ -24,13 +24,18 @@ class BasePage {
         this.showDeleted = false;
         this.showDeleted = false;
     }
     }
 
 
+    escape(s) {
+        //костыль для koreader, не понимает hex-экранирование вида &#x27;
+        return he.escape(s).replace(/&#x27;/g, '&#39;').replace(/&#x60;/g, '&#96;');
+    }
+
     makeEntry(entry = {}) {
     makeEntry(entry = {}) {
         if (!entry.id)
         if (!entry.id)
             throw new Error('makeEntry: no id');
             throw new Error('makeEntry: no id');
         if (!entry.title)
         if (!entry.title)
             throw new Error('makeEntry: no title');
             throw new Error('makeEntry: no title');
 
 
-        entry.title = he.escape(entry.title);
+        entry.title = this.escape(entry.title);
 
 
         const result = {
         const result = {
             updated: (new Date()).toISOString().substring(0, 19) + 'Z',
             updated: (new Date()).toISOString().substring(0, 19) + 'Z',
@@ -48,7 +53,7 @@ class BasePage {
     }
     }
 
 
     makeLink(attrs) {
     makeLink(attrs) {
-        attrs.href = he.escape(attrs.href);
+        attrs.href = this.escape(attrs.href);
         return {'*ATTRS': attrs};
         return {'*ATTRS': attrs};
     }
     }
 
 

+ 1 - 2
server/core/opds/BookPage.js

@@ -1,6 +1,5 @@
 const path = require('path');
 const path = require('path');
 const _ = require('lodash');
 const _ = require('lodash');
-const he = require('he');
 const dayjs = require('dayjs');
 const dayjs = require('dayjs');
 
 
 const BasePage = require('./BasePage');
 const BasePage = require('./BasePage');
@@ -190,7 +189,7 @@ class BookPage extends BasePage {
                 if (content) {
                 if (content) {
                     e.content = {
                     e.content = {
                         '*ATTRS': {type: 'text/html'},
                         '*ATTRS': {type: 'text/html'},
-                        '*TEXT': he.escape(content),
+                        '*TEXT': this.escape(content),
                     };
                     };
                 }
                 }
 
 

+ 1 - 1
server/core/opds/GenrePage.js

@@ -14,7 +14,7 @@ class GenrePage extends BasePage {
 
 
         const query = {
         const query = {
             from: req.query.from || 'search',
             from: req.query.from || 'search',
-            term: req.query.term || '*',
+            term: req.query.term || '',
             section: req.query.section || '',
             section: req.query.section || '',
         };
         };
 
 

+ 1 - 3
server/core/opds/SearchHelpPage.js

@@ -1,5 +1,3 @@
-const he = require('he');
-
 const BasePage = require('./BasePage');
 const BasePage = require('./BasePage');
 
 
 class SearchHelpPage extends BasePage {
 class SearchHelpPage extends BasePage {
@@ -45,7 +43,7 @@ class SearchHelpPage extends BasePage {
                 title: this.title,
                 title: this.title,
                 content: {
                 content: {
                     '*ATTRS': {type: 'text/html'},
                     '*ATTRS': {type: 'text/html'},
-                    '*TEXT': he.escape(content),
+                    '*TEXT': this.escape(content),
                 },
                 },
                 link: [
                 link: [
                     this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})
                     this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})

+ 3 - 3
server/core/opds/index.js

@@ -11,6 +11,8 @@ const OpensearchPage = require('./OpensearchPage');
 const SearchPage = require('./SearchPage');
 const SearchPage = require('./SearchPage');
 const SearchHelpPage = require('./SearchHelpPage');
 const SearchHelpPage = require('./SearchHelpPage');
 
 
+const log = new (require('../AppLogger'))().log;//singleton
+
 module.exports = function(app, config) {
 module.exports = function(app, config) {
     if (!config.opds || !config.opds.enabled)
     if (!config.opds || !config.opds.enabled)
         return;
         return;
@@ -63,10 +65,8 @@ module.exports = function(app, config) {
                 next();
                 next();
             }
             }
         } catch (e) {
         } catch (e) {
+            log(LM_ERR, `OPDS: ${e.message}, url: ${req.originalUrl}`);
             res.status(500).send({error: e.message});
             res.status(500).send({error: e.message});
-            if (config.branch == 'development') {
-                console.error({error: e.message, url: req.originalUrl});
-            }
         }
         }
     };
     };