Работа над расширенным поиском
This commit is contained in:
@@ -12,6 +12,7 @@ module.exports = {
|
|||||||
|
|
||||||
accessPassword: '',
|
accessPassword: '',
|
||||||
accessTimeout: 0,
|
accessTimeout: 0,
|
||||||
|
extendedSearch: true,
|
||||||
bookReadLink: '',
|
bookReadLink: '',
|
||||||
loggingEnabled: true,
|
loggingEnabled: true,
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ module.exports = {
|
|||||||
lowMemoryMode: false,
|
lowMemoryMode: false,
|
||||||
fullOptimization: false,
|
fullOptimization: false,
|
||||||
|
|
||||||
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion'],
|
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch'],
|
||||||
|
|
||||||
allowRemoteLib: false,
|
allowRemoteLib: false,
|
||||||
remoteLib: false,
|
remoteLib: false,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const branchFilename = __dirname + '/application_env';
|
|||||||
const propsToSave = [
|
const propsToSave = [
|
||||||
'accessPassword',
|
'accessPassword',
|
||||||
'accessTimeout',
|
'accessTimeout',
|
||||||
|
'extendedSearch',
|
||||||
'bookReadLink',
|
'bookReadLink',
|
||||||
'loggingEnabled',
|
'loggingEnabled',
|
||||||
'dbCacheSize',
|
'dbCacheSize',
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class DbCreator {
|
|||||||
|
|
||||||
//парсинг
|
//парсинг
|
||||||
const parser = new InpxParser();
|
const parser = new InpxParser();
|
||||||
await parser.parse(config.inpxFile, readFileCallback, parsedCallback);
|
await parser.parse(config.inpxFile, readFileCallback, parsedCallback);
|
||||||
|
|
||||||
//чистка памяти, ибо жрет как не в себя
|
//чистка памяти, ибо жрет как не в себя
|
||||||
authorMap = null;
|
authorMap = null;
|
||||||
@@ -448,7 +448,9 @@ class DbCreator {
|
|||||||
|
|
||||||
const inpxInfo = (inpxFilter && inpxFilter.info ? inpxFilter.info : parser.info);
|
const inpxInfo = (inpxFilter && inpxFilter.info ? inpxFilter.info : parser.info);
|
||||||
inpxInfo.structure = parser.info.structure;
|
inpxInfo.structure = parser.info.structure;
|
||||||
|
if (!inpxInfo.version)
|
||||||
|
inpxInfo.version = parser.info.version;
|
||||||
|
|
||||||
await db.insert({table: 'config', rows: [
|
await db.insert({table: 'config', rows: [
|
||||||
{id: 'inpxInfo', value: inpxInfo},
|
{id: 'inpxInfo', value: inpxInfo},
|
||||||
{id: 'stats', value: stats},
|
{id: 'stats', value: stats},
|
||||||
|
|||||||
@@ -1,12 +1,32 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const ZipReader = require('./ZipReader');
|
const ZipReader = require('./ZipReader');
|
||||||
|
const utils = require('./utils');
|
||||||
|
|
||||||
const collectionInfo = 'collection.info';
|
const collectionInfo = 'collection.info';
|
||||||
const structureInfo = 'structure.info';
|
const structureInfo = 'structure.info';
|
||||||
const versionInfo = 'version.info';
|
const versionInfo = 'version.info';
|
||||||
|
|
||||||
const defaultStructure = 'AUTHOR;GENRE;TITLE;SERIES;SERNO;FILE;SIZE;LIBID;DEL;EXT;DATE;LANG;LIBRATE;KEYWORDS';
|
const defaultStructure = 'AUTHOR;GENRE;TITLE;SERIES;SERNO;FILE;SIZE;LIBID;DEL;EXT;DATE;LANG;LIBRATE;KEYWORDS';
|
||||||
|
//'AUTHOR;GENRE;TITLE;SERIES;SERNO;FILE;SIZE;LIBID;DEL;EXT;DATE;INSNO;FOLDER;LANG;LIBRATE;KEYWORDS;'
|
||||||
|
const defaultRecStruct = {
|
||||||
|
author: 'S',
|
||||||
|
genre: 'S',
|
||||||
|
title: 'S',
|
||||||
|
series: 'S',
|
||||||
|
serno: 'N',
|
||||||
|
file: 'S',
|
||||||
|
size: 'N',
|
||||||
|
libid: 'S',
|
||||||
|
del: 'N',
|
||||||
|
ext: 'S',
|
||||||
|
date: 'S',
|
||||||
|
insno: 'N',
|
||||||
|
folder: 'S',
|
||||||
|
lang: 'S',
|
||||||
|
librate: 'N',
|
||||||
|
keywords: 'S',
|
||||||
|
}
|
||||||
|
|
||||||
class InpxParser {
|
class InpxParser {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -24,6 +44,18 @@ class InpxParser {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRecStruct(structure) {
|
||||||
|
const result = {};
|
||||||
|
for (const field of structure)
|
||||||
|
if (utils.hasProp(defaultRecStruct, field))
|
||||||
|
result[field] = defaultRecStruct[field];
|
||||||
|
|
||||||
|
//folder есть всегда
|
||||||
|
result['folder'] = defaultRecStruct['folder'];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async parse(inpxFile, readFileCallback, parsedCallback) {
|
async parse(inpxFile, readFileCallback, parsedCallback) {
|
||||||
if (!readFileCallback)
|
if (!readFileCallback)
|
||||||
readFileCallback = async() => {};
|
readFileCallback = async() => {};
|
||||||
@@ -65,6 +97,8 @@ class InpxParser {
|
|||||||
info.structure = defaultStructure;
|
info.structure = defaultStructure;
|
||||||
const structure = info.structure.toLowerCase().split(';');
|
const structure = info.structure.toLowerCase().split(';');
|
||||||
|
|
||||||
|
info.recStruct = this.getRecStruct(structure);
|
||||||
|
|
||||||
//парсим inp-файлы
|
//парсим inp-файлы
|
||||||
this.chunk = [];
|
this.chunk = [];
|
||||||
for (const inpFile of inpFiles) {
|
for (const inpFile of inpFiles) {
|
||||||
|
|||||||
Reference in New Issue
Block a user