Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
636e34bdc1 | ||
|
|
2c687c7af9 | ||
|
|
27fc46c410 | ||
|
|
a7cd019a97 | ||
|
|
12304c13a1 | ||
|
|
d87e2ce632 | ||
|
|
a2423fb704 | ||
|
|
192b92cab8 | ||
|
|
386a937239 | ||
|
|
06300e30b4 | ||
|
|
371d5646ae | ||
|
|
0d52a9fd52 | ||
|
|
08287deaa4 | ||
|
|
c43c5520a4 | ||
|
|
4e2b7886a9 | ||
|
|
05744e8472 | ||
|
|
9126973378 | ||
|
|
018e1069d5 | ||
|
|
92617b3263 | ||
|
|
d0172f11c3 | ||
|
|
638126b5f3 | ||
|
|
ef938bff77 | ||
|
|
50597f8d3a | ||
|
|
b84e26fa3b | ||
|
|
d8ac700ee7 | ||
|
|
5519e23e02 | ||
|
|
4d6da6a9b7 | ||
|
|
1385babea5 | ||
|
|
ed916e1b28 | ||
|
|
97c18a290a | ||
|
|
e53bb11566 | ||
|
|
1ecc19b8b5 | ||
|
|
7ef1520756 | ||
|
|
5a5ea147b1 | ||
|
|
5a15241cc1 | ||
|
|
4a8035949c | ||
|
|
ab57dbfbe7 | ||
|
|
302dd8eeb4 | ||
|
|
e983db84ba | ||
|
|
51c026e9d2 | ||
|
|
435b425ab6 | ||
|
|
0981a36fb5 | ||
|
|
3292f35310 | ||
|
|
f85c126d03 | ||
|
|
2cc753f6d0 | ||
|
|
cb26aff4b9 | ||
|
|
ac1be219fb | ||
|
|
b34d915597 | ||
|
|
a2db43bbe1 | ||
|
|
024a5f9b8c | ||
|
|
070c667605 | ||
|
|
6e2ff07a48 | ||
|
|
46f40d29be | ||
|
|
71f2674b38 | ||
|
|
bd2551559b | ||
|
|
85bf7296ef | ||
|
|
64254ccf5f | ||
|
|
48b973d384 | ||
|
|
c17b696d61 | ||
|
|
8837fea654 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/server/.inpx-web*
|
/server/.inpx-web*
|
||||||
/server/inpx-web-filter.json
|
|
||||||
/dist
|
/dist
|
||||||
dev*.sh
|
dev*.sh
|
||||||
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,5 +1,32 @@
|
|||||||
|
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)
|
||||||
|
- Уменьшена длина имени файла при скачивании (#7)
|
||||||
|
- OPDS: добавлен раздел "Жанры", в поиск добавлен раздел "Поиск книг в жанре" (#9)
|
||||||
|
- Исправление проблем скроллинга панели инструментов (#12)
|
||||||
|
- Улучшено отображение веб-интерфейса на мобильных устройствах
|
||||||
|
|
||||||
|
1.4.1 / 2022-12-21
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Добавлена возможность поиска по регулярному выражению (префикс "~")
|
||||||
|
- Заплатка для исправления (#10)
|
||||||
|
|
||||||
1.4.0 / 2022-12-07
|
1.4.0 / 2022-12-07
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
- Добавлена возможность расширенного поиска (раздел "</>"). Поиск не оптимизирован и может сильно нагружать сервер.
|
- Добавлена возможность расширенного поиска (раздел "</>"). Поиск не оптимизирован и может сильно нагружать сервер.
|
||||||
Отключить можно в конфиге, параметр extendedSearch
|
Отключить можно в конфиге, параметр extendedSearch
|
||||||
- Улучшение поддержки reverse-proxy, в конфиг добавлены параметры server.root и opds.root для встраивания inpx-web в уже существующий веб-сервер
|
- Улучшение поддержки reverse-proxy, в конфиг добавлены параметры server.root и opds.root для встраивания inpx-web в уже существующий веб-сервер
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -80,6 +80,14 @@ Options:
|
|||||||
При первом запуске в рабочей директории будет создан конфигурационный файл `config.json`:
|
При первом запуске в рабочей директории будет создан конфигурационный файл `config.json`:
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
// директория библиотеки (с zip-архивами), аналог параметра командной строки --lib-dir
|
||||||
|
// пустая строка: использовать значение по умолчанию - директорию файла приложения
|
||||||
|
"libDir": "",
|
||||||
|
|
||||||
|
// путь к файлу .inpx, аналог параметра командной строки --inpx
|
||||||
|
// пустая строка: использовать значение по умолчанию - inpx-файл, что найдется в директории библиотеки
|
||||||
|
"inpx": "",
|
||||||
|
|
||||||
// пароль для ограничения доступа к веб-интерфейсу сервера
|
// пароль для ограничения доступа к веб-интерфейсу сервера
|
||||||
// пустое значение - доступ без ограничений
|
// пустое значение - доступ без ограничений
|
||||||
"accessPassword": "",
|
"accessPassword": "",
|
||||||
@@ -164,6 +172,31 @@ Options:
|
|||||||
"user": "",
|
"user": "",
|
||||||
"password": "",
|
"password": "",
|
||||||
"root": "/opds"
|
"root": "/opds"
|
||||||
|
},
|
||||||
|
|
||||||
|
// страница для скачивания свежего релиза
|
||||||
|
"latestReleaseLink": "https://github.com/bookpauk/inpx-web/releases/latest",
|
||||||
|
|
||||||
|
// api для проверки новой версии,
|
||||||
|
// пустая строка - отключить проверку выхода новых версий
|
||||||
|
"checkReleaseLink": "https://api.github.com/repos/bookpauk/inpx-web/releases/latest",
|
||||||
|
|
||||||
|
// настройки по умолчанию для веб-интерфейса
|
||||||
|
// устанавливаются при первой загрузке страницы в браузере
|
||||||
|
// дальнейшие изменения настроек с помощью веб-интерфейса уже сохраняются в самом браузере
|
||||||
|
"uiDefaults": {
|
||||||
|
"limit": 20, // результатов на странице
|
||||||
|
"downloadAsZip": false, // скачивать книги в виде zip-архива
|
||||||
|
"showCounts": true, // показывать количество
|
||||||
|
"showRates": true, // показывать оценки
|
||||||
|
"showInfo": true, // показывать кнопку (инфо)
|
||||||
|
"showGenres": true, // показывать жанры
|
||||||
|
"showDates": false, // показывать даты поступления
|
||||||
|
"showDeleted": false, // показывать удаленные
|
||||||
|
"abCacheEnabled": true, // кешировать запросы
|
||||||
|
"langDefault": "", // язык по умолчанию (например "ru,en")
|
||||||
|
"showJson": false, // показывать JSON (в расширенном поиске)
|
||||||
|
"showNewReleaseAvailable": true // уведомлять о выходе новой версии
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -197,8 +197,12 @@ class AuthorList extends BaseList {
|
|||||||
result = `${count}`;
|
result = `${count}`;
|
||||||
if (item.seriesLoaded) {
|
if (item.seriesLoaded) {
|
||||||
const rec = item.seriesLoaded[book.series];
|
const rec = item.seriesLoaded[book.series];
|
||||||
const totalCount = (this.showDeleted ? rec.bookCount + rec.bookDelCount : rec.bookCount);
|
// заплатка для исправления https://github.com/bookpauk/inpx-web/issues/10
|
||||||
result += `/${totalCount}`;
|
// по невыясненным причинам rec иногда равен undefined
|
||||||
|
if (rec) {
|
||||||
|
const totalCount = (this.showDeleted ? rec.bookCount + rec.bookDelCount : rec.bookCount);
|
||||||
|
result += `/${totalCount}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `(${result})`;
|
return `(${result})`;
|
||||||
|
|||||||
@@ -385,7 +385,14 @@ export default class BaseList {
|
|||||||
} else if (searchValue[0] == '#') {
|
} else if (searchValue[0] == '#') {
|
||||||
|
|
||||||
searchValue = searchValue.substring(1);
|
searchValue = searchValue.substring(1);
|
||||||
return !bookValue || (bookValue !== emptyFieldValue && !enru.has(bookValue[0]) && bookValue.indexOf(searchValue) >= 0);
|
if (!bookValue)
|
||||||
|
return false;
|
||||||
|
return bookValue !== emptyFieldValue && !enru.has(bookValue[0]) && bookValue.indexOf(searchValue) >= 0;
|
||||||
|
} else if (searchValue[0] == '~') {//RegExp
|
||||||
|
|
||||||
|
searchValue = searchValue.substring(1);
|
||||||
|
const re = new RegExp(searchValue, 'i');
|
||||||
|
return re.test(bookValue);
|
||||||
} else {
|
} else {
|
||||||
//where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
//where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
||||||
return bookValue.localeCompare(searchValue) >= 0 && bookValue.localeCompare(searchValue + maxUtf8Char) <= 0;
|
return bookValue.localeCompare(searchValue) >= 0 && bookValue.localeCompare(searchValue + maxUtf8Char) <= 0;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<div class="row q-mt-sm no-wrap">
|
<div class="row q-mt-sm no-wrap">
|
||||||
<div class="poster-size">
|
<div class="poster-size">
|
||||||
<div class="poster-size column justify-center items-center" :class="{poster: coverSrc}" @click.stop.prevent="posterClick">
|
<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 = ''" />
|
<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" style="border: 1px solid #ccc; font-size: 300%">
|
||||||
<i>{{ book.ext }}</i>
|
<i>{{ book.ext }}</i>
|
||||||
@@ -317,7 +317,7 @@ export default vueComponent(BookInfoDialog);
|
|||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.poster {
|
.poster, .no-poster {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,286 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="root column fit" style="position: relative">
|
<div class="root column fit" style="position: relative">
|
||||||
<div ref="scroller" class="col fit column no-wrap" style="overflow: auto; position: relative" @scroll="onScroll">
|
<div ref="scroller" class="col fit column no-wrap" style="overflow: auto; position: relative" @scroll="onScroll">
|
||||||
<div ref="toolPanel" class="tool-panel q-pb-xs column bg-cyan-2" style="position: sticky; top: 0; z-index: 10;">
|
<!-- Tool Panel begin -->
|
||||||
<div class="header q-mx-md q-mb-xs q-mt-sm row items-center">
|
<div ref="toolPanel" class="tool-panel column bg-cyan-2" style="position: sticky; top: 0; z-index: 10;">
|
||||||
<a :href="newSearchLink" style="height: 33px; width: 34px">
|
<!-- Обновление -->
|
||||||
<img src="./assets/logo.png" />
|
<div v-show="showNewReleaseAvailable && newReleaseAvailable" class="row q-py-sm bg-green-4 items-center">
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
<div class="q-ml-sm" style="font-size: 120%">
|
||||||
Новый поиск
|
Доступна новая версия <b>{{ config.name }} v{{ config.latestVersion }}</b>
|
||||||
</q-tooltip>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<q-btn-toggle
|
|
||||||
v-model="selectedList"
|
|
||||||
class="q-ml-sm"
|
|
||||||
toggle-color="primary"
|
|
||||||
:options="listOptions"
|
|
||||||
push
|
|
||||||
no-caps
|
|
||||||
rounded
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="row items-center q-ml-sm" style="font-size: 150%;">
|
|
||||||
<div class="q-mr-xs">
|
|
||||||
Коллекция
|
|
||||||
</div>
|
|
||||||
<div class="clickable" @click.stop.prevent="showCollectionInfo">
|
|
||||||
{{ collection }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<DivBtn class="q-ml-sm q-px-sm bg-white" :size="20" @click.stop.prevent="openReleasePage">
|
||||||
<div class="col"></div>
|
Скачать
|
||||||
|
|
||||||
<DivBtn class="q-ml-md text-white bg-secondary" :size="30" :icon-size="24" icon="la la-question" round @click.stop.prevent="showSearchHelp">
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
Памятка
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
</DivBtn>
|
||||||
|
<DivBtn class="q-ml-sm q-px-sm bg-white" :size="20" @click.stop.prevent="settingsDialogVisible = true">
|
||||||
<DivBtn class="q-ml-sm text-white bg-secondary" :size="30" :icon-size="24" :imt="1" icon="la la-cog" round @click.stop.prevent="settingsDialogVisible = true">
|
Отключить уведомление
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
Настройки
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
|
|
||||||
<DivBtn v-if="!config.freeAccess" class="q-ml-sm text-white bg-secondary" :size="30" :icon-size="24" :imt="1" icon="la la-sign-out-alt" round @click.stop.prevent="logout">
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
Выход
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
</DivBtn>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="!isExtendedSearch" class="row q-mx-md q-mb-xs items-center">
|
|
||||||
|
<!-- 1 -->
|
||||||
|
<div class="row">
|
||||||
|
<!-- 1-1 -->
|
||||||
|
<div class="column col">
|
||||||
|
<div class="header q-mb-xs q-ml-sm q-mt-sm row items-center">
|
||||||
|
<div class="row no-wrap items-center">
|
||||||
|
<a :href="newSearchLink" style="height: 33px; width: 34px">
|
||||||
|
<img src="./assets/logo.png" />
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Новый поиск
|
||||||
|
</q-tooltip>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<q-btn-toggle
|
||||||
|
v-model="selectedList"
|
||||||
|
class="q-ml-sm"
|
||||||
|
toggle-color="primary"
|
||||||
|
:options="listOptions"
|
||||||
|
push
|
||||||
|
no-caps
|
||||||
|
rounded
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row items-center q-ml-sm" style="font-size: 150%;">
|
||||||
|
<div class="q-mr-xs">
|
||||||
|
Коллекция
|
||||||
|
</div>
|
||||||
|
<div class="clickable" @click.stop.prevent="showCollectionInfo">
|
||||||
|
{{ collection }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DivBtn class="q-ml-sm text-grey-5 bg-yellow-1" :size="28" :icon-size="24" icon="la la-question" round @click.stop.prevent="showSearchHelp">
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Памятка
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-show="!isExtendedSearch" class="row q-mx-sm q-mb-xs items-center" style="max-width: 1024px">
|
||||||
|
<q-input
|
||||||
|
ref="authorInput" v-model="search.author" :maxlength="5000" :debounce="inputDebounce"
|
||||||
|
class="q-mt-xs col-3" :bg-color="inputBgColor('author')" style="min-width: 140px" label="Автор" stack-label outlined dense clearable
|
||||||
|
>
|
||||||
|
<q-tooltip v-if="search.author" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ search.author }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<q-input
|
||||||
|
v-model="search.series" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
||||||
|
class="q-mt-xs col-3" :bg-color="inputBgColor('series')" style="min-width: 140px" label="Серия" stack-label outlined dense clearable
|
||||||
|
>
|
||||||
|
<q-tooltip v-if="search.series" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ search.series }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<q-input
|
||||||
|
v-model="search.title" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
||||||
|
class="q-mt-xs col-3" :bg-color="inputBgColor('title')" style="min-width: 140px;" label="Название" stack-label outlined dense clearable
|
||||||
|
>
|
||||||
|
<q-tooltip v-if="search.title" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ search.title }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<q-input
|
||||||
|
v-model="search.lang" :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
|
||||||
|
@click.stop.prevent="selectLang"
|
||||||
|
>
|
||||||
|
<template v-if="search.lang" #append>
|
||||||
|
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.lang = ''" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<q-tooltip v-if="search.lang && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ search.lang }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<DivBtn
|
||||||
|
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" :icon-size="24" round
|
||||||
|
icon="la la-level-up-alt"
|
||||||
|
@click.stop.prevent="cloneSearch"
|
||||||
|
>
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Клонировать поиск
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
</div>
|
||||||
|
<div v-show="!isExtendedSearch && extendedParams" class="row q-mx-sm q-mb-xs items-center" style="max-width: 1024px">
|
||||||
|
<q-input
|
||||||
|
v-model="genreNames" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
||||||
|
class="q-mt-xs col-3" :bg-color="inputBgColor()" input-style="cursor: pointer" style="min-width: 140px;" label="Жанр" stack-label outlined dense clearable readonly
|
||||||
|
@click.stop.prevent="selectGenre"
|
||||||
|
>
|
||||||
|
<template v-if="genreNames" #append>
|
||||||
|
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.genre = ''" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<q-tooltip v-if="genreNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ genreNames }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<q-select
|
||||||
|
v-model="searchDate"
|
||||||
|
class="q-mt-xs col-3"
|
||||||
|
:options="searchDateOptions"
|
||||||
|
dropdown-icon="la la-angle-down la-sm"
|
||||||
|
:bg-color="inputBgColor()"
|
||||||
|
style="min-width: 140px;"
|
||||||
|
label="Дата поступления" stack-label
|
||||||
|
outlined dense emit-value map-options clearable
|
||||||
|
>
|
||||||
|
<template #selected-item="scope">
|
||||||
|
<div v-if="scope.opt.value == 'manual'">
|
||||||
|
<div v-html="formatSearchDate" />
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ scope.opt.label }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps" @click.stop.prevent="dateSelectItemClick(scope.opt.value)">
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>
|
||||||
|
{{ scope.opt.label }}
|
||||||
|
</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
|
||||||
|
<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
|
||||||
|
@click.stop.prevent="selectLibRate"
|
||||||
|
>
|
||||||
|
<template v-if="librateNames" #append>
|
||||||
|
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.librate = ''" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<q-tooltip v-if="librateNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ librateNames }}
|
||||||
|
</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 }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-show="isExtendedSearch" class="row q-mx-md q-mb-xs items-center">
|
||||||
|
<q-input
|
||||||
|
v-model="extSearchNames"
|
||||||
|
class="col q-mt-xs" :bg-color="inputBgColor('extended')" input-style="cursor: pointer"
|
||||||
|
style="min-width: 140px; max-width: 638px;" label="Расширенный поиск" stack-label outlined dense clearable readonly
|
||||||
|
@click.stop.prevent="selectExtSearch"
|
||||||
|
>
|
||||||
|
<template v-if="extSearchNames" #append>
|
||||||
|
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="clearExtSearch" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<q-tooltip v-if="extSearchNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
{{ extSearchNames }}
|
||||||
|
</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<DivBtn
|
||||||
|
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
||||||
|
:disabled="!extSearch.author"
|
||||||
|
@me-click="extToList('author')"
|
||||||
|
>
|
||||||
|
<div style="font-size: 130%">
|
||||||
|
<b>А</b>
|
||||||
|
</div>
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
В раздел "Авторы" с переносом значения author={{ extSearch.author }}
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<DivBtn
|
||||||
|
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
||||||
|
:disabled="!extSearch.series"
|
||||||
|
@me-click="extToList('series')"
|
||||||
|
>
|
||||||
|
<div style="font-size: 130%">
|
||||||
|
<b>С</b>
|
||||||
|
</div>
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
В раздел "Серии" с переносом значения series={{ extSearch.series }}
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<DivBtn
|
||||||
|
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
||||||
|
:disabled="!extSearch.title"
|
||||||
|
@me-click="extToList('title')"
|
||||||
|
>
|
||||||
|
<div style="font-size: 130%">
|
||||||
|
<b>К</b>
|
||||||
|
</div>
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
В раздел "Книги" с переносом значения title={{ extSearch.title }}
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
|
||||||
|
<div class="q-mx-xs" />
|
||||||
|
<DivBtn
|
||||||
|
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" :icon-size="24" round
|
||||||
|
icon="la la-level-up-alt"
|
||||||
|
@click.stop.prevent="cloneSearch"
|
||||||
|
>
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Клонировать поиск
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
</div>
|
||||||
|
</div><!-- 1-1 -->
|
||||||
|
<!-- 1-2 -->
|
||||||
|
<div class="column q-mx-sm">
|
||||||
|
<div style="height: 3px" />
|
||||||
|
<DivBtn class="q-mt-sm text-white bg-secondary" :size="28" :icon-size="24" :imt="1" icon="la la-cog" round @click.stop.prevent="settingsDialogVisible = true">
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Настройки
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
|
||||||
|
<DivBtn v-if="!config.freeAccess" class="q-mt-sm text-white bg-secondary" :size="28" :icon-size="24" :imt="1" icon="la la-sign-out-alt" round @click.stop.prevent="logout">
|
||||||
|
<template #tooltip>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
|
Выход
|
||||||
|
</q-tooltip>
|
||||||
|
</template>
|
||||||
|
</DivBtn>
|
||||||
|
</div><!-- 1-2 -->
|
||||||
|
</div><!-- 1 -->
|
||||||
|
<!-- 2 -->
|
||||||
|
<div class="column">
|
||||||
<DivBtn
|
<DivBtn
|
||||||
class="text-grey-5 bg-yellow-1 q-mt-xs" :size="30" :icon-size="24" round
|
v-show="!isExtendedSearch && (extendedParams || !extendedParamsMessage)"
|
||||||
|
class="text-grey-6" :size="16" :icon-size="14"
|
||||||
:icon="(extendedParams ? 'la la-angle-double-up' : 'la la-angle-double-down')"
|
:icon="(extendedParams ? 'la la-angle-double-up' : 'la la-angle-double-down')"
|
||||||
|
no-shadow
|
||||||
@click.stop.prevent="extendedParams = !extendedParams"
|
@click.stop.prevent="extendedParams = !extendedParams"
|
||||||
>
|
>
|
||||||
<template #tooltip>
|
<template #tooltip>
|
||||||
@@ -67,208 +289,12 @@
|
|||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</DivBtn>
|
</DivBtn>
|
||||||
<div class="q-mx-xs" />
|
</div><!-- 2 -->
|
||||||
<q-input
|
|
||||||
ref="authorInput" v-model="search.author" :maxlength="5000" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor('author')" style="width: 200px;" label="Автор" stack-label outlined dense clearable
|
|
||||||
>
|
|
||||||
<q-tooltip v-if="search.author" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ search.author }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-input
|
|
||||||
v-model="search.series" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor('series')" style="width: 200px;" label="Серия" stack-label outlined dense clearable
|
|
||||||
>
|
|
||||||
<q-tooltip v-if="search.series" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ search.series }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-input
|
|
||||||
v-model="search.title" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor('title')" style="width: 200px;" label="Название" stack-label outlined dense clearable
|
|
||||||
>
|
|
||||||
<q-tooltip v-if="search.title" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ search.title }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-input
|
|
||||||
v-model="search.lang" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor()" input-style="cursor: pointer" style="width: 90px;" label="Язык" stack-label outlined dense clearable readonly
|
|
||||||
@click.stop.prevent="selectLang"
|
|
||||||
>
|
|
||||||
<template v-if="search.lang" #append>
|
|
||||||
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.lang = ''" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<q-tooltip v-if="search.lang && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ search.lang }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<DivBtn
|
|
||||||
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" :icon-size="24" round
|
|
||||||
icon="la la-level-up-alt"
|
|
||||||
@click.stop.prevent="cloneSearch"
|
|
||||||
>
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
Клонировать поиск
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
</div>
|
|
||||||
<div v-show="!isExtendedSearch && extendedParams" class="row q-mx-md q-mb-xs items-center">
|
|
||||||
<div style="width: 30px" />
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-input
|
|
||||||
v-model="genreNames" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor()" input-style="cursor: pointer" style="width: 200px;" label="Жанр" stack-label outlined dense clearable readonly
|
|
||||||
@click.stop.prevent="selectGenre"
|
|
||||||
>
|
|
||||||
<template v-if="genreNames" #append>
|
|
||||||
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.genre = ''" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<q-tooltip v-if="genreNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ genreNames }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-select
|
|
||||||
v-model="searchDate"
|
|
||||||
class="q-mt-xs"
|
|
||||||
:options="searchDateOptions"
|
|
||||||
dropdown-icon="la la-angle-down la-sm"
|
|
||||||
:bg-color="inputBgColor()"
|
|
||||||
style="width: 200px;"
|
|
||||||
label="Дата поступления" stack-label
|
|
||||||
outlined dense emit-value map-options clearable
|
|
||||||
>
|
|
||||||
<template #selected-item="scope">
|
|
||||||
<div v-if="scope.opt.value == 'manual'">
|
|
||||||
<div v-html="formatSearchDate" />
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
{{ scope.opt.label }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #option="scope">
|
|
||||||
<q-item v-bind="scope.itemProps" @click.stop.prevent="dateSelectItemClick(scope.opt.value)">
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label>
|
|
||||||
{{ scope.opt.label }}
|
|
||||||
</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</template>
|
|
||||||
</q-select>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<q-input
|
|
||||||
v-model="librateNames" :maxlength="inputMaxLength" :debounce="inputDebounce"
|
|
||||||
class="q-mt-xs" :bg-color="inputBgColor()" input-style="cursor: pointer" style="width: 90px;" label="Оценка" stack-label outlined dense clearable readonly
|
|
||||||
@click.stop.prevent="selectLibRate"
|
|
||||||
>
|
|
||||||
<template v-if="librateNames" #append>
|
|
||||||
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="search.librate = ''" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<q-tooltip v-if="librateNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ librateNames }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
</div>
|
|
||||||
<div v-show="!isExtendedSearch && !extendedParams && extendedParamsMessage" class="row q-mx-md items-center clickable" @click.stop.prevent="extendedParams = true">
|
|
||||||
+{{ extendedParamsMessage }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-show="isExtendedSearch" class="row q-mx-md q-mb-xs items-center">
|
|
||||||
<q-input
|
|
||||||
v-model="extSearchNames"
|
|
||||||
class="col q-mt-xs" :bg-color="inputBgColor('extended')" input-style="cursor: pointer"
|
|
||||||
style="min-width: 200px; max-width: 638px;" label="Расширенный поиск" stack-label outlined dense clearable readonly
|
|
||||||
@click.stop.prevent="selectExtSearch"
|
|
||||||
>
|
|
||||||
<template v-if="extSearchNames" #append>
|
|
||||||
<q-icon name="la la-times-circle" class="q-field__focusable-action" @click.stop.prevent="clearExtSearch" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<q-tooltip v-if="extSearchNames && showTooltips" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
{{ extSearchNames }}
|
|
||||||
</q-tooltip>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<DivBtn
|
|
||||||
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
|
||||||
:disabled="!extSearch.author"
|
|
||||||
@me-click="extToList('author')"
|
|
||||||
>
|
|
||||||
<div style="font-size: 130%">
|
|
||||||
<b>А</b>
|
|
||||||
</div>
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
В раздел "Авторы" с переносом значения author={{ extSearch.author }}
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<DivBtn
|
|
||||||
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
|
||||||
:disabled="!extSearch.series"
|
|
||||||
@me-click="extToList('series')"
|
|
||||||
>
|
|
||||||
<div style="font-size: 130%">
|
|
||||||
<b>С</b>
|
|
||||||
</div>
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
В раздел "Серии" с переносом значения series={{ extSearch.series }}
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<DivBtn
|
|
||||||
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" round
|
|
||||||
:disabled="!extSearch.title"
|
|
||||||
@me-click="extToList('title')"
|
|
||||||
>
|
|
||||||
<div style="font-size: 130%">
|
|
||||||
<b>К</b>
|
|
||||||
</div>
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
В раздел "Книги" с переносом значения title={{ extSearch.title }}
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
|
|
||||||
<div class="q-mx-xs" />
|
|
||||||
<DivBtn
|
|
||||||
class="text-grey-8 bg-yellow-1 q-mt-xs" :size="30" :icon-size="24" round
|
|
||||||
icon="la la-level-up-alt"
|
|
||||||
@click.stop.prevent="cloneSearch"
|
|
||||||
>
|
|
||||||
<template #tooltip>
|
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
|
||||||
Клонировать поиск
|
|
||||||
</q-tooltip>
|
|
||||||
</template>
|
|
||||||
</DivBtn>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Tool Panel end -->
|
||||||
|
|
||||||
<div class="row items-center q-ml-lg q-mt-sm">
|
<div class="row items-center q-ml-lg q-mt-sm">
|
||||||
<div style="width: 400px; height: 50px">
|
<div style="width: 400px;">
|
||||||
<PageScroller v-show="pageCount > 1" ref="pageScroller1" v-model="search.page" :page-count="pageCount" />
|
<PageScroller v-show="pageCount > 1" ref="pageScroller1" v-model="search.page" :page-count="pageCount" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -491,6 +517,7 @@ class Search {
|
|||||||
limit = 20;
|
limit = 20;
|
||||||
extendedParams = false;
|
extendedParams = false;
|
||||||
showJson = false;
|
showJson = false;
|
||||||
|
showNewReleaseAvailable = true;
|
||||||
|
|
||||||
//stuff
|
//stuff
|
||||||
prevList = {};
|
prevList = {};
|
||||||
@@ -542,8 +569,16 @@ class Search {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
(async() => {
|
(async() => {
|
||||||
|
//для срабатывания watch.config
|
||||||
await this.api.updateConfig();
|
await this.api.updateConfig();
|
||||||
|
|
||||||
|
//устанавливаем uiDefaults от сервера, если это необходимо
|
||||||
|
if (!this.settings.defaultsSet) {
|
||||||
|
const uiDefaults = _.cloneDeep(this.config.uiDefaults);
|
||||||
|
uiDefaults.defaultsSet = true;
|
||||||
|
this.commit('setSettings', uiDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
this.generateDefaults(this.extSearch, this.recStruct.map(f => f.field));
|
this.generateDefaults(this.extSearch, this.recStruct.map(f => f.field));
|
||||||
this.extSearch.setDefaults(this.extSearch);
|
this.extSearch.setDefaults(this.extSearch);
|
||||||
this.search.lang = this.langDefault;
|
this.search.lang = this.langDefault;
|
||||||
@@ -584,6 +619,7 @@ class Search {
|
|||||||
this.abCacheEnabled = settings.abCacheEnabled;
|
this.abCacheEnabled = settings.abCacheEnabled;
|
||||||
this.langDefault = settings.langDefault;
|
this.langDefault = settings.langDefault;
|
||||||
this.showJson = settings.showJson;
|
this.showJson = settings.showJson;
|
||||||
|
this.showNewReleaseAvailable = settings.showNewReleaseAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
recvMessage(d) {
|
recvMessage(d) {
|
||||||
@@ -593,6 +629,7 @@ class Search {
|
|||||||
this.list.liberamaReady = true;
|
this.list.liberamaReady = true;
|
||||||
this.sendMessage({type: 'mes', data: 'ready'});
|
this.sendMessage({type: 'mes', data: 'ready'});
|
||||||
this.sendCurrentUrl();
|
this.sendCurrentUrl();
|
||||||
|
this.makeTitle();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -610,6 +647,10 @@ class Search {
|
|||||||
return this.$store.state.config;
|
return this.$store.state.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get newReleaseAvailable() {
|
||||||
|
return (this.config.latestVersion && this.config.version != this.config.latestVersion);
|
||||||
|
}
|
||||||
|
|
||||||
get recStruct() {
|
get recStruct() {
|
||||||
if (this.config.dbConfig && this.config.dbConfig.inpxInfo.recStruct)
|
if (this.config.dbConfig && this.config.dbConfig.inpxInfo.recStruct)
|
||||||
return this.config.dbConfig.inpxInfo.recStruct;
|
return this.config.dbConfig.inpxInfo.recStruct;
|
||||||
@@ -707,14 +748,19 @@ class Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openReleasePage() {
|
openReleasePage() {
|
||||||
window.open('https://github.com/bookpauk/inpx-web/releases', '_blank');
|
if (this.config.latestReleaseLink)
|
||||||
|
window.open(this.config.latestReleaseLink, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
makeProjectName() {
|
makeProjectName() {
|
||||||
const collection = this.config.dbConfig.inpxInfo.collection.split('\n');
|
const collection = this.config.dbConfig.inpxInfo.collection.split('\n');
|
||||||
this.collection = collection[0].trim();
|
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();
|
this.makeTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,6 +835,11 @@ class Search {
|
|||||||
Указание простого "#" в поиске по названию означает: найти всех авторов, названия книг которых начинаются не с русской или латинской буквы
|
Указание простого "#" в поиске по названию означает: найти всех авторов, названия книг которых начинаются не с русской или латинской буквы
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
|
<li>
|
||||||
|
"~" поиск по регулярному выражению. Например, для "~^\\s" в поле названия, будут найдены
|
||||||
|
все книги, названия которых начинаются с пробельного символа
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
<li>
|
<li>
|
||||||
"?" поиск пустых значений или тех, что начинаются с этого символа. Например, "?" в поле серии означает: найти всех авторов, у которых есть книги без серий
|
"?" поиск пустых значений или тех, что начинаются с этого символа. Например, "?" в поле серии означает: найти всех авторов, у которых есть книги без серий
|
||||||
или название серии начинается с "?".
|
или название серии начинается с "?".
|
||||||
@@ -902,6 +953,7 @@ class Search {
|
|||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
const curScrollTop = this.$refs.scroller.scrollTop;
|
const curScrollTop = this.$refs.scroller.scrollTop;
|
||||||
|
const toolPanelOffset = this.$refs.toolPanel.getBoundingClientRect().top;
|
||||||
|
|
||||||
if (this.ignoreScrolling) {
|
if (this.ignoreScrolling) {
|
||||||
this.lastScrollTop = curScrollTop;
|
this.lastScrollTop = curScrollTop;
|
||||||
@@ -910,21 +962,27 @@ class Search {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.lastScrollTop === curScrollTop)
|
||||||
|
return; //если событие вызвано более 1 раза на 1 скролл
|
||||||
|
|
||||||
if (!this.lastScrollTop)
|
if (!this.lastScrollTop)
|
||||||
this.lastScrollTop = 0;
|
this.lastScrollTop = 0;
|
||||||
if (!this.lastScrollTop2)
|
|
||||||
this.lastScrollTop2 = 0;
|
|
||||||
|
|
||||||
if (curScrollTop - this.lastScrollTop > 0) {
|
if (curScrollTop - this.lastScrollTop > 0) { //страницу крутят вверх
|
||||||
|
if (this.$refs.toolPanel.style.position == 'sticky') //если блок приклеен к окну
|
||||||
|
this.$refs.toolPanel.style.top = `${this.lastScrollTop}px`;//приклеиваем его к позиции в родителе
|
||||||
|
|
||||||
this.$refs.toolPanel.style.position = 'relative';
|
this.$refs.toolPanel.style.position = 'relative';
|
||||||
if (this.lastScrollTop2 <= curScrollTop - this.$refs.toolPanel.clientHeight)
|
(async() => {//"отложенная" коректировка, из-за артефактов в firefox
|
||||||
this.lastScrollTop2 = 0;
|
if (toolPanelOffset < -this.$refs.toolPanel.offsetHeight) { //не даём блоку оказаться дальше своей высоты за экраном
|
||||||
|
await utils.sleep(10);
|
||||||
|
this.$refs.toolPanel.style.top = `${curScrollTop - this.$refs.toolPanel.offsetHeight}px`;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
this.$refs.toolPanel.style.top = `${this.lastScrollTop2}px`;
|
} else if (toolPanelOffset >= 0) {
|
||||||
} else {
|
this.$refs.toolPanel.style.top = '0px';
|
||||||
this.$refs.toolPanel.style.position = 'sticky';
|
this.$refs.toolPanel.style.position = 'sticky';
|
||||||
this.$refs.toolPanel.style.top = 0;
|
|
||||||
this.lastScrollTop2 = curScrollTop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastScrollTop = curScrollTop;
|
this.lastScrollTop = curScrollTop;
|
||||||
@@ -934,14 +992,14 @@ class Search {
|
|||||||
this.ignoreScrolling = true;
|
this.ignoreScrolling = true;
|
||||||
await utils.sleep(ms);
|
await utils.sleep(ms);
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
await this.$nextTick();
|
|
||||||
await this.$nextTick();
|
|
||||||
this.ignoreScrolling = false;
|
this.ignoreScrolling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
scrollToTop() {
|
||||||
this.$refs.scroller.scrollTop = 0;
|
this.$refs.scroller.scrollTop = 0;
|
||||||
this.lastScrollTop = 0;
|
this.lastScrollTop = 0;
|
||||||
|
this.$refs.toolPanel.style.top = '0px';
|
||||||
|
this.$refs.toolPanel.style.position = 'sticky';
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePageCount() {
|
updatePageCount() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Расширенный поиск
|
Расширенный поиск
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DivBtn class="q-ml-md text-white bg-secondary" :size="30" :icon-size="24" icon="la la-question" round @click.stop.prevent="showSearchHelp">
|
<DivBtn class="q-ml-sm text-grey-5 bg-yellow-1" :size="28" :icon-size="24" icon="la la-question" round @click.stop.prevent="showSearchHelp">
|
||||||
<template #tooltip>
|
<template #tooltip>
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
|
||||||
Памятка
|
Памятка
|
||||||
@@ -160,6 +160,9 @@ class SelectExtSearchDialog {
|
|||||||
<li>
|
<li>
|
||||||
префикс "#": поиск подстроки в строке, но только среди начинающихся не с латинского или кириллического символа
|
префикс "#": поиск подстроки в строке, но только среди начинающихся не с латинского или кириллического символа
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
префикс "~": поиск по регулярному выражению
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
префикс "?": поиск пустых значений или тех, что начинаются с этого символа
|
префикс "?": поиск пустых значений или тех, что начинаются с этого символа
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</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="downloadAsZip" size="36px" label="Скачивать книги в виде zip-архива" />
|
||||||
<q-checkbox v-model="showCounts" size="36px" label="Показывать количество" />
|
<q-checkbox v-model="showCounts" size="36px" label="Показывать количество" />
|
||||||
<q-checkbox v-model="showRates" size="36px" label="Показывать оценки" />
|
<q-checkbox v-model="showRates" size="36px" label="Показывать оценки" />
|
||||||
@@ -85,6 +86,9 @@ const componentOptions = {
|
|||||||
abCacheEnabled(newValue) {
|
abCacheEnabled(newValue) {
|
||||||
this.commit('setSettings', {'abCacheEnabled': newValue});
|
this.commit('setSettings', {'abCacheEnabled': newValue});
|
||||||
},
|
},
|
||||||
|
showNewReleaseAvailable(newValue) {
|
||||||
|
this.commit('setSettings', {'showNewReleaseAvailable': newValue});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class SettingsDialog {
|
class SettingsDialog {
|
||||||
@@ -105,6 +109,7 @@ class SettingsDialog {
|
|||||||
showDates = true;
|
showDates = true;
|
||||||
showDeleted = false;
|
showDeleted = false;
|
||||||
abCacheEnabled = true;
|
abCacheEnabled = true;
|
||||||
|
showNewReleaseAvailable = true;
|
||||||
|
|
||||||
limitOptions = [
|
limitOptions = [
|
||||||
{label: '10', value: 10},
|
{label: '10', value: 10},
|
||||||
@@ -125,6 +130,10 @@ class SettingsDialog {
|
|||||||
mounted() {
|
mounted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config() {
|
||||||
|
return this.$store.state.config;
|
||||||
|
}
|
||||||
|
|
||||||
get settings() {
|
get settings() {
|
||||||
return this.$store.state.settings;
|
return this.$store.state.settings;
|
||||||
}
|
}
|
||||||
@@ -142,6 +151,7 @@ class SettingsDialog {
|
|||||||
this.showDates = settings.showDates;
|
this.showDates = settings.showDates;
|
||||||
this.showDeleted = settings.showDeleted;
|
this.showDeleted = settings.showDeleted;
|
||||||
this.abCacheEnabled = settings.abCacheEnabled;
|
this.abCacheEnabled = settings.abCacheEnabled;
|
||||||
|
this.showNewReleaseAvailable = settings.showNewReleaseAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
okClick() {
|
okClick() {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class DivBtn {
|
|||||||
round: Boolean,
|
round: Boolean,
|
||||||
imt: { type: Number, default: 0 },// icon margin top
|
imt: { type: Number, default: 0 },// icon margin top
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
|
noShadow: Boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
pressed = false;
|
pressed = false;
|
||||||
@@ -56,6 +57,9 @@ class DivBtn {
|
|||||||
style.borderRadius = `${this.size}px`;
|
style.borderRadius = `${this.size}px`;
|
||||||
else
|
else
|
||||||
style.borderRadius = `${this.size/10}px`;
|
style.borderRadius = `${this.size/10}px`;
|
||||||
|
|
||||||
|
if (!this.noShadow)
|
||||||
|
style.boxShadow = '0.5px 1px 3px #333333';
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickEffect(event) {
|
async clickEffect(event) {
|
||||||
@@ -77,7 +81,6 @@ export default vueComponent(DivBtn);
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.button {
|
.button {
|
||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: 0.5px 1px 3px #333333;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
@@ -86,8 +89,10 @@ export default vueComponent(DivBtn);
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button-pressed {
|
.button-pressed {
|
||||||
margin-left: 2px;
|
margin-left: 1px;
|
||||||
margin-top: 2px;
|
margin-top: 1px;
|
||||||
|
margin-right: -1px;
|
||||||
|
margin-bottom: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickable {
|
.clickable {
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ const state = {
|
|||||||
settings: {
|
settings: {
|
||||||
accessToken: '',
|
accessToken: '',
|
||||||
extendedParams: false,
|
extendedParams: false,
|
||||||
limit: 20,
|
|
||||||
expandedAuthor: [],
|
expandedAuthor: [],
|
||||||
expandedSeries: [],
|
expandedSeries: [],
|
||||||
|
|
||||||
|
defaultsSet: false,
|
||||||
|
|
||||||
|
//uiDefaults
|
||||||
|
limit: 20,
|
||||||
downloadAsZip: false,
|
downloadAsZip: false,
|
||||||
showCounts: true,
|
showCounts: true,
|
||||||
showRates: true,
|
showRates: true,
|
||||||
@@ -17,6 +21,7 @@ const state = {
|
|||||||
abCacheEnabled: true,
|
abCacheEnabled: true,
|
||||||
langDefault: '',
|
langDefault: '',
|
||||||
showJson: false,
|
showJson: false,
|
||||||
|
showNewReleaseAvailable: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "inpx-web",
|
"name": "inpx-web",
|
||||||
"version": "1.4.0",
|
"version": "1.5.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "inpx-web",
|
"name": "inpx-web",
|
||||||
"version": "1.4.0",
|
"version": "1.5.3",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"he": "^1.2.0",
|
"he": "^1.2.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"jembadb": "^5.1.5",
|
"jembadb": "^5.1.7",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimist": "^1.2.7",
|
"minimist": "^1.2.7",
|
||||||
@@ -5071,9 +5071,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jembadb": {
|
"node_modules/jembadb": {
|
||||||
"version": "5.1.5",
|
"version": "5.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/jembadb/-/jembadb-5.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/jembadb/-/jembadb-5.1.7.tgz",
|
||||||
"integrity": "sha512-Vb+TkTg3JVXLPTG5BiqboZjJ2wvZRONnLd2+qU4gTuaqt2JSniigbniKSl3kACAEFfuRXEjfs9dLlKWjBX2Aiw==",
|
"integrity": "sha512-TNZjiKQ7Zfh89Q1x25PKKtsbkxiC5uOnx953dxJEP6RqfcdR6uVpr4cf+kmyq6IQ1GhwhXTELnoTIdvLWrpEvw==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.16.0"
|
"node": ">=16.16.0"
|
||||||
}
|
}
|
||||||
@@ -12617,9 +12617,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"jembadb": {
|
"jembadb": {
|
||||||
"version": "5.1.5",
|
"version": "5.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/jembadb/-/jembadb-5.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/jembadb/-/jembadb-5.1.7.tgz",
|
||||||
"integrity": "sha512-Vb+TkTg3JVXLPTG5BiqboZjJ2wvZRONnLd2+qU4gTuaqt2JSniigbniKSl3kACAEFfuRXEjfs9dLlKWjBX2Aiw=="
|
"integrity": "sha512-TNZjiKQ7Zfh89Q1x25PKKtsbkxiC5uOnx953dxJEP6RqfcdR6uVpr4cf+kmyq6IQ1GhwhXTELnoTIdvLWrpEvw=="
|
||||||
},
|
},
|
||||||
"jest-util": {
|
"jest-util": {
|
||||||
"version": "29.3.1",
|
"version": "29.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "inpx-web",
|
"name": "inpx-web",
|
||||||
"version": "1.4.0",
|
"version": "1.5.3",
|
||||||
"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",
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"he": "^1.2.0",
|
"he": "^1.2.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"jembadb": "^5.1.5",
|
"jembadb": "^5.1.7",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimist": "^1.2.7",
|
"minimist": "^1.2.7",
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ const execDir = path.resolve(__dirname, '..');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
branch: 'unknown',
|
branch: 'unknown',
|
||||||
version: pckg.version,
|
version: pckg.version,
|
||||||
|
latestVersion: '',
|
||||||
name: pckg.name,
|
name: pckg.name,
|
||||||
|
|
||||||
execDir,
|
execDir,
|
||||||
|
libDir: '',
|
||||||
|
inpx: '',
|
||||||
|
|
||||||
accessPassword: '',
|
accessPassword: '',
|
||||||
accessTimeout: 0,
|
accessTimeout: 0,
|
||||||
@@ -17,8 +20,8 @@ module.exports = {
|
|||||||
loggingEnabled: true,
|
loggingEnabled: true,
|
||||||
|
|
||||||
//поправить в случае, если были критические изменения в DbCreator или InpxParser
|
//поправить в случае, если были критические изменения в DbCreator или InpxParser
|
||||||
//иначе будет рассинхронизация между сервером и клиентом на уровне БД
|
//иначе будет рассинхронизация по кешу между сервером и клиентом на уровне БД
|
||||||
dbVersion: '10',
|
dbVersion: '11',
|
||||||
dbCacheSize: 5,
|
dbCacheSize: 5,
|
||||||
|
|
||||||
maxPayloadSize: 500,//in MB
|
maxPayloadSize: 500,//in MB
|
||||||
@@ -31,7 +34,7 @@ module.exports = {
|
|||||||
lowMemoryMode: false,
|
lowMemoryMode: false,
|
||||||
fullOptimization: false,
|
fullOptimization: false,
|
||||||
|
|
||||||
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch'],
|
webConfigParams: ['name', 'version', 'latestVersion', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch', 'latestReleaseLink', 'uiDefaults'],
|
||||||
|
|
||||||
allowRemoteLib: false,
|
allowRemoteLib: false,
|
||||||
remoteLib: false,
|
remoteLib: false,
|
||||||
@@ -55,5 +58,23 @@ module.exports = {
|
|||||||
password: '',
|
password: '',
|
||||||
root: '/opds',
|
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,
|
||||||
|
showCounts: true,
|
||||||
|
showRates: true,
|
||||||
|
showInfo: true,
|
||||||
|
showGenres: true,
|
||||||
|
showDates: false,
|
||||||
|
showDeleted: false,
|
||||||
|
abCacheEnabled: true,
|
||||||
|
langDefault: '',
|
||||||
|
showJson: false,
|
||||||
|
showNewReleaseAvailable: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ const fs = require('fs-extra');
|
|||||||
const branchFilename = __dirname + '/application_env';
|
const branchFilename = __dirname + '/application_env';
|
||||||
|
|
||||||
const propsToSave = [
|
const propsToSave = [
|
||||||
|
'libDir',
|
||||||
|
'inpx',
|
||||||
'accessPassword',
|
'accessPassword',
|
||||||
'accessTimeout',
|
'accessTimeout',
|
||||||
'extendedSearch',
|
'extendedSearch',
|
||||||
@@ -23,6 +25,9 @@ const propsToSave = [
|
|||||||
'remoteLib',
|
'remoteLib',
|
||||||
'server',
|
'server',
|
||||||
'opds',
|
'opds',
|
||||||
|
'latestReleaseLink',
|
||||||
|
'checkReleaseLink',
|
||||||
|
'uiDefaults',
|
||||||
];
|
];
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ class DbCreator {
|
|||||||
//сохраним поисковые таблицы
|
//сохраним поисковые таблицы
|
||||||
const chunkSize = 10000;
|
const chunkSize = 10000;
|
||||||
|
|
||||||
const saveTable = async(table, arr, nullArr, indexType = 'string') => {
|
const saveTable = async(table, arr, nullArr, indexType = 'string', delEmpty = false) => {
|
||||||
|
|
||||||
if (indexType == 'string')
|
if (indexType == 'string')
|
||||||
arr.sort((a, b) => a.value.localeCompare(b.value));
|
arr.sort((a, b) => a.value.localeCompare(b.value));
|
||||||
@@ -366,6 +366,13 @@ class DbCreator {
|
|||||||
callback({progress: i/arr.length});
|
callback({progress: i/arr.length});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delEmpty) {
|
||||||
|
const delResult = await db.delete({table, where: `@@indexLR('value', '?', '?')`});
|
||||||
|
const statField = `${table}Count`;
|
||||||
|
if (stats[statField])
|
||||||
|
stats[statField] -= delResult.deleted;
|
||||||
|
}
|
||||||
|
|
||||||
nullArr();
|
nullArr();
|
||||||
await db.close({table});
|
await db.close({table});
|
||||||
utils.freeMemory();
|
utils.freeMemory();
|
||||||
@@ -378,7 +385,7 @@ class DbCreator {
|
|||||||
|
|
||||||
//series
|
//series
|
||||||
callback({job: 'series save', jobMessage: 'Сохранение индекса серий', jobStep: 4, progress: 0});
|
callback({job: 'series save', jobMessage: 'Сохранение индекса серий', jobStep: 4, progress: 0});
|
||||||
await saveTable('series', seriesArr, () => {seriesArr = null});
|
await saveTable('series', seriesArr, () => {seriesArr = null}, 'string', true);
|
||||||
|
|
||||||
//title
|
//title
|
||||||
callback({job: 'title save', jobMessage: 'Сохранение индекса названий', jobStep: 5, progress: 0});
|
callback({job: 'title save', jobMessage: 'Сохранение индекса названий', jobStep: 5, progress: 0});
|
||||||
|
|||||||
@@ -63,8 +63,18 @@ class DbSearcher {
|
|||||||
a = a.substring(1);
|
a = a.substring(1);
|
||||||
where = `@indexIter('value', (v) => {
|
where = `@indexIter('value', (v) => {
|
||||||
const enru = new Set(${db.esc(enruArr)});
|
const enru = new Set(${db.esc(enruArr)});
|
||||||
return !v || (v !== ${db.esc(emptyFieldValue)} && !enru.has(v[0]) && v.indexOf(${db.esc(a)}) >= 0);
|
if (!v)
|
||||||
|
return false;
|
||||||
|
return v !== ${db.esc(emptyFieldValue)} && !enru.has(v[0]) && v.indexOf(${db.esc(a)}) >= 0;
|
||||||
})`;
|
})`;
|
||||||
|
} else if (a[0] == '~') {//RegExp
|
||||||
|
a = a.substring(1);
|
||||||
|
where = `
|
||||||
|
await (async() => {
|
||||||
|
const re = new RegExp(${db.esc(a)}, 'i');
|
||||||
|
@@indexIter('value', (v) => re.test(v) );
|
||||||
|
})()
|
||||||
|
`;
|
||||||
} else {
|
} else {
|
||||||
where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
||||||
}
|
}
|
||||||
@@ -99,7 +109,7 @@ class DbSearcher {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//авторы
|
//авторы
|
||||||
if (query.author && query.author !== '*') {
|
if (query.author) {
|
||||||
const key = `book-ids-author-${query.author}`;
|
const key = `book-ids-author-${query.author}`;
|
||||||
let ids = await this.getCached(key);
|
let ids = await this.getCached(key);
|
||||||
|
|
||||||
@@ -113,7 +123,7 @@ class DbSearcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//серии
|
//серии
|
||||||
if (query.series && query.series !== '*') {
|
if (query.series) {
|
||||||
const key = `book-ids-series-${query.series}`;
|
const key = `book-ids-series-${query.series}`;
|
||||||
let ids = await this.getCached(key);
|
let ids = await this.getCached(key);
|
||||||
|
|
||||||
@@ -127,7 +137,7 @@ class DbSearcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//названия
|
//названия
|
||||||
if (query.title && query.title !== '*') {
|
if (query.title) {
|
||||||
const key = `book-ids-title-${query.title}`;
|
const key = `book-ids-title-${query.title}`;
|
||||||
let ids = await this.getCached(key);
|
let ids = await this.getCached(key);
|
||||||
|
|
||||||
@@ -337,7 +347,7 @@ class DbSearcher {
|
|||||||
//то в выборку по bookId могут попасть авторы, которые отсутствуют в критерии query.author,
|
//то в выборку по bookId могут попасть авторы, которые отсутствуют в критерии query.author,
|
||||||
//поэтому дополнительно фильтруем
|
//поэтому дополнительно фильтруем
|
||||||
let result = null;
|
let result = null;
|
||||||
if (from == 'author' && query.author && query.author !== '*') {
|
if (from == 'author' && query.author) {
|
||||||
const key = `filter-ids-author-${query.author}`;
|
const key = `filter-ids-author-${query.author}`;
|
||||||
let authorIds = await this.getCached(key);
|
let authorIds = await this.getCached(key);
|
||||||
|
|
||||||
@@ -562,6 +572,15 @@ class DbSearcher {
|
|||||||
|
|
||||||
searchValue = searchValue.substring(1);
|
searchValue = searchValue.substring(1);
|
||||||
return `(row.${bookField} === '' || (!enru.has(row.${bookField}.toLowerCase()[0]) && row.${bookField}.toLowerCase().indexOf(${db.esc(searchValue)}) >= 0))`;
|
return `(row.${bookField} === '' || (!enru.has(row.${bookField}.toLowerCase()[0]) && row.${bookField}.toLowerCase().indexOf(${db.esc(searchValue)}) >= 0))`;
|
||||||
|
} else if (searchValue[0] == '~') {//RegExp
|
||||||
|
searchValue = searchValue.substring(1);
|
||||||
|
|
||||||
|
return `
|
||||||
|
(() => {
|
||||||
|
const re = new RegExp(${db.esc(searchValue)}, 'i');
|
||||||
|
return re.test(row.${bookField});
|
||||||
|
})()
|
||||||
|
`;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return `(row.${bookField}.toLowerCase().localeCompare(${db.esc(searchValue)}) >= 0 ` +
|
return `(row.${bookField}.toLowerCase().localeCompare(${db.esc(searchValue)}) >= 0 ` +
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const DbCreator = require('./DbCreator');
|
|||||||
const DbSearcher = require('./DbSearcher');
|
const DbSearcher = require('./DbSearcher');
|
||||||
const InpxHashCreator = require('./InpxHashCreator');
|
const InpxHashCreator = require('./InpxHashCreator');
|
||||||
const RemoteLib = require('./RemoteLib');//singleton
|
const RemoteLib = require('./RemoteLib');//singleton
|
||||||
|
const FileDownloader = require('./FileDownloader');
|
||||||
|
|
||||||
const asyncExit = new (require('./AsyncExit'))();
|
const asyncExit = new (require('./AsyncExit'))();
|
||||||
const log = new (require('./AppLogger'))().log;//singleton
|
const log = new (require('./AppLogger'))().log;//singleton
|
||||||
@@ -28,7 +29,8 @@ const stateToText = {
|
|||||||
[ssDbCreating]: 'Создание поисковой базы',
|
[ssDbCreating]: 'Создание поисковой базы',
|
||||||
};
|
};
|
||||||
|
|
||||||
const cleanDirPeriod = 60*60*1000;//каждый час
|
const cleanDirInterval = 60*60*1000;//каждый час
|
||||||
|
const checkReleaseInterval = 2*60*60*1000;//каждые 2 часа
|
||||||
|
|
||||||
//singleton
|
//singleton
|
||||||
let instance = null;
|
let instance = null;
|
||||||
@@ -67,6 +69,7 @@ class WebWorker {
|
|||||||
|
|
||||||
this.periodicCleanDir(dirConfig);//no await
|
this.periodicCleanDir(dirConfig);//no await
|
||||||
this.periodicCheckInpx();//no await
|
this.periodicCheckInpx();//no await
|
||||||
|
this.periodicCheckNewRelease();//no await
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
@@ -433,20 +436,28 @@ class WebWorker {
|
|||||||
const db = this.db;
|
const db = this.db;
|
||||||
let link = '';
|
let link = '';
|
||||||
|
|
||||||
//найдем bookPath и downFileName
|
//найдем downFileName и bookPath
|
||||||
let rows = await db.select({table: 'book', where: `@@hash('_uid', ${db.esc(bookUid)})`});
|
let rows = await db.select({table: 'book', where: `@@hash('_uid', ${db.esc(bookUid)})`});
|
||||||
if (!rows.length)
|
if (!rows.length)
|
||||||
throw new Error('404 Файл не найден');
|
throw new Error('404 Файл не найден');
|
||||||
|
|
||||||
const book = rows[0];
|
const book = rows[0];
|
||||||
let downFileName = book.file;
|
let downFileName = book.file;
|
||||||
const author = book.author.split(',');
|
const authors = book.author.split(',');
|
||||||
const at = [author[0], book.title];
|
let author = authors[0];
|
||||||
downFileName = utils.makeValidFileNameOrEmpty(at.filter(r => r).join(' - '))
|
author = author.split(' ').filter(r => r.trim());
|
||||||
|
for (let i = 1; i < author.length; i++)
|
||||||
|
author[i] = `${(i === 1 ? ' ' : '')}${author[i][0]}.`;
|
||||||
|
if (authors.length > 1)
|
||||||
|
author.push(' и др.');
|
||||||
|
|
||||||
|
const at = [author.join(''), (book.title ? `_${book.title}` : '')];
|
||||||
|
downFileName = utils.makeValidFileNameOrEmpty(at.filter(r => r).join(''))
|
||||||
|| utils.makeValidFileNameOrEmpty(at[0])
|
|| utils.makeValidFileNameOrEmpty(at[0])
|
||||||
|| utils.makeValidFileNameOrEmpty(at[1])
|
|| utils.makeValidFileNameOrEmpty(at[1])
|
||||||
|| downFileName;
|
|| downFileName;
|
||||||
downFileName = downFileName.substring(0, 100);
|
if (downFileName.length > 50)
|
||||||
|
downFileName = `${downFileName.substring(0, 50)}_`;
|
||||||
|
|
||||||
const ext = `.${book.ext}`;
|
const ext = `.${book.ext}`;
|
||||||
if (downFileName.substring(downFileName.length - ext.length) != ext)
|
if (downFileName.substring(downFileName.length - ext.length) != ext)
|
||||||
@@ -630,7 +641,7 @@ class WebWorker {
|
|||||||
let lastCleanDirTime = 0;
|
let lastCleanDirTime = 0;
|
||||||
while (1) {// eslint-disable-line no-constant-condition
|
while (1) {// eslint-disable-line no-constant-condition
|
||||||
//чистка папок
|
//чистка папок
|
||||||
if (Date.now() - lastCleanDirTime >= cleanDirPeriod) {
|
if (Date.now() - lastCleanDirTime >= cleanDirInterval) {
|
||||||
for (const config of dirConfig) {
|
for (const config of dirConfig) {
|
||||||
try {
|
try {
|
||||||
await this.cleanDir(config);
|
await this.cleanDir(config);
|
||||||
@@ -682,6 +693,27 @@ class WebWorker {
|
|||||||
await utils.sleep(inpxCheckInterval*60*1000);
|
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;
|
module.exports = WebWorker;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const StreamZip = require('node-stream-zip');
|
const StreamUnzip = require('node-stream-zip');
|
||||||
|
|
||||||
class ZipReader {
|
class ZipReader {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,7 +14,7 @@ class ZipReader {
|
|||||||
if (this.zip)
|
if (this.zip)
|
||||||
throw new Error('Zip file is already open');
|
throw new Error('Zip file is already open');
|
||||||
|
|
||||||
const zip = new StreamZip.async({file: zipFile, skipEntryNameValidation: true});
|
const zip = new StreamUnzip.async({file: zipFile, skipEntryNameValidation: true});
|
||||||
|
|
||||||
if (zipEntries)
|
if (zipEntries)
|
||||||
this.zipEntries = await zip.entries();
|
this.zipEntries = await zip.entries();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class AuthorPage extends BasePage {
|
|||||||
author: req.query.author || '',
|
author: req.query.author || '',
|
||||||
series: req.query.series || '',
|
series: req.query.series || '',
|
||||||
genre: req.query.genre || '',
|
genre: req.query.genre || '',
|
||||||
del: 0,
|
del: '0',
|
||||||
|
|
||||||
all: req.query.all || '',
|
all: req.query.all || '',
|
||||||
depth: 0,
|
depth: 0,
|
||||||
@@ -86,7 +86,7 @@ class AuthorPage extends BasePage {
|
|||||||
|
|
||||||
if (bookList.books) {
|
if (bookList.books) {
|
||||||
let books = bookList.books;
|
let books = bookList.books;
|
||||||
const booksAll = this.filterBooks(books, {del: 0});
|
const booksAll = this.filterBooks(books);
|
||||||
const filtered = (query.all ? booksAll : this.filterBooks(books, query));
|
const filtered = (query.all ? booksAll : this.filterBooks(books, query));
|
||||||
const sorted = this.sortSeriesBooks(filtered);
|
const sorted = this.sortSeriesBooks(filtered);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ class BasePage {
|
|||||||
this.webWorker = new WebWorker(config);
|
this.webWorker = new WebWorker(config);
|
||||||
this.rootTag = 'feed';
|
this.rootTag = 'feed';
|
||||||
this.opdsRoot = config.opdsRoot;
|
this.opdsRoot = config.opdsRoot;
|
||||||
|
|
||||||
|
this.showDeleted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
escape(s) {
|
||||||
|
//костыль для koreader, не понимает hex-экранирование вида '
|
||||||
|
return he.escape(s).replace(/'/g, ''').replace(/`/g, '`');
|
||||||
}
|
}
|
||||||
|
|
||||||
makeEntry(entry = {}) {
|
makeEntry(entry = {}) {
|
||||||
@@ -28,7 +35,7 @@ class BasePage {
|
|||||||
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',
|
||||||
@@ -46,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};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +220,7 @@ class BasePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//скопировано из BaseList.js, часть функционала не используется
|
//скопировано из BaseList.js, часть функционала не используется
|
||||||
filterBooks(books, query) {
|
filterBooks(books, query = {}) {
|
||||||
const s = query;
|
const s = query;
|
||||||
|
|
||||||
const splitAuthor = (author) => {
|
const splitAuthor = (author) => {
|
||||||
@@ -250,7 +257,14 @@ class BasePage {
|
|||||||
} else if (searchValue[0] == '#') {
|
} else if (searchValue[0] == '#') {
|
||||||
|
|
||||||
searchValue = searchValue.substring(1);
|
searchValue = searchValue.substring(1);
|
||||||
return !bookValue || (bookValue !== emptyFieldValue && !enru.has(bookValue[0]) && bookValue.indexOf(searchValue) >= 0);
|
if (!bookValue)
|
||||||
|
return false;
|
||||||
|
return bookValue !== emptyFieldValue && !enru.has(bookValue[0]) && bookValue.indexOf(searchValue) >= 0;
|
||||||
|
} else if (searchValue[0] == '~') {//RegExp
|
||||||
|
|
||||||
|
searchValue = searchValue.substring(1);
|
||||||
|
const re = new RegExp(searchValue, 'i');
|
||||||
|
return re.test(bookValue);
|
||||||
} else {
|
} else {
|
||||||
//where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
//where = `@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
|
||||||
return bookValue.localeCompare(searchValue) >= 0 && bookValue.localeCompare(searchValue + maxUtf8Char) <= 0;
|
return bookValue.localeCompare(searchValue) >= 0 && bookValue.localeCompare(searchValue + maxUtf8Char) <= 0;
|
||||||
|
|||||||
@@ -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');
|
||||||
@@ -131,15 +130,15 @@ class BookPage extends BasePage {
|
|||||||
|
|
||||||
//format
|
//format
|
||||||
const ext = bookInfo.book.ext;
|
const ext = bookInfo.book.ext;
|
||||||
let fileFormat = `${ext}+zip`;
|
const formats = {
|
||||||
let downHref = bookInfo.link;
|
[`${ext}+zip`]: `${bookInfo.link}/zip`,
|
||||||
|
[ext]: bookInfo.link,
|
||||||
|
};
|
||||||
|
|
||||||
if (ext === 'mobi') {
|
if (ext === 'mobi') {
|
||||||
fileFormat = 'x-mobipocket-ebook';
|
formats['x-mobipocket-ebook'] = bookInfo.link;
|
||||||
} else if (ext == 'epub') {
|
} else if (ext == 'epub') {
|
||||||
//
|
formats[`${ext}+zip`] = bookInfo.link;
|
||||||
} else {
|
|
||||||
downHref = `${bookInfo.link}/zip`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//entry
|
//entry
|
||||||
@@ -148,8 +147,13 @@ class BookPage extends BasePage {
|
|||||||
title: bookInfo.book.title || 'Без названия',
|
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:language'] = bookInfo.book.lang;
|
||||||
e['dc:format'] = fileFormat;
|
e['dc:format'] = ext;
|
||||||
|
|
||||||
//genre
|
//genre
|
||||||
const genre = bookInfo.book.genre.split(',');
|
const genre = bookInfo.book.genre.split(',');
|
||||||
@@ -173,7 +177,8 @@ class BookPage extends BasePage {
|
|||||||
const infoObj = parser.bookInfo();
|
const infoObj = parser.bookInfo();
|
||||||
|
|
||||||
if (infoObj.titleInfo) {
|
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}));
|
e.author = infoObj.titleInfo.author.map(a => ({name: a}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,12 +195,15 @@ 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),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//links
|
//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) {
|
if (bookInfo.cover) {
|
||||||
let coverType = 'image/jpeg';
|
let coverType = 'image/jpeg';
|
||||||
if (path.extname(bookInfo.cover) == '.png')
|
if (path.extname(bookInfo.cover) == '.png')
|
||||||
|
|||||||
@@ -13,13 +13,17 @@ class GenrePage extends BasePage {
|
|||||||
const result = {};
|
const result = {};
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
from: req.query.from || '',
|
from: req.query.from || 'search',
|
||||||
|
term: req.query.term || '',
|
||||||
section: req.query.section || '',
|
section: req.query.section || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let searchQuery = '';
|
||||||
|
if (query.from == 'search')
|
||||||
|
searchQuery = `&type=title&term=${encodeURIComponent(query.term)}`;
|
||||||
|
|
||||||
const entry = [];
|
const entry = [];
|
||||||
if (query.from) {
|
if (query.from) {
|
||||||
|
|
||||||
if (query.section) {
|
if (query.section) {
|
||||||
//выбираем подразделы
|
//выбираем подразделы
|
||||||
const {genreSection} = await this.getGenres();
|
const {genreSection} = await this.getGenres();
|
||||||
@@ -34,7 +38,7 @@ class GenrePage extends BasePage {
|
|||||||
this.makeEntry({
|
this.makeEntry({
|
||||||
id: ++id,
|
id: ++id,
|
||||||
title: g.name,
|
title: g.name,
|
||||||
link: this.navLink({href: `/${encodeURIComponent(query.from)}?genre=${encodeURIComponent(g.value)}`}),
|
link: this.navLink({href: `/${encodeURIComponent(query.from)}?genre=${encodeURIComponent(g.value)}${searchQuery}`}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -43,7 +47,7 @@ class GenrePage extends BasePage {
|
|||||||
this.makeEntry({
|
this.makeEntry({
|
||||||
id: 'whole_section',
|
id: 'whole_section',
|
||||||
title: '[Весь раздел]',
|
title: '[Весь раздел]',
|
||||||
link: this.navLink({href: `/${encodeURIComponent(query.from)}?genre=${encodeURIComponent(all.join(','))}`}),
|
link: this.navLink({href: `/${encodeURIComponent(query.from)}?genre=${encodeURIComponent(all.join(','))}${searchQuery}`}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -56,7 +60,7 @@ class GenrePage extends BasePage {
|
|||||||
this.makeEntry({
|
this.makeEntry({
|
||||||
id: ++id,
|
id: ++id,
|
||||||
title: section.name,
|
title: section.name,
|
||||||
link: this.navLink({href: `/genre?from=${encodeURIComponent(query.from)}§ion=${encodeURIComponent(section.name)}`}),
|
link: this.navLink({href: `/genre?from=${encodeURIComponent(query.from)}§ion=${encodeURIComponent(section.name)}${searchQuery}`}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const BasePage = require('./BasePage');
|
|||||||
const AuthorPage = require('./AuthorPage');
|
const AuthorPage = require('./AuthorPage');
|
||||||
const SeriesPage = require('./SeriesPage');
|
const SeriesPage = require('./SeriesPage');
|
||||||
const TitlePage = require('./TitlePage');
|
const TitlePage = require('./TitlePage');
|
||||||
|
const GenrePage = require('./GenrePage');
|
||||||
|
|
||||||
class RootPage extends BasePage {
|
class RootPage extends BasePage {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
@@ -13,6 +14,7 @@ class RootPage extends BasePage {
|
|||||||
this.authorPage = new AuthorPage(config);
|
this.authorPage = new AuthorPage(config);
|
||||||
this.seriesPage = new SeriesPage(config);
|
this.seriesPage = new SeriesPage(config);
|
||||||
this.titlePage = new TitlePage(config);
|
this.titlePage = new TitlePage(config);
|
||||||
|
this.genrePage = new GenrePage(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
async body(req) {
|
async body(req) {
|
||||||
@@ -30,6 +32,7 @@ class RootPage extends BasePage {
|
|||||||
this.authorPage.myEntry(),
|
this.authorPage.myEntry(),
|
||||||
this.seriesPage.myEntry(),
|
this.seriesPage.myEntry(),
|
||||||
this.titlePage.myEntry(),
|
this.titlePage.myEntry(),
|
||||||
|
this.genrePage.myEntry(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return this.makeBody(result, req);
|
return this.makeBody(result, req);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
const he = require('he');
|
|
||||||
|
|
||||||
const BasePage = require('./BasePage');
|
const BasePage = require('./BasePage');
|
||||||
|
|
||||||
class SearchHelpPage extends BasePage {
|
class SearchHelpPage extends BasePage {
|
||||||
@@ -31,6 +29,9 @@ class SearchHelpPage extends BasePage {
|
|||||||
<li>
|
<li>
|
||||||
префикс "#": поиск подстроки в строке, но только среди значений, начинающихся не с латинского или кириллического символа
|
префикс "#": поиск подстроки в строке, но только среди значений, начинающихся не с латинского или кириллического символа
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
префикс "~": поиск по регулярному выражению
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
префикс "?": поиск пустых значений или тех, что начинаются с этого символа
|
префикс "?": поиск пустых значений или тех, что начинаются с этого символа
|
||||||
</li>
|
</li>
|
||||||
@@ -42,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`})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const BasePage = require('./BasePage');
|
const BasePage = require('./BasePage');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
class SearchPage extends BasePage {
|
class SearchPage extends BasePage {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
@@ -15,46 +16,64 @@ class SearchPage extends BasePage {
|
|||||||
const query = {
|
const query = {
|
||||||
type: req.query.type || '',
|
type: req.query.type || '',
|
||||||
term: req.query.term || '',
|
term: req.query.term || '',
|
||||||
|
genre: req.query.genre || '',
|
||||||
page: parseInt(req.query.page, 10) || 1,
|
page: parseInt(req.query.page, 10) || 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
let entry = [];
|
let entry = [];
|
||||||
if (query.type) {
|
if (query.type) {
|
||||||
if (['author', 'series', 'title'].includes(query.type)) {
|
if (['author', 'series', 'title'].includes(query.type)) {
|
||||||
const from = query.type;
|
try {
|
||||||
const page = query.page;
|
const from = query.type;
|
||||||
|
const page = query.page;
|
||||||
|
|
||||||
const limit = 100;
|
const limit = 100;
|
||||||
const offset = (page - 1)*limit;
|
const offset = (page - 1)*limit;
|
||||||
const queryRes = await this.webWorker.search(from, {[from]: query.term, del: 0, offset, limit});
|
|
||||||
|
|
||||||
const found = queryRes.found;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < found.length; i++) {
|
const found = queryRes.found;
|
||||||
const row = found[i];
|
|
||||||
if (!row.bookCount)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
for (let i = 0; i < found.length; i++) {
|
||||||
|
const row = found[i];
|
||||||
|
if (!row.bookCount)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
entry.push(
|
||||||
|
this.makeEntry({
|
||||||
|
id: row.id,
|
||||||
|
title: `${(from === 'series' ? 'Серия: ': '')}${from === 'author' ? this.bookAuthor(row[from]) : row[from]}`,
|
||||||
|
link: this.navLink({href: `/${from}?${from}==${encodeURIComponent(row[from])}`}),
|
||||||
|
content: {
|
||||||
|
'*ATTRS': {type: 'text'},
|
||||||
|
'*TEXT': `${row.bookCount} книг${utils.wordEnding(row.bookCount, 8)}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queryRes.totalFound > offset + found.length) {
|
||||||
|
entry.push(
|
||||||
|
this.makeEntry({
|
||||||
|
id: 'next_page',
|
||||||
|
title: '[Следующая страница]',
|
||||||
|
link: this.navLink({href: `/${this.id}?type=${from}&term=${encodeURIComponent(query.term)}&genre=${encodeURIComponent(query.genre)}&page=${page + 1}`}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
entry.push(
|
entry.push(
|
||||||
this.makeEntry({
|
this.makeEntry({
|
||||||
id: row.id,
|
id: 'error',
|
||||||
title: `${(from === 'series' ? 'Серия: ': '')}${from === 'author' ? this.bookAuthor(row[from]) : row[from]}`,
|
title: `Ошибка: ${e.message}`,
|
||||||
link: this.navLink({href: `/${from}?${from}==${encodeURIComponent(row[from])}`}),
|
link: this.navLink({href: `/fake-error-link`}),
|
||||||
content: {
|
})
|
||||||
'*ATTRS': {type: 'text'},
|
|
||||||
'*TEXT': `${row.bookCount} книг${utils.wordEnding(row.bookCount, 8)}`,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queryRes.totalFound > offset + found.length) {
|
|
||||||
entry.push(
|
|
||||||
this.makeEntry({
|
|
||||||
id: 'next_page',
|
|
||||||
title: '[Следующая страница]',
|
|
||||||
link: this.navLink({href: `/${this.id}?type=${from}&term=${encodeURIComponent(query.term)}&page=${page + 1}`}),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,6 +107,15 @@ class SearchPage extends BasePage {
|
|||||||
'*TEXT': `Искать по названиям книг`,
|
'*TEXT': `Искать по названиям книг`,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
this.makeEntry({
|
||||||
|
id: 'search_genre',
|
||||||
|
title: 'Поиск книг в жанре',
|
||||||
|
link: this.navLink({href: `/genre?from=search&term=${encodeURIComponent(query.term)}`}),
|
||||||
|
content: {
|
||||||
|
'*ATTRS': {type: 'text'},
|
||||||
|
'*TEXT': `Искать по названиям книг в выбранном жанре`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
this.makeEntry({
|
this.makeEntry({
|
||||||
id: 'search_help',
|
id: 'search_help',
|
||||||
title: '[Памятка по поиску]',
|
title: '[Памятка по поиску]',
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SeriesPage extends BasePage {
|
|||||||
const query = {
|
const query = {
|
||||||
series: req.query.series || '',
|
series: req.query.series || '',
|
||||||
genre: req.query.genre || '',
|
genre: req.query.genre || '',
|
||||||
del: 0,
|
del: '0',
|
||||||
|
|
||||||
all: req.query.all || '',
|
all: req.query.all || '',
|
||||||
depth: 0,
|
depth: 0,
|
||||||
@@ -46,7 +46,7 @@ class SeriesPage extends BasePage {
|
|||||||
|
|
||||||
if (bookList.books) {
|
if (bookList.books) {
|
||||||
let books = bookList.books;
|
let books = bookList.books;
|
||||||
const booksAll = this.filterBooks(books, {del: 0});
|
const booksAll = this.filterBooks(books);
|
||||||
const filtered = (query.all ? booksAll : this.filterBooks(books, query));
|
const filtered = (query.all ? booksAll : this.filterBooks(books, query));
|
||||||
const sorted = this.sortSeriesBooks(filtered);
|
const sorted = this.sortSeriesBooks(filtered);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class TitlePage extends BasePage {
|
|||||||
const query = {
|
const query = {
|
||||||
title: req.query.title || '',
|
title: req.query.title || '',
|
||||||
genre: req.query.genre || '',
|
genre: req.query.genre || '',
|
||||||
del: 0,
|
del: '0',
|
||||||
|
|
||||||
depth: 0,
|
depth: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,16 @@ let branch = '';
|
|||||||
const argvStrings = ['host', 'port', 'app-dir', 'lib-dir', 'inpx'];
|
const argvStrings = ['host', 'port', 'app-dir', 'lib-dir', 'inpx'];
|
||||||
|
|
||||||
function showHelp(defaultConfig) {
|
function showHelp(defaultConfig) {
|
||||||
console.log(utils.versionText(config));
|
console.log(utils.versionText(defaultConfig));
|
||||||
console.log(
|
console.log(
|
||||||
`Usage: ${config.name} [options]
|
`Usage: ${defaultConfig.name} [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print ${config.name} command line options
|
--help Print ${defaultConfig.name} command line options
|
||||||
--host=<ip> Set web server host, default: ${defaultConfig.server.host}
|
--host=<ip> Set web server host, default: ${defaultConfig.server.host}
|
||||||
--port=<port> Set web server port, default: ${defaultConfig.server.port}
|
--port=<port> Set web server port, default: ${defaultConfig.server.port}
|
||||||
--app-dir=<dirpath> Set application working directory, default: <execDir>/.${config.name}
|
--app-dir=<dirpath> Set application working directory, default: <execDir>/.${defaultConfig.name}
|
||||||
--lib-dir=<dirpath> Set library directory, default: the same as ${config.name} executable's
|
--lib-dir=<dirpath> Set library directory, default: the same as ${defaultConfig.name} executable's
|
||||||
--inpx=<filepath> Set INPX collection file, default: the one that found in library dir
|
--inpx=<filepath> Set INPX collection file, default: the one that found in library dir
|
||||||
--recreate Force recreation of the search database on start
|
--recreate Force recreation of the search database on start
|
||||||
`
|
`
|
||||||
@@ -84,7 +84,7 @@ async function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!config.remoteLib) {
|
if (!config.remoteLib) {
|
||||||
const libDir = argv['lib-dir'];
|
const libDir = argv['lib-dir'] || config.libDir;
|
||||||
if (libDir) {
|
if (libDir) {
|
||||||
if (await fs.pathExists(libDir)) {
|
if (await fs.pathExists(libDir)) {
|
||||||
config.libDir = libDir;
|
config.libDir = libDir;
|
||||||
@@ -95,11 +95,12 @@ async function init() {
|
|||||||
config.libDir = config.execDir;
|
config.libDir = config.execDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv.inpx) {
|
const inpxFile = argv.inpx || config.inpx;
|
||||||
if (await fs.pathExists(argv.inpx)) {
|
if (inpxFile) {
|
||||||
config.inpxFile = argv.inpx;
|
if (await fs.pathExists(inpxFile)) {
|
||||||
|
config.inpxFile = inpxFile;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`File "${argv.inpx}" not found`);
|
throw new Error(`File "${inpxFile}" not found`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const inpxFiles = [];
|
const inpxFiles = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user