Merge branch 'release/1.2.5'
This commit is contained in:
@@ -4,7 +4,8 @@ class Misc {
|
|||||||
async loadConfig() {
|
async loadConfig() {
|
||||||
|
|
||||||
const query = {params: [
|
const query = {params: [
|
||||||
'name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter', 'acceptFileExt', 'bucEnabled', 'branch', 'networkLibraryLink',
|
'name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter',
|
||||||
|
'acceptFileExt', 'bucEnabled', 'branch', 'networkLibraryLink', 'restricted'
|
||||||
]};
|
]};
|
||||||
|
|
||||||
const config = await wsc.message(await wsc.send(Object.assign({action: 'get-config'}, query)));
|
const config = await wsc.message(await wsc.send(Object.assign({action: 'get-config'}, query)));
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ class Reader {
|
|||||||
await wallpaperStorage.init();
|
await wallpaperStorage.init();
|
||||||
await coversStorage.init();
|
await coversStorage.init();
|
||||||
|
|
||||||
await bookManager.init(this.settings);
|
await bookManager.init(this.settings, this.restricted);
|
||||||
bookManager.addEventListener(this.bookManagerEvent);
|
bookManager.addEventListener(this.bookManagerEvent);
|
||||||
|
|
||||||
if (this.$root.getRootRoute() == '/reader') {
|
if (this.$root.getRootRoute() == '/reader') {
|
||||||
@@ -770,6 +770,10 @@ class Reader {
|
|||||||
return this.$store.state.config.bucEnabled && this.bucEnabled;
|
return this.$store.state.config.bucEnabled && this.bucEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get restricted() {
|
||||||
|
return this.$store.state.config.restricted;
|
||||||
|
}
|
||||||
|
|
||||||
get routeParamUrl() {
|
get routeParamUrl() {
|
||||||
let result = '';
|
let result = '';
|
||||||
const path = this.$route.fullPath;
|
const path = this.$route.fullPath;
|
||||||
|
|||||||
8
client/components/Reader/share/bmHelper.js
Normal file
8
client/components/Reader/share/bmHelper.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default {
|
||||||
|
restrictedData: `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink">
|
||||||
|
<description><title-info><book-title>Нарушение авторских прав</book-title></title-info></description>
|
||||||
|
<body><section><p>Книга не загружена по причине нарушения авторских прав.</p></section></body>
|
||||||
|
</FictionBook>`,
|
||||||
|
|
||||||
|
};
|
||||||
@@ -3,6 +3,7 @@ import path from 'path-browserify';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import BookParser from './BookParser';
|
import BookParser from './BookParser';
|
||||||
|
import bmHelper from './bmHelper';
|
||||||
import readerApi from '../../../api/reader';
|
import readerApi from '../../../api/reader';
|
||||||
import coversStorage from './coversStorage';
|
import coversStorage from './coversStorage';
|
||||||
import * as utils from '../../../share/utils';
|
import * as utils from '../../../share/utils';
|
||||||
@@ -26,9 +27,10 @@ const bmRecentStoreNew = localForage.createInstance({
|
|||||||
});
|
});
|
||||||
|
|
||||||
class BookManager {
|
class BookManager {
|
||||||
async init(settings) {
|
async init(settings, restricted) {
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
this.restricted = restricted;
|
||||||
|
|
||||||
this.eventListeners = [];
|
this.eventListeners = [];
|
||||||
this.books = {};
|
this.books = {};
|
||||||
@@ -232,6 +234,18 @@ class BookManager {
|
|||||||
return inflator.result;
|
return inflator.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isUrlAllowed(url) {
|
||||||
|
const restrictedSites = this.restricted?.sites;
|
||||||
|
if (restrictedSites) {
|
||||||
|
for (const site of restrictedSites) {
|
||||||
|
if (url.indexOf(site) === 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async addBook(newBook, callback) {
|
async addBook(newBook, callback) {
|
||||||
let meta = {url: newBook.url, path: newBook.path};
|
let meta = {url: newBook.url, path: newBook.path};
|
||||||
|
|
||||||
@@ -348,6 +362,10 @@ class BookManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseBook(meta, data, callback) {
|
async parseBook(meta, data, callback) {
|
||||||
|
if (!this.isUrlAllowed(meta.url)) {
|
||||||
|
data = bmHelper.restrictedData;
|
||||||
|
}
|
||||||
|
|
||||||
const parsed = new BookParser(this.settings);
|
const parsed = new BookParser(this.settings);
|
||||||
|
|
||||||
const parsedMeta = await parsed.parse(data, callback);
|
const parsedMeta = await parsed.parse(data, callback);
|
||||||
|
|||||||
@@ -1,4 +1,17 @@
|
|||||||
export const versionHistory = [
|
export const versionHistory = [
|
||||||
|
{
|
||||||
|
version: '1.2.5',
|
||||||
|
releaseDate: '2024-10-03',
|
||||||
|
showUntil: '2024-10-02',
|
||||||
|
content:
|
||||||
|
`
|
||||||
|
<ul>
|
||||||
|
<li>исправления из-за нарушения авторских прав</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
`
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
version: '1.2.4',
|
version: '1.2.4',
|
||||||
releaseDate: '2024-08-27',
|
releaseDate: '2024-08-27',
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "liberama",
|
"name": "liberama",
|
||||||
"version": "1.2.3",
|
"version": "1.2.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "liberama",
|
"name": "liberama",
|
||||||
"version": "1.2.3",
|
"version": "1.2.5",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "liberama",
|
"name": "liberama",
|
||||||
"version": "1.2.4",
|
"version": "1.2.5",
|
||||||
"author": "Book Pauk <bookpauk@gmail.com>",
|
"author": "Book Pauk <bookpauk@gmail.com>",
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"repository": "bookpauk/liberama",
|
"repository": "bookpauk/liberama",
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ module.exports = {
|
|||||||
|
|
||||||
useExternalBookConverter: false,
|
useExternalBookConverter: false,
|
||||||
acceptFileExt: '.fb2, .fb3, .html, .txt, .zip, .bz2, .gz, .rar, .epub, .mobi, .rtf, .doc, .docx, .pdf, .djvu, .jpg, .jpeg, .png',
|
acceptFileExt: '.fb2, .fb3, .html, .txt, .zip, .bz2, .gz, .rar, .epub, .mobi, .rtf, .doc, .docx, .pdf, .djvu, .jpg, .jpeg, .png',
|
||||||
webConfigParams: ['name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter', 'acceptFileExt', 'bucEnabled', 'branch', 'networkLibraryLink'],
|
restricted: {},
|
||||||
|
webConfigParams: ['name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter', 'acceptFileExt', 'bucEnabled', 'branch', 'networkLibraryLink', 'restricted'],
|
||||||
|
|
||||||
jembaDb: [
|
jembaDb: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class ConfigManager {
|
|||||||
|
|
||||||
await fs.ensureDir(config.dataDir);
|
await fs.ensureDir(config.dataDir);
|
||||||
this._userConfigFile = `${config.dataDir}/config.json`;
|
this._userConfigFile = `${config.dataDir}/config.json`;
|
||||||
|
this._restrictedFile = `${config.dataDir}/restricted.json`;
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
|
||||||
this.inited = true;
|
this.inited = true;
|
||||||
@@ -75,6 +76,10 @@ class ConfigManager {
|
|||||||
return this._userConfigFile;
|
return this._userConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get restrictedFile() {
|
||||||
|
return this._restrictedFile;
|
||||||
|
}
|
||||||
|
|
||||||
set userConfigFile(value) {
|
set userConfigFile(value) {
|
||||||
if (value)
|
if (value)
|
||||||
this._userConfigFile = value;
|
this._userConfigFile = value;
|
||||||
@@ -100,6 +105,12 @@ class ConfigManager {
|
|||||||
} else {
|
} else {
|
||||||
await this.save();
|
await this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await fs.pathExists(this.restrictedFile)) {
|
||||||
|
const data = JSON.parse(await fs.readFile(this.restrictedFile, 'utf8'));
|
||||||
|
|
||||||
|
this.config = {restricted: data};
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
throw new Error(`Error while loading "${this.userConfigFile}": ${e.message}`);
|
throw new Error(`Error while loading "${this.userConfigFile}": ${e.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user