Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3810d1ff5 | ||
|
|
deeac0be14 | ||
|
|
70593b5d22 | ||
|
|
4c90844f46 | ||
|
|
3e2599f233 | ||
|
|
8687931274 | ||
|
|
50f7a7800d | ||
|
|
eb2fbd20ae | ||
|
|
24d609d8f1 | ||
|
|
4b4f7bd697 | ||
|
|
bf6cf4238a | ||
|
|
1daf619a2d | ||
|
|
7e8d616c65 | ||
|
|
d9e19ff9b7 | ||
|
|
6be1b94b96 | ||
|
|
d6aa43d01b | ||
|
|
14a877d6d1 | ||
|
|
82eb78f433 | ||
|
|
8e5e0104a4 | ||
|
|
636e34bdc1 | ||
|
|
2c687c7af9 | ||
|
|
27fc46c410 | ||
|
|
a7cd019a97 | ||
|
|
12304c13a1 | ||
|
|
d87e2ce632 | ||
|
|
a2423fb704 | ||
|
|
192b92cab8 | ||
|
|
386a937239 | ||
|
|
06300e30b4 | ||
|
|
371d5646ae | ||
|
|
0d52a9fd52 | ||
|
|
08287deaa4 | ||
|
|
c43c5520a4 | ||
|
|
4e2b7886a9 | ||
|
|
05744e8472 | ||
|
|
9126973378 | ||
|
|
018e1069d5 | ||
|
|
92617b3263 | ||
|
|
d0172f11c3 | ||
|
|
638126b5f3 | ||
|
|
ef938bff77 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,4 +1,22 @@
|
||||
1.5.0 / 2023-01-28
|
||||
1.5.4 / 2023-04-12
|
||||
|
||||
- Добавлена возможность поиска по типу файла
|
||||
- Улучшена работа с inpx, теперь понимает файлы в каталогах (без zip-архива)
|
||||
- В readme добавлен раздел "Запуск без сборки релиза" для запуска inpx-web на любых платформах
|
||||
- Исправления мелких багов
|
||||
|
||||
1.5.3 / 2023-03-02
|
||||
|
||||
- OPDS: исправление проблемы поиска для koreader
|
||||
- OPDS: улучшено скачивание для не-fb2 форматов файлов (djvu, pdf и пр.)
|
||||
- Добавлена полоска уведомления о выходе новой версии (отключается в настройках веб-интерфейса).
|
||||
Проверка новой версии настраивается параметром checkReleaseLink в конфиге сервера (#15)
|
||||
|
||||
1.5.2 / 2023-02-05
|
||||
|
||||
- Исправление проблемы чтения каталога opds для koreader
|
||||
|
||||
1.5.1 / 2023-01-28
|
||||
------------------
|
||||
|
||||
- Настройки веб-интерфейса и опции командной строки "--lib-dir", "--inpx" вынесены в конфиг (#6)
|
||||
|
||||
44
README.md
44
README.md
@@ -29,7 +29,8 @@ OPDS-сервер доступен по адресу [http://127.0.0.1:12380/opd
|
||||
* [Удаленная библиотека](#remotelib)
|
||||
* [Фильтр по авторам и книгам](#filter)
|
||||
* [Настройка https с помощью nginx](#https)
|
||||
* [Сборка проекта](#build)
|
||||
* [Сборка релизов](#build)
|
||||
* [Запуск без сборки релиза](#native_run)
|
||||
* [Разработка](#development)
|
||||
|
||||
<a id="capabilities" />
|
||||
@@ -174,6 +175,13 @@ Options:
|
||||
"root": "/opds"
|
||||
},
|
||||
|
||||
// страница для скачивания свежего релиза
|
||||
"latestReleaseLink": "https://github.com/bookpauk/inpx-web/releases/latest",
|
||||
|
||||
// api для проверки новой версии,
|
||||
// пустая строка - отключить проверку выхода новых версий
|
||||
"checkReleaseLink": "https://api.github.com/repos/bookpauk/inpx-web/releases/latest",
|
||||
|
||||
// настройки по умолчанию для веб-интерфейса
|
||||
// устанавливаются при первой загрузке страницы в браузере
|
||||
// дальнейшие изменения настроек с помощью веб-интерфейса уже сохраняются в самом браузере
|
||||
@@ -188,7 +196,8 @@ Options:
|
||||
"showDeleted": false, // показывать удаленные
|
||||
"abCacheEnabled": true, // кешировать запросы
|
||||
"langDefault": "", // язык по умолчанию (например "ru,en")
|
||||
"showJson": false // показывать JSON (в расширенном поиске)
|
||||
"showJson": false, // показывать JSON (в расширенном поиске)
|
||||
"showNewReleaseAvailable": true // уведомлять о выходе новой версии
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -313,7 +322,7 @@ sudo service nginx reload
|
||||
|
||||
<a id="build" />
|
||||
|
||||
### Сборка проекта
|
||||
### Сборка релизов
|
||||
Сборка только в среде Linux.
|
||||
Необходима версия node.js не ниже 16.
|
||||
|
||||
@@ -323,15 +332,36 @@ sudo service nginx reload
|
||||
git clone https://github.com/bookpauk/inpx-web
|
||||
cd inpx-web
|
||||
npm i
|
||||
```
|
||||
|
||||
#### Релизы
|
||||
```sh
|
||||
npm run release
|
||||
```
|
||||
|
||||
Результат сборки будет доступен в каталоге `dist/release`
|
||||
|
||||
<a id="native_run" />
|
||||
|
||||
### Запуск без сборки релиза
|
||||
Т.к. сборщик pkg поддерживает не все платформы, то не всегда удается собрать релиз.
|
||||
Однако, можно скачать и запустить inpx-web нативным путем, с помощью nodejs.
|
||||
Ниже пример для Ubuntu, для других линуксов различия не принципиальны:
|
||||
|
||||
```sh
|
||||
# установка nodejs v16 и выше:
|
||||
curl -s https://deb.nodesource.com/setup_16.x | sudo bash
|
||||
sudo apt install nodejs -y
|
||||
|
||||
# подготовка
|
||||
git clone https://github.com/bookpauk/inpx-web
|
||||
cd inpx-web
|
||||
npm i
|
||||
npm run build:client && node build/prepkg.js linux
|
||||
|
||||
# удалим файл development-среды, чтобы запускался в production-режиме
|
||||
rm ./server/config/application_env
|
||||
|
||||
# запуск inpx-web, тут же будет создан каталог .inpx-web
|
||||
node server --app-dir=.inpx-web
|
||||
```
|
||||
|
||||
<a id="development" />
|
||||
|
||||
### Разработка
|
||||
|
||||
@@ -126,9 +126,9 @@
|
||||
</div>
|
||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||
|
||||
<div v-if="!refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<div v-if="!refreshing && (!tableData.length || error)" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
||||
Поиск не дал результатов
|
||||
{{ (error ? error : 'Поиск не дал результатов') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -438,6 +438,7 @@ class AuthorList extends BaseList {
|
||||
if (this.refreshing)
|
||||
return;
|
||||
|
||||
this.error = '';
|
||||
this.refreshing = true;
|
||||
|
||||
(async() => {
|
||||
@@ -467,7 +468,12 @@ class AuthorList extends BaseList {
|
||||
this.highlightPageScroller(query);
|
||||
}
|
||||
} catch (e) {
|
||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.list.queryFound = 0;
|
||||
this.list.totalFound = 0;
|
||||
this.searchResult = {found: []};
|
||||
await this.updateTableData();
|
||||
//this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.error = `Ошибка: ${e.message}`;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -48,6 +48,7 @@ export default class BaseList {
|
||||
genreMap: Object,
|
||||
};
|
||||
|
||||
error = '';
|
||||
loadingMessage = '';
|
||||
loadingMessage2 = '';
|
||||
|
||||
@@ -371,7 +372,8 @@ export default class BaseList {
|
||||
bookValue = emptyFieldValue;
|
||||
|
||||
bookValue = bookValue.toLowerCase();
|
||||
searchValue = searchValue.toLowerCase();
|
||||
if (searchValue[0] !== '~')
|
||||
searchValue = searchValue.toLowerCase();
|
||||
|
||||
//особая обработка префиксов
|
||||
if (searchValue[0] == '=') {
|
||||
@@ -450,6 +452,13 @@ export default class BaseList {
|
||||
librateFound = searchLibrate.has(book.librate);
|
||||
}
|
||||
|
||||
//ext
|
||||
let extFound = !s.ext;
|
||||
if (!extFound) {
|
||||
const searchExt = new Set(s.ext.split('|'));
|
||||
extFound = searchExt.has(book.ext.toLowerCase() || emptyFieldValue);
|
||||
}
|
||||
|
||||
return (this.showDeleted || !book.del)
|
||||
&& authorFound
|
||||
&& filterBySearch(book.series, s.series)
|
||||
@@ -458,6 +467,7 @@ export default class BaseList {
|
||||
&& langFound
|
||||
&& dateFound
|
||||
&& librateFound
|
||||
&& extFound
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="poster-size">
|
||||
<div class="column justify-center items-center" :class="{'poster': coverSrc, 'no-poster': !coverSrc}" @click.stop.prevent="posterClick">
|
||||
<img v-if="coverSrc" :src="coverSrc" class="fit row justify-center items-center" style="object-fit: contain" @error="coverSrc = ''" />
|
||||
<div v-if="!coverSrc" class="fit row justify-center items-center text-grey-5" style="border: 1px solid #ccc; font-size: 300%">
|
||||
<div v-if="!coverSrc" class="fit row justify-center items-center text-grey-5 overflow-hidden" style="border: 1px solid #ccc; font-size: 300%">
|
||||
<i>{{ book.ext }}</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
</div>
|
||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||
|
||||
<div v-if="!refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<div v-if="!refreshing && (!tableData.length || error)" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
||||
Поиск не дал результатов
|
||||
{{ (error ? error : 'Поиск не дал результатов') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -74,6 +74,7 @@ class ExtendedList extends BaseList {
|
||||
if (this.refreshing)
|
||||
return;
|
||||
|
||||
this.error = '';
|
||||
this.refreshing = true;
|
||||
|
||||
(async() => {
|
||||
@@ -103,7 +104,12 @@ class ExtendedList extends BaseList {
|
||||
this.highlightPageScroller(query);
|
||||
}
|
||||
} catch (e) {
|
||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.list.queryFound = 0;
|
||||
this.list.totalFound = 0;
|
||||
this.searchResult = {found: []};
|
||||
await this.updateTableData();
|
||||
//this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.error = `Ошибка: ${e.message}`;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -3,6 +3,19 @@
|
||||
<div ref="scroller" class="col fit column no-wrap" style="overflow: auto; position: relative" @scroll="onScroll">
|
||||
<!-- Tool Panel begin -->
|
||||
<div ref="toolPanel" class="tool-panel column bg-cyan-2" style="position: sticky; top: 0; z-index: 10;">
|
||||
<!-- Обновление -->
|
||||
<div v-show="showNewReleaseAvailable && newReleaseAvailable" class="row q-py-sm bg-green-4 items-center">
|
||||
<div class="q-ml-sm" style="font-size: 120%">
|
||||
Доступна новая версия <b>{{ config.name }} v{{ config.latestVersion }}</b>
|
||||
</div>
|
||||
<DivBtn class="q-ml-sm q-px-sm bg-white" :size="20" @click.stop.prevent="openReleasePage">
|
||||
Скачать
|
||||
</DivBtn>
|
||||
<DivBtn class="q-ml-sm q-px-sm bg-white" :size="20" @click.stop.prevent="settingsDialogVisible = true">
|
||||
Отключить уведомление
|
||||
</DivBtn>
|
||||
</div>
|
||||
|
||||
<!-- 1 -->
|
||||
<div class="row">
|
||||
<!-- 1-1 -->
|
||||
@@ -147,7 +160,7 @@
|
||||
<div class="q-mx-xs" />
|
||||
<q-input
|
||||
v-model="librateNames" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
||||
class="q-mt-xs col-1" :bg-color="inputBgColor()" input-style="cursor: pointer" style="min-width: 90px;" label="Оценка" stack-label outlined dense clearable readonly
|
||||
class="q-mt-xs col-2" :bg-color="inputBgColor()" input-style="cursor: pointer" style="min-width: 140px;" label="Оценка" stack-label outlined dense clearable readonly
|
||||
@click.stop.prevent="selectLibRate"
|
||||
>
|
||||
<template v-if="librateNames" #append>
|
||||
@@ -158,6 +171,21 @@
|
||||
{{ librateNames }}
|
||||
</q-tooltip>
|
||||
</q-input>
|
||||
|
||||
<div class="q-mx-xs" />
|
||||
<q-input
|
||||
v-model="search.ext" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
||||
class="q-mt-xs col-2" :bg-color="inputBgColor()" input-style="cursor: pointer" style="min-width: 140px;" label="Тип файла" stack-label outlined dense clearable readonly
|
||||
@click.stop.prevent="selectExt"
|
||||
>
|
||||
<template v-if="search.ext" #append>
|
||||
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.ext = ''" />
|
||||
</template>
|
||||
|
||||
<q-tooltip v-if="search.ext && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||
{{ search.ext }}
|
||||
</q-tooltip>
|
||||
</q-input>
|
||||
</div>
|
||||
<div v-show="!isExtendedSearch && !extendedParams && extendedParamsMessage" class="row q-mx-sm items-center clickable" @click.stop.prevent="extendedParams = true">
|
||||
+{{ extendedParamsMessage }}
|
||||
@@ -318,6 +346,7 @@
|
||||
<SelectLangDialog v-model="selectLangDialogVisible" v-model:lang="search.lang" :lang-list="langList" :lang-default="langDefault" />
|
||||
<SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" />
|
||||
<SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" />
|
||||
<SelectExtDialog v-model="selectExtDialogVisible" v-model:ext="search.ext" :ext-list="extList" />
|
||||
<BookInfoDialog v-model="bookInfoDialogVisible" :book-info="bookInfo" />
|
||||
<SelectExtSearchDialog v-model="selectExtSearchDialogVisible" v-model:ext-search="extSearch" />
|
||||
</div>
|
||||
@@ -338,6 +367,7 @@ import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue';
|
||||
import SelectLangDialog from './SelectLangDialog/SelectLangDialog.vue';
|
||||
import SelectLibRateDialog from './SelectLibRateDialog/SelectLibRateDialog.vue';
|
||||
import SelectDateDialog from './SelectDateDialog/SelectDateDialog.vue';
|
||||
import SelectExtDialog from './SelectExtDialog/SelectExtDialog.vue';
|
||||
import BookInfoDialog from './BookInfoDialog/BookInfoDialog.vue';
|
||||
import SelectExtSearchDialog from './SelectExtSearchDialog/SelectExtSearchDialog.vue';
|
||||
|
||||
@@ -371,6 +401,7 @@ const componentOptions = {
|
||||
SelectLangDialog,
|
||||
SelectLibRateDialog,
|
||||
SelectDateDialog,
|
||||
SelectExtDialog,
|
||||
BookInfoDialog,
|
||||
SelectExtSearchDialog,
|
||||
Dialog,
|
||||
@@ -482,6 +513,7 @@ class Search {
|
||||
selectLangDialogVisible = false;
|
||||
selectLibRateDialogVisible = false;
|
||||
selectDateDialogVisible = false;
|
||||
selectExtDialogVisible = false;
|
||||
bookInfoDialogVisible = false;
|
||||
selectExtSearchDialogVisible = false;
|
||||
|
||||
@@ -504,6 +536,7 @@ class Search {
|
||||
limit = 20;
|
||||
extendedParams = false;
|
||||
showJson = false;
|
||||
showNewReleaseAvailable = true;
|
||||
|
||||
//stuff
|
||||
prevList = {};
|
||||
@@ -517,6 +550,7 @@ class Search {
|
||||
genreTree = [];
|
||||
genreMap = new Map();
|
||||
langList = [];
|
||||
extList = [];
|
||||
genreTreeInpxHash = '';
|
||||
showTooltips = true;
|
||||
|
||||
@@ -547,7 +581,7 @@ class Search {
|
||||
this.commit = this.$store.commit;
|
||||
this.api = this.$root.api;
|
||||
|
||||
this.generateDefaults(this.search, ['author', 'series', 'title', 'genre', 'lang', 'date', 'librate']);
|
||||
this.generateDefaults(this.search, ['author', 'series', 'title', 'genre', 'lang', 'date', 'librate', 'ext']);
|
||||
this.search.setDefaults(this.search);
|
||||
|
||||
this.loadSettings();
|
||||
@@ -555,6 +589,7 @@ class Search {
|
||||
|
||||
mounted() {
|
||||
(async() => {
|
||||
//для срабатывания watch.config
|
||||
await this.api.updateConfig();
|
||||
|
||||
//устанавливаем uiDefaults от сервера, если это необходимо
|
||||
@@ -604,6 +639,7 @@ class Search {
|
||||
this.abCacheEnabled = settings.abCacheEnabled;
|
||||
this.langDefault = settings.langDefault;
|
||||
this.showJson = settings.showJson;
|
||||
this.showNewReleaseAvailable = settings.showNewReleaseAvailable;
|
||||
}
|
||||
|
||||
recvMessage(d) {
|
||||
@@ -631,6 +667,10 @@ class Search {
|
||||
return this.$store.state.config;
|
||||
}
|
||||
|
||||
get newReleaseAvailable() {
|
||||
return (this.config.latestVersion && this.config.version != this.config.latestVersion);
|
||||
}
|
||||
|
||||
get recStruct() {
|
||||
if (this.config.dbConfig && this.config.dbConfig.inpxInfo.recStruct)
|
||||
return this.config.dbConfig.inpxInfo.recStruct;
|
||||
@@ -685,6 +725,7 @@ class Search {
|
||||
result.push(s.genre ? 'Жанр' : '');
|
||||
result.push(s.date ? 'Дата поступления' : '');
|
||||
result.push(s.librate ? 'Оценка' : '');
|
||||
result.push(s.ext ? 'Тип файла' : '');
|
||||
|
||||
return result.filter(s => s).join(', ');
|
||||
}
|
||||
@@ -728,14 +769,19 @@ class Search {
|
||||
}
|
||||
|
||||
openReleasePage() {
|
||||
window.open('https://github.com/bookpauk/inpx-web/releases', '_blank');
|
||||
if (this.config.latestReleaseLink)
|
||||
window.open(this.config.latestReleaseLink, '_blank');
|
||||
}
|
||||
|
||||
makeProjectName() {
|
||||
const collection = this.config.dbConfig.inpxInfo.collection.split('\n');
|
||||
this.collection = collection[0].trim();
|
||||
|
||||
this.projectName = `${this.config.name} v${this.config.webAppVersion}`;
|
||||
let projectName = `${this.config.name} v${this.config.webAppVersion}`;
|
||||
if (this.newReleaseAvailable)
|
||||
projectName += `, доступно обновление: v${this.config.latestVersion}`;
|
||||
|
||||
this.projectName = projectName;
|
||||
this.makeTitle();
|
||||
}
|
||||
|
||||
@@ -916,6 +962,11 @@ class Search {
|
||||
this.selectLibRateDialogVisible = true;
|
||||
}
|
||||
|
||||
selectExt() {
|
||||
this.hideTooltip();
|
||||
this.selectExtDialogVisible = true;
|
||||
}
|
||||
|
||||
selectExtSearch() {
|
||||
this.hideTooltip();
|
||||
this.selectExtSearchDialogVisible = true;
|
||||
@@ -1054,6 +1105,7 @@ class Search {
|
||||
lang: (typeof(query.lang) == 'string' ? query.lang : this.langDefault),
|
||||
date: query.date,
|
||||
librate: query.librate,
|
||||
ext: query.ext,
|
||||
|
||||
page: parseInt(query.page, 10),
|
||||
limit: parseInt(query.limit, 10) || this.search.limit,
|
||||
@@ -1145,6 +1197,7 @@ class Search {
|
||||
}
|
||||
|
||||
this.langList = result.langList;
|
||||
this.extList = result.extList;
|
||||
this.genreTreeInpxHash = result.inpxHash;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
187
client/components/Search/SelectExtDialog/SelectExtDialog.vue
Normal file
187
client/components/Search/SelectExtDialog/SelectExtDialog.vue
Normal file
@@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<Dialog ref="dialog" v-model="dialogVisible">
|
||||
<template #header>
|
||||
<div class="row items-center">
|
||||
<div style="font-size: 110%">
|
||||
Выбрать типы файлов
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="width: 370px; padding: 0px 10px 10px 10px;">
|
||||
<div v-show="extList.length" class="checkbox-tick-all">
|
||||
<div class="row items-center">
|
||||
<q-option-group
|
||||
v-model="ticked"
|
||||
:options="optionsPre"
|
||||
type="checkbox"
|
||||
inline
|
||||
>
|
||||
<template #label="opt">
|
||||
<div class="row items-center" style="width: 35px">
|
||||
<span>{{ opt.label }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</q-option-group>
|
||||
</div>
|
||||
|
||||
<q-checkbox v-model="tickAll" label="Выбрать/снять все" toggle-order="ft" @update:model-value="makeTickAll" />
|
||||
</div>
|
||||
|
||||
<q-option-group
|
||||
v-model="ticked"
|
||||
:options="options"
|
||||
type="checkbox"
|
||||
>
|
||||
</q-option-group>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">
|
||||
OK
|
||||
</q-btn>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import vueComponent from '../../vueComponent.js';
|
||||
|
||||
import Dialog from '../../share/Dialog.vue';
|
||||
|
||||
const componentOptions = {
|
||||
components: {
|
||||
Dialog
|
||||
},
|
||||
watch: {
|
||||
modelValue(newValue) {
|
||||
this.dialogVisible = newValue;
|
||||
if (newValue)
|
||||
this.init();//no await
|
||||
},
|
||||
dialogVisible(newValue) {
|
||||
this.$emit('update:modelValue', newValue);
|
||||
},
|
||||
ext() {
|
||||
this.updateTicked();
|
||||
},
|
||||
ticked() {
|
||||
this.checkAllTicked();
|
||||
this.updateExt();
|
||||
},
|
||||
}
|
||||
};
|
||||
class SelectExtDialog {
|
||||
_options = componentOptions;
|
||||
_props = {
|
||||
modelValue: Boolean,
|
||||
ext: {type: String, value: ''},
|
||||
extList: Array,
|
||||
};
|
||||
|
||||
dialogVisible = false;
|
||||
|
||||
ticked = [];
|
||||
tickAll = false;
|
||||
|
||||
created() {
|
||||
this.commit = this.$store.commit;
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.updateTicked();
|
||||
}
|
||||
|
||||
async init() {
|
||||
//await this.$refs.dialog.waitShown();
|
||||
}
|
||||
|
||||
get options() {
|
||||
const result = [];
|
||||
|
||||
for (const ext of this.extList) {
|
||||
if (ext.length <= 4)
|
||||
result.push({label: ext, value: ext});
|
||||
}
|
||||
|
||||
for (const ext of this.extList) {
|
||||
if (ext.length > 4)
|
||||
result.push({label: ext, value: ext});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
get optionsPre() {
|
||||
const result = [];
|
||||
|
||||
for (const ext of ['fb2', 'epub', 'mobi', 'pdf', 'djvu', 'doc', 'docx', 'rtf', 'xml', 'html', 'txt', 'zip']) {
|
||||
if (this.extList.includes(ext)) {
|
||||
result.push({label: ext, value: ext});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
makeTickAll() {
|
||||
if (this.tickAll) {
|
||||
const newTicked = [];
|
||||
for (const ext of this.extList) {
|
||||
newTicked.push(ext);
|
||||
}
|
||||
this.ticked = newTicked;
|
||||
} else {
|
||||
this.ticked = [];
|
||||
this.tickAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
checkAllTicked() {
|
||||
const ticked = new Set(this.ticked);
|
||||
|
||||
let newTickAll = !!(this.extList.length);
|
||||
for (const ext of this.extList) {
|
||||
if (!ticked.has(ext)) {
|
||||
newTickAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ticked.length && !newTickAll) {
|
||||
this.tickAll = undefined;
|
||||
} else {
|
||||
this.tickAll = newTickAll;
|
||||
}
|
||||
}
|
||||
|
||||
updateTicked() {
|
||||
this.ticked = this.ext.split('|').filter(s => s);
|
||||
}
|
||||
|
||||
updateExt() {
|
||||
this.$emit('update:ext', this.ticked.join('|'));
|
||||
}
|
||||
|
||||
okClick() {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
export default vueComponent(SelectExtDialog);
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.checkbox-tick-all {
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
margin-bottom: 7px;
|
||||
padding: 5px 5px 2px 0px;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
color: blue;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -145,7 +145,7 @@ class SelectExtSearchDialog {
|
||||
Атрибуты можно увидеть, если включить опцию "Показывать JSON".
|
||||
Названия атрибутов (кроме "_uid" и "id") соответствуют названиям полей струкутры записей из inpx-файла.
|
||||
На поисковые значения действуют те же правила, что и для разделов "Авторы", "Серии", "Книги".
|
||||
<br>
|
||||
<br><br>
|
||||
Для строковых значений (S):
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -96,9 +96,9 @@
|
||||
</div>
|
||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||
|
||||
<div v-if="!refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<div v-if="!refreshing && (!tableData.length || error)" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
||||
Поиск не дал результатов
|
||||
{{ (error ? error : 'Поиск не дал результатов') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -234,6 +234,7 @@ class SeriesList extends BaseList {
|
||||
if (this.refreshing)
|
||||
return;
|
||||
|
||||
this.error = '';
|
||||
this.refreshing = true;
|
||||
|
||||
(async() => {
|
||||
@@ -263,7 +264,12 @@ class SeriesList extends BaseList {
|
||||
this.highlightPageScroller(query);
|
||||
}
|
||||
} catch (e) {
|
||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.list.queryFound = 0;
|
||||
this.list.totalFound = 0;
|
||||
this.searchResult = {found: []};
|
||||
await this.updateTableData();
|
||||
//this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.error = `Ошибка: ${e.message}`;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<q-checkbox v-show="config.latestVersion" v-model="showNewReleaseAvailable" size="36px" label="Уведомлять о выходе новой версии" />
|
||||
<q-checkbox v-model="downloadAsZip" size="36px" label="Скачивать книги в виде zip-архива" />
|
||||
<q-checkbox v-model="showCounts" size="36px" label="Показывать количество" />
|
||||
<q-checkbox v-model="showRates" size="36px" label="Показывать оценки" />
|
||||
@@ -85,6 +86,9 @@ const componentOptions = {
|
||||
abCacheEnabled(newValue) {
|
||||
this.commit('setSettings', {'abCacheEnabled': newValue});
|
||||
},
|
||||
showNewReleaseAvailable(newValue) {
|
||||
this.commit('setSettings', {'showNewReleaseAvailable': newValue});
|
||||
},
|
||||
}
|
||||
};
|
||||
class SettingsDialog {
|
||||
@@ -105,6 +109,7 @@ class SettingsDialog {
|
||||
showDates = true;
|
||||
showDeleted = false;
|
||||
abCacheEnabled = true;
|
||||
showNewReleaseAvailable = true;
|
||||
|
||||
limitOptions = [
|
||||
{label: '10', value: 10},
|
||||
@@ -125,6 +130,10 @@ class SettingsDialog {
|
||||
mounted() {
|
||||
}
|
||||
|
||||
get config() {
|
||||
return this.$store.state.config;
|
||||
}
|
||||
|
||||
get settings() {
|
||||
return this.$store.state.settings;
|
||||
}
|
||||
@@ -142,6 +151,7 @@ class SettingsDialog {
|
||||
this.showDates = settings.showDates;
|
||||
this.showDeleted = settings.showDeleted;
|
||||
this.abCacheEnabled = settings.abCacheEnabled;
|
||||
this.showNewReleaseAvailable = settings.showNewReleaseAvailable;
|
||||
}
|
||||
|
||||
okClick() {
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
</div>
|
||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||
|
||||
<div v-if="!refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<div v-if="!refreshing && (!tableData.length || error)" class="row items-center q-ml-md" style="font-size: 120%">
|
||||
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
||||
Поиск не дал результатов
|
||||
{{ (error ? error : 'Поиск не дал результатов') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -95,6 +95,7 @@ class TitleList extends BaseList {
|
||||
if (this.refreshing)
|
||||
return;
|
||||
|
||||
this.error = '';
|
||||
this.refreshing = true;
|
||||
|
||||
(async() => {
|
||||
@@ -124,7 +125,12 @@ class TitleList extends BaseList {
|
||||
this.highlightPageScroller(query);
|
||||
}
|
||||
} catch (e) {
|
||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.list.queryFound = 0;
|
||||
this.list.totalFound = 0;
|
||||
this.searchResult = {found: []};
|
||||
await this.updateTableData();
|
||||
//this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
this.error = `Ошибка: ${e.message}`;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -89,8 +89,10 @@ export default vueComponent(DivBtn);
|
||||
}
|
||||
|
||||
.button-pressed {
|
||||
margin-left: 2px;
|
||||
margin-top: 2px;
|
||||
margin-left: 1px;
|
||||
margin-top: 1px;
|
||||
margin-right: -1px;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
|
||||
@@ -87,35 +87,6 @@ export async function copyTextToClipboard(text) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
export function formatDate(d, format = 'normal') {
|
||||
switch (format) {
|
||||
case 'normal':
|
||||
return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()} ` +
|
||||
`${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}`;
|
||||
case 'coDate':
|
||||
return `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
|
||||
case 'coMonth':
|
||||
return `${(d.getMonth() + 1).toString().padStart(2, '0')}`;
|
||||
case 'noDate':
|
||||
return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()}`;
|
||||
|
||||
default:
|
||||
throw new Error('formatDate: unknown date format');
|
||||
}
|
||||
}
|
||||
|
||||
export function parseDate(sqlDate) {
|
||||
const d = sqlDate.split('-');
|
||||
const result = new Date();
|
||||
result.setDate(parseInt(d[2], 10));
|
||||
result.setMonth(parseInt(d[1], 10) - 1);
|
||||
result.setYear(parseInt(d[0], 10));
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
export function isDigit(c) {
|
||||
return !isNaN(parseInt(c, 10));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ const state = {
|
||||
abCacheEnabled: true,
|
||||
langDefault: '',
|
||||
showJson: false,
|
||||
showNewReleaseAvailable: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "inpx-web",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "inpx-web",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.4",
|
||||
"hasInstallScript": true,
|
||||
"license": "CC0-1.0",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "inpx-web",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.4",
|
||||
"author": "Book Pauk <bookpauk@gmail.com>",
|
||||
"license": "CC0-1.0",
|
||||
"repository": "bookpauk/inpx-web",
|
||||
|
||||
@@ -6,6 +6,7 @@ const execDir = path.resolve(__dirname, '..');
|
||||
module.exports = {
|
||||
branch: 'unknown',
|
||||
version: pckg.version,
|
||||
latestVersion: '',
|
||||
name: pckg.name,
|
||||
|
||||
execDir,
|
||||
@@ -19,8 +20,8 @@ module.exports = {
|
||||
loggingEnabled: true,
|
||||
|
||||
//поправить в случае, если были критические изменения в DbCreator или InpxParser
|
||||
//иначе будет рассинхронизация между сервером и клиентом на уровне БД
|
||||
dbVersion: '11',
|
||||
//иначе будет рассинхронизация по кешу между сервером и клиентом на уровне БД
|
||||
dbVersion: '12',
|
||||
dbCacheSize: 5,
|
||||
|
||||
maxPayloadSize: 500,//in MB
|
||||
@@ -33,7 +34,7 @@ module.exports = {
|
||||
lowMemoryMode: false,
|
||||
fullOptimization: false,
|
||||
|
||||
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch', 'uiDefaults'],
|
||||
webConfigParams: ['name', 'version', 'latestVersion', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch', 'latestReleaseLink', 'uiDefaults'],
|
||||
|
||||
allowRemoteLib: false,
|
||||
remoteLib: false,
|
||||
@@ -57,6 +58,10 @@ module.exports = {
|
||||
password: '',
|
||||
root: '/opds',
|
||||
},
|
||||
|
||||
latestReleaseLink: 'https://github.com/bookpauk/inpx-web/releases/latest',
|
||||
checkReleaseLink: 'https://api.github.com/repos/bookpauk/inpx-web/releases/latest',
|
||||
|
||||
uiDefaults: {
|
||||
limit: 20,
|
||||
downloadAsZip: false,
|
||||
@@ -69,6 +74,7 @@ module.exports = {
|
||||
abCacheEnabled: true,
|
||||
langDefault: '',
|
||||
showJson: false,
|
||||
showNewReleaseAvailable: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ const propsToSave = [
|
||||
'remoteLib',
|
||||
'server',
|
||||
'opds',
|
||||
'latestReleaseLink',
|
||||
'checkReleaseLink',
|
||||
'uiDefaults',
|
||||
];
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ class DbCreator {
|
||||
let dateArr = [];
|
||||
let librateMap = new Map();//оценка
|
||||
let librateArr = [];
|
||||
let extMap = new Map();//тип файла
|
||||
let extArr = [];
|
||||
|
||||
let uidSet = new Set();//уникальные идентификаторы
|
||||
|
||||
@@ -215,6 +217,9 @@ class DbCreator {
|
||||
|
||||
//оценка
|
||||
parseField(rec.librate, librateMap, librateArr, rec.id);
|
||||
|
||||
//тип файла
|
||||
parseField(rec.ext, extMap, extArr, rec.id);
|
||||
};
|
||||
|
||||
//основная процедура парсинга
|
||||
@@ -272,6 +277,8 @@ class DbCreator {
|
||||
delMap = null;
|
||||
dateMap = null;
|
||||
librateMap = null;
|
||||
extMap = null;
|
||||
|
||||
uidSet = null;
|
||||
|
||||
await db.close({table: 'book'});
|
||||
@@ -408,6 +415,9 @@ class DbCreator {
|
||||
//librate
|
||||
await saveTable('librate', librateArr, () => {librateArr = null}, 'number');
|
||||
|
||||
//ext
|
||||
await saveTable('ext', extArr, () => {extArr = null});
|
||||
|
||||
//кэш-таблицы запросов
|
||||
await db.create({table: 'query_cache'});
|
||||
await db.create({table: 'query_time'});
|
||||
|
||||
@@ -49,7 +49,8 @@ class DbSearcher {
|
||||
getWhere(a) {
|
||||
const db = this.db;
|
||||
|
||||
a = a.toLowerCase();
|
||||
if (a[0] !== '~')
|
||||
a = a.toLowerCase();
|
||||
let where;
|
||||
|
||||
//особая обработка префиксов
|
||||
@@ -288,6 +289,42 @@ class DbSearcher {
|
||||
idsArr.push(ids);
|
||||
}
|
||||
|
||||
//тип файла
|
||||
if (query.ext) {
|
||||
const key = `book-ids-ext-${query.ext}`;
|
||||
let ids = await this.getCached(key);
|
||||
|
||||
if (ids === null) {
|
||||
const extRows = await db.select({
|
||||
table: 'ext',
|
||||
rawResult: true,
|
||||
where: `
|
||||
const exts = ${db.esc(query.ext.split('|'))};
|
||||
|
||||
const ids = new Set();
|
||||
for (const l of exts) {
|
||||
for (const id of @indexLR('value', l, l))
|
||||
ids.add(id);
|
||||
}
|
||||
|
||||
const result = new Set();
|
||||
for (const id of ids) {
|
||||
const row = @unsafeRow(id);
|
||||
for (const bookId of row.bookIds)
|
||||
result.add(bookId);
|
||||
}
|
||||
|
||||
return new Uint32Array(result);
|
||||
`
|
||||
});
|
||||
|
||||
ids = extRows[0].rawResult;
|
||||
await this.putCached(key, ids);
|
||||
}
|
||||
|
||||
idsArr.push(ids);
|
||||
}
|
||||
|
||||
if (idsArr.length > 1) {
|
||||
//ищем пересечение множеств
|
||||
let proc = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ const DbCreator = require('./DbCreator');
|
||||
const DbSearcher = require('./DbSearcher');
|
||||
const InpxHashCreator = require('./InpxHashCreator');
|
||||
const RemoteLib = require('./RemoteLib');//singleton
|
||||
const FileDownloader = require('./FileDownloader');
|
||||
|
||||
const asyncExit = new (require('./AsyncExit'))();
|
||||
const log = new (require('./AppLogger'))().log;//singleton
|
||||
@@ -28,7 +29,8 @@ const stateToText = {
|
||||
[ssDbCreating]: 'Создание поисковой базы',
|
||||
};
|
||||
|
||||
const cleanDirPeriod = 60*60*1000;//каждый час
|
||||
const cleanDirInterval = 60*60*1000;//каждый час
|
||||
const checkReleaseInterval = 7*60*60*1000;//каждые 7 часов
|
||||
|
||||
//singleton
|
||||
let instance = null;
|
||||
@@ -67,6 +69,7 @@ class WebWorker {
|
||||
|
||||
this.periodicCleanDir(dirConfig);//no await
|
||||
this.periodicCheckInpx();//no await
|
||||
this.periodicCheckNewRelease();//no await
|
||||
|
||||
instance = this;
|
||||
}
|
||||
@@ -347,9 +350,14 @@ class WebWorker {
|
||||
rows = await db.select({table: 'lang', map: `(r) => ({value: r.value})`});
|
||||
const langs = rows.map(r => r.value);
|
||||
|
||||
// exts
|
||||
rows = await db.select({table: 'ext', map: `(r) => ({value: r.value})`});
|
||||
const exts = rows.map(r => r.value);
|
||||
|
||||
result = {
|
||||
genreTree: genres,
|
||||
langList: langs,
|
||||
extList: exts,
|
||||
inpxHash: (config.inpxHash ? config.inpxHash : ''),
|
||||
};
|
||||
|
||||
@@ -364,17 +372,28 @@ class WebWorker {
|
||||
async extractBook(bookPath) {
|
||||
const outFile = `${this.config.tempDir}/${utils.randomHexString(30)}`;
|
||||
|
||||
const folder = `${this.config.libDir}/${path.dirname(bookPath)}`;
|
||||
const file = path.basename(bookPath);
|
||||
bookPath = bookPath.replace(/\\/g, '/').replace(/\/\//g, '/');
|
||||
|
||||
const zipReader = new ZipReader();
|
||||
await zipReader.open(folder);
|
||||
const i = bookPath.indexOf('/');
|
||||
const folder = `${this.config.libDir}/${(i >= 0 ? bookPath.substring(0, i) : bookPath )}`;
|
||||
const file = (i >= 0 ? bookPath.substring(i + 1) : '' );
|
||||
|
||||
try {
|
||||
await zipReader.extractToFile(file, outFile);
|
||||
const fullPath = `${folder}/${file}`;
|
||||
|
||||
if (!file || await fs.pathExists(fullPath)) {// файл есть на диске
|
||||
|
||||
await fs.copy(fullPath, outFile);
|
||||
return outFile;
|
||||
} finally {
|
||||
await zipReader.close();
|
||||
} else {// файл в zip-архиве
|
||||
const zipReader = new ZipReader();
|
||||
await zipReader.open(folder);
|
||||
|
||||
try {
|
||||
await zipReader.extractToFile(file, outFile);
|
||||
return outFile;
|
||||
} finally {
|
||||
await zipReader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,7 +657,7 @@ class WebWorker {
|
||||
let lastCleanDirTime = 0;
|
||||
while (1) {// eslint-disable-line no-constant-condition
|
||||
//чистка папок
|
||||
if (Date.now() - lastCleanDirTime >= cleanDirPeriod) {
|
||||
if (Date.now() - lastCleanDirTime >= cleanDirInterval) {
|
||||
for (const config of dirConfig) {
|
||||
try {
|
||||
await this.cleanDir(config);
|
||||
@@ -690,6 +709,27 @@ class WebWorker {
|
||||
await utils.sleep(inpxCheckInterval*60*1000);
|
||||
}
|
||||
}
|
||||
|
||||
async periodicCheckNewRelease() {
|
||||
const checkReleaseLink = this.config.checkReleaseLink;
|
||||
if (!checkReleaseLink)
|
||||
return;
|
||||
const down = new FileDownloader(1024*1024);
|
||||
|
||||
while (1) {// eslint-disable-line no-constant-condition
|
||||
try {
|
||||
let release = await down.load(checkReleaseLink);
|
||||
release = JSON.parse(release.toString());
|
||||
|
||||
if (release.tag_name)
|
||||
this.config.latestVersion = release.tag_name;
|
||||
} catch(e) {
|
||||
log(LM_ERR, `periodicCheckNewRelease: ${e.message}`);
|
||||
}
|
||||
|
||||
await utils.sleep(checkReleaseInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebWorker;
|
||||
@@ -35,7 +35,7 @@ class Fb2Helper {
|
||||
if (m) {
|
||||
let enc = m[1].toLowerCase();
|
||||
if (enc != 'utf-8') {
|
||||
//enc может не соответсвовать реальной кодировке файла, поэтому:
|
||||
//если кодировка не определена в getEncoding, используем enc
|
||||
if (encoding.indexOf('ISO-8859') >= 0) {
|
||||
encoding = enc;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ function getEncoding(buf) {
|
||||
let selected = getEncodingLite(buf);
|
||||
|
||||
if (selected == 'ISO-8859-5' && buf.length > 10) {
|
||||
const charsetAll = chardet.analyse(buf.slice(0, 20000));
|
||||
const charsetAll = chardet.analyse(buf.slice(0, 100000));
|
||||
for (const charset of charsetAll) {
|
||||
if (charset.name.indexOf('ISO-8859') < 0) {
|
||||
selected = charset.name;
|
||||
@@ -39,9 +39,7 @@ function getEncodingLite(buf, returnAll) {
|
||||
'u': 0,
|
||||
};
|
||||
|
||||
const len = buf.length;
|
||||
const blockSize = (len > 5*3000 ? 3000 : len);
|
||||
let counter = 0;
|
||||
const len = (buf.length > 100000 ? 100000 : buf.length);
|
||||
let i = 0;
|
||||
let totalChecked = 0;
|
||||
while (i < len) {
|
||||
@@ -76,13 +74,6 @@ function getEncodingLite(buf, returnAll) {
|
||||
if (char > 207 && char < 240) charsets['i'] += lowerCase;
|
||||
if (char > 175 && char < 208) charsets['i'] += upperCase;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if (counter > blockSize) {
|
||||
counter = 0;
|
||||
i += Math.round(len/2 - 2*blockSize);
|
||||
}
|
||||
}
|
||||
|
||||
let sorted = Object.keys(charsets).map(function(key) {
|
||||
|
||||
@@ -24,13 +24,18 @@ class BasePage {
|
||||
this.showDeleted = false;
|
||||
}
|
||||
|
||||
escape(s) {
|
||||
//костыль для koreader, не понимает hex-экранирование вида '
|
||||
return he.escape(s).replace(/'/g, ''').replace(/`/g, '`');
|
||||
}
|
||||
|
||||
makeEntry(entry = {}) {
|
||||
if (!entry.id)
|
||||
throw new Error('makeEntry: no id');
|
||||
if (!entry.title)
|
||||
throw new Error('makeEntry: no title');
|
||||
|
||||
entry.title = he.escape(entry.title);
|
||||
entry.title = this.escape(entry.title);
|
||||
|
||||
const result = {
|
||||
updated: (new Date()).toISOString().substring(0, 19) + 'Z',
|
||||
@@ -48,7 +53,7 @@ class BasePage {
|
||||
}
|
||||
|
||||
makeLink(attrs) {
|
||||
attrs.href = he.escape(attrs.href);
|
||||
attrs.href = this.escape(attrs.href);
|
||||
return {'*ATTRS': attrs};
|
||||
}
|
||||
|
||||
@@ -238,7 +243,8 @@ class BasePage {
|
||||
bookValue = emptyFieldValue;
|
||||
|
||||
bookValue = bookValue.toLowerCase();
|
||||
searchValue = searchValue.toLowerCase();
|
||||
if (searchValue[0] !== '~')
|
||||
searchValue = searchValue.toLowerCase();
|
||||
|
||||
//особая обработка префиксов
|
||||
if (searchValue[0] == '=') {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const he = require('he');
|
||||
const dayjs = require('dayjs');
|
||||
|
||||
const BasePage = require('./BasePage');
|
||||
@@ -131,15 +130,15 @@ class BookPage extends BasePage {
|
||||
|
||||
//format
|
||||
const ext = bookInfo.book.ext;
|
||||
let fileFormat = `${ext}+zip`;
|
||||
let downHref = bookInfo.link;
|
||||
const formats = {
|
||||
[`${ext}+zip`]: `${bookInfo.link}/zip`,
|
||||
[ext]: bookInfo.link,
|
||||
};
|
||||
|
||||
if (ext === 'mobi') {
|
||||
fileFormat = 'x-mobipocket-ebook';
|
||||
formats['x-mobipocket-ebook'] = bookInfo.link;
|
||||
} else if (ext == 'epub') {
|
||||
//
|
||||
} else {
|
||||
downHref = `${bookInfo.link}/zip`;
|
||||
formats[`${ext}+zip`] = bookInfo.link;
|
||||
}
|
||||
|
||||
//entry
|
||||
@@ -148,8 +147,13 @@ class BookPage extends BasePage {
|
||||
title: bookInfo.book.title || 'Без названия',
|
||||
});
|
||||
|
||||
//author bookInfo
|
||||
if (bookInfo.book.author) {
|
||||
e.author = bookInfo.book.author.split(',').map(a => ({name: a}));
|
||||
}
|
||||
|
||||
e['dc:language'] = bookInfo.book.lang;
|
||||
e['dc:format'] = fileFormat;
|
||||
e['dc:format'] = ext;
|
||||
|
||||
//genre
|
||||
const genre = bookInfo.book.genre.split(',');
|
||||
@@ -173,7 +177,8 @@ class BookPage extends BasePage {
|
||||
const infoObj = parser.bookInfo();
|
||||
|
||||
if (infoObj.titleInfo) {
|
||||
if (infoObj.titleInfo.author.length) {
|
||||
//author fb2Info
|
||||
if (!e.author && infoObj.titleInfo.author.length) {
|
||||
e.author = infoObj.titleInfo.author.map(a => ({name: a}));
|
||||
}
|
||||
|
||||
@@ -190,12 +195,15 @@ class BookPage extends BasePage {
|
||||
if (content) {
|
||||
e.content = {
|
||||
'*ATTRS': {type: 'text/html'},
|
||||
'*TEXT': he.escape(content),
|
||||
'*TEXT': this.escape(content),
|
||||
};
|
||||
}
|
||||
|
||||
//links
|
||||
e.link = [ this.downLink({href: downHref, type: `application/${fileFormat}`}) ];
|
||||
e.link = [];
|
||||
for (const [fileFormat, downHref] of Object.entries(formats))
|
||||
e.link.push(this.downLink({href: downHref, type: `application/${fileFormat}`}));
|
||||
|
||||
if (bookInfo.cover) {
|
||||
let coverType = 'image/jpeg';
|
||||
if (path.extname(bookInfo.cover) == '.png')
|
||||
|
||||
@@ -14,7 +14,7 @@ class GenrePage extends BasePage {
|
||||
|
||||
const query = {
|
||||
from: req.query.from || 'search',
|
||||
term: req.query.term || '*',
|
||||
term: req.query.term || '',
|
||||
section: req.query.section || '',
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const he = require('he');
|
||||
|
||||
const BasePage = require('./BasePage');
|
||||
|
||||
class SearchHelpPage extends BasePage {
|
||||
@@ -45,7 +43,7 @@ class SearchHelpPage extends BasePage {
|
||||
title: this.title,
|
||||
content: {
|
||||
'*ATTRS': {type: 'text/html'},
|
||||
'*TEXT': he.escape(content),
|
||||
'*TEXT': this.escape(content),
|
||||
},
|
||||
link: [
|
||||
this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const BasePage = require('./BasePage');
|
||||
const utils = require('../utils');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
class SearchPage extends BasePage {
|
||||
constructor(config) {
|
||||
@@ -28,7 +29,14 @@ class SearchPage extends BasePage {
|
||||
|
||||
const limit = 100;
|
||||
const offset = (page - 1)*limit;
|
||||
const queryRes = await this.webWorker.search(from, {[from]: query.term, genre: query.genre, del: '0', offset, limit});
|
||||
|
||||
const searchQuery = {[from]: query.term, genre: query.genre, del: '0', offset, limit};
|
||||
let queryRes = await this.webWorker.search(from, searchQuery);
|
||||
|
||||
if (queryRes.totalFound === 0) { // не нашли ничего, проверим, может term в кодировке ISO-8859-1 (баг koreader)
|
||||
searchQuery[from] = iconv.encode(query.term, 'ISO-8859-1').toString();
|
||||
queryRes = await this.webWorker.search(from, searchQuery);
|
||||
}
|
||||
|
||||
const found = queryRes.found;
|
||||
|
||||
@@ -55,7 +63,7 @@ class SearchPage extends BasePage {
|
||||
this.makeEntry({
|
||||
id: 'next_page',
|
||||
title: '[Следующая страница]',
|
||||
link: this.navLink({href: `/${this.id}?type=${from}&term=${encodeURIComponent(query.term)}&page=${page + 1}`}),
|
||||
link: this.navLink({href: `/${this.id}?type=${from}&term=${encodeURIComponent(query.term)}&genre=${encodeURIComponent(query.genre)}&page=${page + 1}`}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ const OpensearchPage = require('./OpensearchPage');
|
||||
const SearchPage = require('./SearchPage');
|
||||
const SearchHelpPage = require('./SearchHelpPage');
|
||||
|
||||
const log = new (require('../AppLogger'))().log;//singleton
|
||||
|
||||
module.exports = function(app, config) {
|
||||
if (!config.opds || !config.opds.enabled)
|
||||
return;
|
||||
@@ -63,10 +65,8 @@ module.exports = function(app, config) {
|
||||
next();
|
||||
}
|
||||
} catch (e) {
|
||||
log(LM_ERR, `OPDS: ${e.message}, url: ${req.originalUrl}`);
|
||||
res.status(500).send({error: e.message});
|
||||
if (config.branch == 'development') {
|
||||
console.error({error: e.message, url: req.originalUrl});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user