Compare commits
154 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3943fc7d95 | ||
|
|
3999dc930c | ||
|
|
d4dea16456 | ||
|
|
ed38cb33a5 | ||
|
|
4cf5a0f4c8 | ||
|
|
8f0d526af2 | ||
|
|
6ca3881841 | ||
|
|
d8e765a04f | ||
|
|
40ff572f94 | ||
|
|
cc4275dc03 | ||
|
|
b387f4a0db | ||
|
|
1a096031c4 | ||
|
|
83a60b4091 | ||
|
|
b292407ec2 | ||
|
|
952c337b76 | ||
|
|
e947b887fe | ||
|
|
bd1e5485d7 | ||
|
|
e095c3318b | ||
|
|
d75a08b519 | ||
|
|
d55a616fe0 | ||
|
|
2146cb3576 | ||
|
|
ae260e74f6 | ||
|
|
355410c03c | ||
|
|
718ad51fac | ||
|
|
4242a8679f | ||
|
|
4ff9ff699b | ||
|
|
7a76673274 | ||
|
|
bd03ca5136 | ||
|
|
b3e1e4b909 | ||
|
|
4bb22183df | ||
|
|
e72f8f4245 | ||
|
|
5b52f48bce | ||
|
|
f07a157a2a | ||
|
|
ca40854106 | ||
|
|
d6a8209b31 | ||
|
|
731e1f1f15 | ||
|
|
b4a2a8fb98 | ||
|
|
5a3e4ee5ca | ||
|
|
ab2cf0aeec | ||
|
|
9de6a02b30 | ||
|
|
9fb7892bfe | ||
|
|
546f4556f6 | ||
|
|
471de104bc | ||
|
|
d30be1536d | ||
|
|
6c0678ed61 | ||
|
|
4883b8a190 | ||
|
|
14742ed4ad | ||
|
|
1d8bd56862 | ||
|
|
94b8f9fe1c | ||
|
|
27412211a5 | ||
|
|
f8c4960079 | ||
|
|
b2e0bcf995 | ||
|
|
fcf6639d38 | ||
|
|
d540cb91a9 | ||
|
|
f69cc6f1b1 | ||
|
|
607f2ff407 | ||
|
|
ba6bf8c091 | ||
|
|
7e4c938dfd | ||
|
|
7f36d55320 | ||
|
|
d9634a134c | ||
|
|
4f8868d4b1 | ||
|
|
956546585c | ||
|
|
3ca0a92442 | ||
|
|
213f7e48c9 | ||
|
|
8b66fd522d | ||
|
|
fdf5009999 | ||
|
|
bbdba0ef16 | ||
|
|
a63602df7a | ||
|
|
587120f984 | ||
|
|
e72ca0de7e | ||
|
|
c44c27d3d2 | ||
|
|
df4e201ccd | ||
|
|
c8c0e9ec1a | ||
|
|
9a4a84a367 | ||
|
|
1dc3424411 | ||
|
|
c13745e913 | ||
|
|
25c12309f2 | ||
|
|
4b632da5af | ||
|
|
87c364b8ee | ||
|
|
efa48fbc8a | ||
|
|
21df6c1d21 | ||
|
|
39d2ceb94b | ||
|
|
1dad013d60 | ||
|
|
add7a03f88 | ||
|
|
0cefaa6d48 | ||
|
|
f08e73f359 | ||
|
|
cf9ce26438 | ||
|
|
fd74a5a82e | ||
|
|
3109104928 | ||
|
|
b1ec4df2e4 | ||
|
|
1609e149a8 | ||
|
|
298c483d0e | ||
|
|
dc917b75b1 | ||
|
|
ad32bdab44 | ||
|
|
5e8b2e1c87 | ||
|
|
08b4afd287 | ||
|
|
0de31f643b | ||
|
|
5e815eb3c4 | ||
|
|
48c93a2120 | ||
|
|
ad5de42172 | ||
|
|
32bafedaad | ||
|
|
c67fd11be9 | ||
|
|
8b59c72848 | ||
|
|
c35b2f3bfc | ||
|
|
ac63ad4612 | ||
|
|
e1dea1c752 | ||
|
|
25648e2327 | ||
|
|
18ac04bb0f | ||
|
|
5263ee58b2 | ||
|
|
af542b89f7 | ||
|
|
684b675fca | ||
|
|
c29044eca1 | ||
|
|
a36510fcc8 | ||
|
|
bc21ace416 | ||
|
|
57e521e2ff | ||
|
|
ac6ebb9e8d | ||
|
|
54bef54635 | ||
|
|
593e201f79 | ||
|
|
d7b24253fe | ||
|
|
33961abd86 | ||
|
|
37e0e1d42f | ||
|
|
1121f9c918 | ||
|
|
582203f5da | ||
|
|
8c0f193738 | ||
|
|
ebe42956ad | ||
|
|
b8f8df8927 | ||
|
|
2c66ca4fdd | ||
|
|
49f813e880 | ||
|
|
da6fed80d1 | ||
|
|
b901d9b8c9 | ||
|
|
b41d46ac57 | ||
|
|
4f0189f3e0 | ||
|
|
c956e7a802 | ||
|
|
dcbc8409e0 | ||
|
|
fd58568cf0 | ||
|
|
0f81fa53d2 | ||
|
|
44655dc81c | ||
|
|
749667aefd | ||
|
|
dd94418c26 | ||
|
|
55a5375e46 | ||
|
|
df76de7352 | ||
|
|
1fb1a1b2b1 | ||
|
|
f998edb2aa | ||
|
|
7c2cb9a0c7 | ||
|
|
0690a365da | ||
|
|
a20d05aba8 | ||
|
|
4362ae95ba | ||
|
|
d658814399 | ||
|
|
39e14d70ee | ||
|
|
2e58cfdb75 | ||
|
|
fcaa724c00 | ||
|
|
8806b4141e | ||
|
|
7bd159766b | ||
|
|
4df15d603f |
@@ -8,7 +8,7 @@
|
||||

|
||||
|
||||
## VPS
|
||||
Для разворачивания читалки на чистом VPS с нуля смотрите [docs/omnireader](docs/omnireader/README.md)
|
||||
Для разворачивания читалки на чистом VPS с нуля смотрите [docs/omnireader.ru](docs/omnireader.ru/README.md)
|
||||
|
||||
## Сборка проекта
|
||||
Необходима версия node.js не ниже 10.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import * as utils from '../share/utils';
|
||||
|
||||
const cleanPeriod = 60*1000;//1 минута
|
||||
|
||||
class WebSocketConnection {
|
||||
@@ -9,6 +11,8 @@ class WebSocketConnection {
|
||||
this.messageQueue = [];
|
||||
this.messageLifeTime = messageLifeTime;
|
||||
this.requestId = 0;
|
||||
|
||||
this.connecting = false;
|
||||
}
|
||||
|
||||
addListener(listener) {
|
||||
@@ -53,14 +57,22 @@ class WebSocketConnection {
|
||||
}
|
||||
|
||||
open(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => { (async() => {
|
||||
//Ожидаем окончания процесса подключения, если open уже был вызван
|
||||
let i = 0;
|
||||
while (this.connecting && i < 200) {//10 сек
|
||||
await utils.sleep(50);
|
||||
i++;
|
||||
}
|
||||
if (i >= 200)
|
||||
this.connecting = false;
|
||||
|
||||
//проверим подключение, и если нет, то подключимся заново
|
||||
if (this.ws && this.ws.readyState == WebSocket.OPEN) {
|
||||
resolve(this.ws);
|
||||
} else {
|
||||
let protocol = 'ws:';
|
||||
if (window.location.protocol == 'https:') {
|
||||
protocol = 'wss:'
|
||||
}
|
||||
this.connecting = true;
|
||||
const protocol = (window.location.protocol == 'https:' ? 'wss:' : 'ws:');
|
||||
|
||||
url = url || `${protocol}//${window.location.host}/ws`;
|
||||
|
||||
@@ -71,9 +83,8 @@ class WebSocketConnection {
|
||||
}
|
||||
this.timer = setTimeout(() => { this.periodicClean(); }, cleanPeriod);
|
||||
|
||||
let resolved = false;
|
||||
this.ws.onopen = (e) => {
|
||||
resolved = true;
|
||||
this.connecting = false;
|
||||
resolve(e);
|
||||
};
|
||||
|
||||
@@ -97,11 +108,13 @@ class WebSocketConnection {
|
||||
|
||||
this.ws.onerror = (e) => {
|
||||
this.emit(e.message, true);
|
||||
if (!resolved)
|
||||
if (this.connecting) {
|
||||
this.connecting = false;
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
})() });
|
||||
}
|
||||
|
||||
//timeout в минутах (cleanPeriod)
|
||||
|
||||
@@ -1,56 +1,4 @@
|
||||
<template>
|
||||
<!--q-layout view="lhr lpr lfr">
|
||||
<q-drawer v-model="showAsideBar" :width="asideWidth">
|
||||
<div class="app-name"><span v-html="appName"></span></div>
|
||||
<q-btn class="el-button-collapse" @click="toggleCollapse"></q-btn>
|
||||
|
||||
<q-list>
|
||||
<q-item clickable v-ripple>
|
||||
<q-item-section avatar>
|
||||
<q-icon name="inbox" />
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>Inbox</q-item-section>
|
||||
</q-item>
|
||||
</q-list-->
|
||||
<!--el-menu class="el-menu-vertical" :default-active="rootRoute" :collapse="isCollapse" router>
|
||||
<el-menu-item index="/cardindex">
|
||||
<i class="el-icon-search"></i>
|
||||
<span :class="itemTitleClass('/cardindex')" slot="title">{{ this.itemRuText['/cardindex'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/reader">
|
||||
<i class="el-icon-tickets"></i>
|
||||
<span :class="itemTitleClass('/reader')" slot="title">{{ this.itemRuText['/reader'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/forum" disabled>
|
||||
<i class="el-icon-message"></i>
|
||||
<span :class="itemTitleClass('/forum')" slot="title">{{ this.itemRuText['/forum'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/income">
|
||||
<i class="el-icon-upload"></i>
|
||||
<span :class="itemTitleClass('/income')" slot="title">{{ this.itemRuText['/income'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/sources">
|
||||
<i class="el-icon-menu"></i>
|
||||
<span :class="itemTitleClass('/sources')" slot="title">{{ this.itemRuText['/sources'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/settings">
|
||||
<i class="el-icon-setting"></i>
|
||||
<span :class="itemTitleClass('/settings')" slot="title">{{ this.itemRuText['/settings'] }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/help">
|
||||
<i class="el-icon-question"></i>
|
||||
<span :class="itemTitleClass('/help')" slot="title">{{ this.itemRuText['/help'] }}</span>
|
||||
</el-menu-item>
|
||||
</el-menu-->
|
||||
<!--/q-drawer>
|
||||
|
||||
<q-page-container>
|
||||
<keep-alive>
|
||||
<router-view></router-view>
|
||||
</keep-alive>
|
||||
</q-page-container>
|
||||
</q-layout-->
|
||||
<div class="fit row">
|
||||
<Notify ref="notify"/>
|
||||
<StdDialog ref="stdDialog"/>
|
||||
@@ -90,7 +38,8 @@ class App extends Vue {
|
||||
'/sources': 'Источники',
|
||||
'/settings': 'Параметры',
|
||||
'/help': 'Справка',
|
||||
}
|
||||
};
|
||||
|
||||
created() {
|
||||
this.commit = this.$store.commit;
|
||||
this.dispatch = this.$store.dispatch;
|
||||
@@ -106,10 +55,20 @@ class App extends Vue {
|
||||
cachedPath = this.$route.path;
|
||||
const m = cachedPath.match(/^(\/[^/]*).*$/i);
|
||||
cachedRoute = (m ? m[1] : this.$route.path);
|
||||
|
||||
}
|
||||
return cachedRoute;
|
||||
}
|
||||
|
||||
this.$router.beforeEach((to, from, next) => {
|
||||
//распознавание хоста, если присутствует домен 3-уровня "b.", то разрешена только определенная страница
|
||||
if (window.location.host.indexOf('b.') == 0 && to.path != '/external-libs' && to.path != '/404') {
|
||||
next('/404');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
// set-app-title
|
||||
this.$root.$on('set-app-title', this.setAppTitle);
|
||||
|
||||
@@ -133,15 +92,26 @@ class App extends Vue {
|
||||
|
||||
document.addEventListener('keyup', (event) => {
|
||||
this.keyHook(event);
|
||||
});
|
||||
});
|
||||
document.addEventListener('keypress', (event) => {
|
||||
this.keyHook(event);
|
||||
});
|
||||
document.addEventListener('keydown', (event) => {
|
||||
this.keyHook(event);
|
||||
});
|
||||
});
|
||||
window.addEventListener('resize', () => {
|
||||
this.$root.$emit('resize');
|
||||
});
|
||||
}
|
||||
|
||||
routerReady() {
|
||||
return new Promise ((resolve) => {
|
||||
this.$router.onReady(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.$root.notify = this.$refs.notify;
|
||||
this.$root.stdDialog = this.$refs.stdDialog;
|
||||
@@ -157,7 +127,10 @@ class App extends Vue {
|
||||
});
|
||||
|
||||
this.setAppTitle();
|
||||
this.redirectIfNeeded();
|
||||
(async() => {
|
||||
await this.routerReady();
|
||||
this.redirectIfNeeded();
|
||||
})();
|
||||
}
|
||||
|
||||
toggleCollapse() {
|
||||
@@ -202,7 +175,9 @@ class App extends Vue {
|
||||
|
||||
setAppTitle(title) {
|
||||
if (!title) {
|
||||
if (this.mode == 'omnireader') {
|
||||
if (this.mode == 'liberama.top') {
|
||||
document.title = `Liberama Reader - всегда с вами`;
|
||||
} else if (this.mode == 'omnireader') {
|
||||
document.title = `Omni Reader - всегда с вами`;
|
||||
} else if (this.config && this.mode !== null) {
|
||||
document.title = `${this.config.name} - ${this.itemRuText[this.$root.rootRoute]}`;
|
||||
@@ -221,29 +196,32 @@ class App extends Vue {
|
||||
}
|
||||
|
||||
get showAsideBar() {
|
||||
return (this.mode !== null && this.mode != 'reader' && this.mode != 'omnireader');
|
||||
return (this.mode !== null && this.mode != 'reader' && this.mode != 'omnireader' && this.mode != 'liberama.top');
|
||||
}
|
||||
|
||||
set showAsideBar(value) {
|
||||
}
|
||||
|
||||
get isReaderActive() {
|
||||
return this.rootRoute == '/reader';
|
||||
return (this.rootRoute == '/reader' || this.rootRoute == '/external-libs');
|
||||
}
|
||||
|
||||
redirectIfNeeded() {
|
||||
if ((this.mode == 'reader' || this.mode == 'omnireader') && (!this.isReaderActive)) {
|
||||
//старый url
|
||||
if ((this.mode == 'reader' || this.mode == 'omnireader' || this.mode == 'liberama.top')) {
|
||||
const search = window.location.search.substr(1);
|
||||
const s = search.split('url=');
|
||||
const url = s[1] || '';
|
||||
const q = utils.parseQuery(s[0] || '');
|
||||
if (url) {
|
||||
q.url = decodeURIComponent(url);
|
||||
}
|
||||
|
||||
window.history.replaceState({}, '', '/');
|
||||
this.$router.replace({ path: '/reader', query: q });
|
||||
//распознавание параметра url вида "?url=<link>" и редирект при необходимости
|
||||
if (!this.isReaderActive) {
|
||||
const s = search.split('url=');
|
||||
const url = s[1] || '';
|
||||
const q = utils.parseQuery(s[0] || '');
|
||||
if (url) {
|
||||
q.url = decodeURIComponent(url);
|
||||
}
|
||||
|
||||
window.history.replaceState({}, '', '/');
|
||||
this.$router.replace({ path: '/reader', query: q });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +248,7 @@ body, html, #app {
|
||||
}
|
||||
|
||||
.dborder {
|
||||
border: 2px solid yellow !important;
|
||||
border: 2px solid magenta !important;
|
||||
}
|
||||
|
||||
.icon-rotate {
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
<template>
|
||||
<Window ref="window" width="600px" height="95%" @close="close">
|
||||
<template slot="header">
|
||||
Настроить закладки
|
||||
</template>
|
||||
|
||||
<div class="col column fit">
|
||||
<div class="row items-center top-panel bg-grey-3">
|
||||
<q-btn class="q-mr-md" round dense color="blue" icon="la la-check" @click.stop="openSelected" size="16px" :disabled="!selected">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть выбранную закладку</q-tooltip>
|
||||
</q-btn>
|
||||
<q-input class="col" ref="search" rounded outlined dense bg-color="white" placeholder="Найти" v-model="search">
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="search !== ''" name="la la-times" class="cursor-pointer" @click="resetSearch"/>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
|
||||
<div class="col row">
|
||||
<div class="left-panel column items-center no-wrap bg-grey-3">
|
||||
<q-btn class="q-my-sm" round dense color="blue" icon="la la-plus" @click.stop="addBookmark" size="14px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="q-mb-sm" round dense color="blue" icon="la la-minus" @click.stop="delBookmark" size="14px" :disabled="!ticked.length">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Удалить отмеченные закладки</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="q-mb-sm" round dense color="blue" icon="la la-edit" @click.stop="editBookmark" size="14px" :disabled="!selected || selected.indexOf('r-') == 0">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Редактировать закладку</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="q-mb-sm" round dense color="blue" icon="la la-arrow-up" @click.stop="moveBookmark(false)" size="14px" :disabled="!ticked.length">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Переместить отмеченные вверх</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="q-mb-sm" round dense color="blue" icon="la la-arrow-down" @click.stop="moveBookmark(true)" size="14px" :disabled="!ticked.length">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Переместить отмеченные вниз</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="q-mb-sm" round dense color="blue" icon="la la-broom" @click.stop="setDefaultBookmarks" size="14px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Установить по умолчанию</q-tooltip>
|
||||
</q-btn>
|
||||
<div class="space"/>
|
||||
</div>
|
||||
|
||||
<div class="col fit tree">
|
||||
<div v-show="nodes.length" class="checkbox-tick-all">
|
||||
<q-checkbox v-model="tickAll" @input="makeTickAll" size="36px" label="Выбрать все" />
|
||||
</div>
|
||||
<q-tree
|
||||
class="q-my-xs"
|
||||
:nodes="nodes"
|
||||
node-key="key"
|
||||
tick-strategy="leaf"
|
||||
:selected.sync="selected"
|
||||
:ticked.sync="ticked"
|
||||
:expanded.sync="expanded"
|
||||
selected-color="black"
|
||||
:filter="search"
|
||||
no-nodes-label="Закладок пока нет"
|
||||
no-results-label="Ничего не найдено"
|
||||
>
|
||||
<template v-slot:default-header="p">
|
||||
<div class="q-px-xs" :class="{selected: selected == p.key}">{{ p.node.label }}</div>
|
||||
</template>
|
||||
</q-tree>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Window>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Window from '../../share/Window.vue';
|
||||
import * as lu from '../linkUtils';
|
||||
import rstore from '../../../store/modules/reader';
|
||||
|
||||
const BookmarkSettingsProps = Vue.extend({
|
||||
props: {
|
||||
libs: Object,
|
||||
addBookmarkVisible: Boolean,
|
||||
}
|
||||
});
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
Window,
|
||||
},
|
||||
watch: {
|
||||
ticked: function() {
|
||||
this.checkAllTicked();
|
||||
},
|
||||
}
|
||||
})
|
||||
class BookmarkSettings extends BookmarkSettingsProps {
|
||||
search = '';
|
||||
selected = '';
|
||||
ticked = [];
|
||||
expanded = [];
|
||||
tickAll = false;
|
||||
|
||||
created() {
|
||||
this.afterInit = true;
|
||||
}
|
||||
|
||||
mounted() {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.$refs.window.init();
|
||||
}
|
||||
|
||||
get nodes() {
|
||||
const result = [];
|
||||
|
||||
const expanded = [];
|
||||
this.links = {};
|
||||
this.libs.groups.forEach(group => {
|
||||
const rkey = `r-${group.r}`;
|
||||
const g = {label: group.r, key: rkey, children: []};
|
||||
this.links[rkey] = {l: group.r, c: ''};
|
||||
|
||||
group.list.forEach(link => {
|
||||
const key = link.l;
|
||||
g.children.push({
|
||||
label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l),
|
||||
key
|
||||
});
|
||||
|
||||
this.links[key] = link;
|
||||
if (link.l == this.libs.startLink && expanded.indexOf(rkey) < 0) {
|
||||
expanded.push(rkey);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
result.push(g);
|
||||
});
|
||||
|
||||
if (this.afterInit) {
|
||||
this.$nextTick(() => {
|
||||
this.expanded = expanded;
|
||||
});
|
||||
this.afterInit = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
makeTickAll() {
|
||||
if (this.tickAll) {
|
||||
const newTicked = [];
|
||||
for (const key of Object.keys(this.links)) {
|
||||
if (key.indexOf('r-') != 0)
|
||||
newTicked.push(key);
|
||||
}
|
||||
this.ticked = newTicked;
|
||||
} else {
|
||||
this.ticked = [];
|
||||
}
|
||||
}
|
||||
|
||||
checkAllTicked() {
|
||||
const ticked = new Set(this.ticked);
|
||||
|
||||
let newTickAll = !!(this.nodes.length);
|
||||
for (const key of Object.keys(this.links)) {
|
||||
if (key.indexOf('r-') != 0 && !ticked.has(key))
|
||||
newTickAll = false;
|
||||
}
|
||||
this.tickAll = newTickAll;
|
||||
}
|
||||
|
||||
resetSearch() {
|
||||
this.search = '';
|
||||
this.$refs.search.focus();
|
||||
}
|
||||
|
||||
openSelected() {
|
||||
if (!this.selected)
|
||||
return;
|
||||
if (this.selected.indexOf('r-') === 0) {//rootLink
|
||||
this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected].l});
|
||||
} else {//selectedLink
|
||||
this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected].l});
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
|
||||
editBookmark() {
|
||||
this.$emit('do-action', {action: 'editBookmark', data: {link: this.links[this.selected].l, desc: this.links[this.selected].c}});
|
||||
}
|
||||
|
||||
addBookmark() {
|
||||
this.$emit('do-action', {action: 'addBookmark'});
|
||||
}
|
||||
|
||||
async delBookmark() {
|
||||
const newLibs = _.cloneDeep(this.libs);
|
||||
|
||||
if (await this.$root.stdDialog.confirm(`Подтвердите удаление ${this.ticked.length} закладок:`, ' ')) {
|
||||
const ticked = new Set(this.ticked);
|
||||
for (let i = newLibs.groups.length - 1; i >= 0; i--) {
|
||||
const g = newLibs.groups[i];
|
||||
for (let j = g.list.length - 1; j >= 0; j--) {
|
||||
if (ticked.has(g.list[j].l)) {
|
||||
delete g.list[j];
|
||||
}
|
||||
}
|
||||
g.list = g.list.filter(v => v);
|
||||
if (!g.list.length)
|
||||
delete newLibs.groups[i];
|
||||
else {
|
||||
const item = lu.getListItemByLink(g.list, g.s);
|
||||
if (!item)
|
||||
g.s = g.list[0].l;
|
||||
}
|
||||
}
|
||||
|
||||
newLibs.groups = newLibs.groups.filter(v => v);
|
||||
this.ticked = [];
|
||||
this.selected = '';
|
||||
this.$emit('do-action', {action: 'setLibs', data: newLibs});
|
||||
}
|
||||
}
|
||||
|
||||
moveBookmark(down = false) {
|
||||
const newLibs = _.cloneDeep(this.libs);
|
||||
|
||||
const ticked = new Set(this.ticked);
|
||||
let moved = false;
|
||||
let prevFull = false;
|
||||
if (!down) {
|
||||
for (let i = 0; i < newLibs.groups.length; i++) {
|
||||
const g = newLibs.groups[i];
|
||||
let count = 0;
|
||||
for (let j = 0; j < g.list.length; j++) {
|
||||
if (ticked.has(g.list[j].l)) {
|
||||
if (j > 0 && !ticked.has(g.list[j - 1].l)) {
|
||||
[g.list[j], g.list[j - 1]] = [g.list[j - 1], g.list[j]];
|
||||
moved = true;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == g.list.length && !prevFull && i > 0) {
|
||||
const gs = newLibs.groups;
|
||||
[gs[i], gs[i - 1]] = [gs[i - 1], gs[i]];
|
||||
moved = true;
|
||||
} else
|
||||
prevFull = (count == g.list.length);
|
||||
}
|
||||
} else {
|
||||
for (let i = newLibs.groups.length - 1; i >= 0; i--) {
|
||||
const g = newLibs.groups[i];
|
||||
let count = 0;
|
||||
for (let j = g.list.length - 1; j >= 0; j--) {
|
||||
if (ticked.has(g.list[j].l)) {
|
||||
if (j < g.list.length - 1 && !ticked.has(g.list[j + 1].l)) {
|
||||
[g.list[j], g.list[j + 1]] = [g.list[j + 1], g.list[j]];
|
||||
moved = true;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == g.list.length && !prevFull && i < newLibs.groups.length - 1) {
|
||||
const gs = newLibs.groups;
|
||||
[gs[i], gs[i + 1]] = [gs[i + 1], gs[i]];
|
||||
moved = true;
|
||||
} else
|
||||
prevFull = (count == g.list.length);
|
||||
}
|
||||
}
|
||||
|
||||
if (moved)
|
||||
this.$emit('do-action', {action: 'setLibs', data: newLibs});
|
||||
}
|
||||
|
||||
async setDefaultBookmarks() {
|
||||
const result = await this.$root.stdDialog.prompt(`Введите 'да' для сброса всех закладок в предустановленные значения:`, ' ', {
|
||||
inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Удаление не подтверждено'; },
|
||||
});
|
||||
|
||||
if (result && result.value && result.value.toLowerCase() == 'да') {
|
||||
this.$emit('do-action', {action: 'setLibs', data: _.cloneDeep(
|
||||
Object.assign({helpShowed: true}, rstore.libsDefaults)
|
||||
)});
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.afterInit = false;
|
||||
this.$emit('close');
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (this.addBookmarkVisible)
|
||||
return false;
|
||||
|
||||
if (event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.top-panel {
|
||||
height: 50px;
|
||||
border-bottom: 1px solid gray;
|
||||
padding: 0 10px 0 12px;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
width: 60px;
|
||||
height: 100%;
|
||||
border-right: 1px solid gray;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.tree {
|
||||
padding: 0px 10px 10px 10px;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.selected {
|
||||
text-shadow: 0 0 20px yellow, 0 0 15px yellow, 0 0 10px yellow, 0 0 10px yellow, 0 0 5px yellow;
|
||||
}
|
||||
|
||||
.checkbox-tick-all {
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
margin-bottom: 7px;
|
||||
padding: 5px 5px 2px 16px;
|
||||
}
|
||||
|
||||
.space {
|
||||
min-height: 1px;
|
||||
width: 1px;
|
||||
}
|
||||
</style>
|
||||
858
client/components/ExternalLibs/ExternalLibs.vue
Normal file
@@ -0,0 +1,858 @@
|
||||
<template>
|
||||
<Window ref="window" @close="close" margin="2px">
|
||||
<template slot="header">
|
||||
{{ header }}
|
||||
</template>
|
||||
|
||||
<template slot="buttons">
|
||||
<span class="full-screen-button row justify-center items-center" @mousedown.stop @click="fullScreenToggle">
|
||||
<q-icon :name="(fullScreenActive ? 'la la-compress-arrows-alt': 'la la-expand-arrows-alt')" size="16px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">На весь экран</q-tooltip>
|
||||
</span>
|
||||
<span class="full-screen-button row justify-center items-center" @mousedown.stop @click="changeScale(0.1)">
|
||||
<q-icon name="la la-plus" size="16px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Увеличить масштаб</q-tooltip>
|
||||
</span>
|
||||
<span class="full-screen-button row justify-center items-center" @mousedown.stop @click="changeScale(-0.1)">
|
||||
<q-icon name="la la-minus" size="16px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Уменьшить масштаб</q-tooltip>
|
||||
</span>
|
||||
<span class="full-screen-button row justify-center items-center" @mousedown.stop @click="showHelp">
|
||||
<q-icon name="la la-question-circle" size="16px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Справка</q-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<div v-show="ready" class="col column" style="min-width: 600px">
|
||||
<div class="row items-center q-px-sm" style="height: 50px">
|
||||
<q-select class="q-mr-sm" ref="rootLink" v-model="rootLink" :options="rootLinkOptions" @input="rootLinkInput"
|
||||
@popup-show="onSelectPopupShow" @popup-hide="onSelectPopupHide"
|
||||
style="width: 230px"
|
||||
dropdown-icon="la la-angle-down la-sm"
|
||||
rounded outlined dense emit-value map-options display-value-sanitize options-sanitize
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-plus" @click.stop="addBookmark" size="12px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn round dense color="blue" icon="la la-bars" @click.stop="bookmarkSettings" size="12px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Настроить закладки</q-tooltip>
|
||||
</q-btn>
|
||||
</template>
|
||||
<template v-slot:selected>
|
||||
<div style="overflow: hidden; white-space: nowrap;">{{ rootLinkWithoutProtocol }}</div>
|
||||
</template>
|
||||
</q-select>
|
||||
|
||||
<q-select class="q-mr-sm" ref="selectedLink" v-model="selectedLink" :options="selectedLinkOptions" @input="selectedLinkInput" style="width: 50px"
|
||||
@popup-show="onSelectPopupShow" @popup-hide="onSelectPopupHide"
|
||||
dropdown-icon="la la-angle-down la-sm"
|
||||
rounded outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
|
||||
>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Закладки</q-tooltip>
|
||||
</q-select>
|
||||
|
||||
<q-input class="col q-mr-sm" ref="input" rounded outlined dense bg-color="white" v-model="bookUrl" placeholder="Скопируйте сюда URL книги"
|
||||
@focus="selectAllOnFocus" @keydown="bookUrlKeyDown"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(selectedLink)" size="12px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px" :disabled="!bookUrl">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Загрузить URL во фрейм</q-tooltip>
|
||||
</q-btn>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
<q-btn round dense color="blue" icon="la la-cog" @click.stop="optionsVisible = true" size="12px">
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Опции</q-tooltip>
|
||||
</q-btn>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-btn rounded color="green-7" no-caps size="14px" @click="submitUrl" :disabled="!bookUrl">Открыть
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть в читалке</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
|
||||
<div class="col fit" ref="frameBox" style="position: relative;">
|
||||
<div ref="frameWrap" class="overflow-hidden">
|
||||
<iframe v-if="frameVisible" ref="frame" :src="frameSrc" frameborder="0"></iframe>
|
||||
</div>
|
||||
<div v-show="transparentLayoutVisible" ref="transparentLayout" class="fit transparent-layout" @click="transparentLayoutClick"></div>
|
||||
</div>
|
||||
|
||||
<Dialog ref="dialogAddBookmark" v-model="addBookmarkVisible">
|
||||
<template slot="header">
|
||||
<div class="row items-center">
|
||||
<q-icon class="q-mr-sm" name="la la-bookmark" size="28px"></q-icon>
|
||||
<div v-if="addBookmarkMode == 'edit'">Редактировать закладку</div>
|
||||
<div v-else>Добавить закладку</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="q-mx-md row">
|
||||
<q-input ref="bookmarkLink" class="col q-mr-sm" outlined dense bg-color="white" v-model="bookmarkLink" @keydown="bookmarkLinkKeyDown"
|
||||
placeholder="Ссылка для закладки" maxlength="2000" @focus="selectAllOnFocus">
|
||||
</q-input>
|
||||
|
||||
<q-select class="q-mr-sm" ref="defaultRootLink" v-model="defaultRootLink" :options="defaultRootLinkOptions" @input="defaultRootLinkInput" style="width: 50px"
|
||||
dropdown-icon="la la-angle-down la-sm"
|
||||
outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
|
||||
>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Предустановленные ссылки</q-tooltip>
|
||||
</q-select>
|
||||
</div>
|
||||
|
||||
<div class="q-mx-md q-mt-md">
|
||||
<q-input class="col q-mr-sm" ref="bookmarkDesc" outlined dense bg-color="white" v-model="bookmarkDesc" @keydown="bookmarkDescKeyDown"
|
||||
placeholder="Описание" style="width: 400px" maxlength="100" @focus="selectAllOnFocus">
|
||||
</q-input>
|
||||
</div>
|
||||
|
||||
<template slot="footer">
|
||||
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
||||
<q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okAddBookmark" :disabled="!bookmarkLink">OK</q-btn>
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref="options" v-model="optionsVisible">
|
||||
<template slot="header">
|
||||
<div class="row items-center">
|
||||
<q-icon class="q-mr-sm" name="la la-cog" size="28px"></q-icon>
|
||||
Опции
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="q-mx-md column">
|
||||
<q-checkbox v-model="closeAfterSubmit" size="36px" label="Закрыть окно при отправке ссылки в читалку" />
|
||||
<q-checkbox v-model="openInFrameOnEnter" size="36px" label="Открывать ссылку во фрейме при нажатии 'Enter'" />
|
||||
<q-checkbox v-model="openInFrameOnAdd" size="36px" label="Активировать новую закладку после добавления" />
|
||||
</div>
|
||||
|
||||
<template slot="footer">
|
||||
<q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="optionsVisible = false">OK</q-btn>
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
<BookmarkSettings v-if="bookmarkSettingsActive" ref="bookmarkSettings" :libs="libs" :addBookmarkVisible="addBookmarkVisible"
|
||||
@do-action="doAction" @close="closeBookmarkSettings">
|
||||
</BookmarkSettings>
|
||||
</Window>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Window from '../share/Window.vue';
|
||||
import Dialog from '../share/Dialog.vue';
|
||||
import BookmarkSettings from './BookmarkSettings/BookmarkSettings.vue';
|
||||
|
||||
import rstore from '../../store/modules/reader';
|
||||
import * as utils from '../../share/utils';
|
||||
import * as lu from './linkUtils';
|
||||
|
||||
const proxySubst = {
|
||||
'http://flibusta.is': 'http://b.liberama.top:23480',
|
||||
'http://fantasy-worlds.org': 'http://b.liberama.top:23580',
|
||||
};
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
Window,
|
||||
Dialog,
|
||||
BookmarkSettings
|
||||
},
|
||||
watch: {
|
||||
libs: function() {
|
||||
this.loadLibs();
|
||||
},
|
||||
defaultRootLink: function() {
|
||||
this.updateBookmarkLink();
|
||||
},
|
||||
bookUrl: function(newValue) {
|
||||
const value = lu.addProtocol(newValue);
|
||||
const subst = this.makeProxySubst(value, true);
|
||||
if (value != subst) {
|
||||
this.$nextTick(() => {
|
||||
this.bookUrl = subst;
|
||||
});
|
||||
}
|
||||
},
|
||||
bookmarkLink: function(newValue) {
|
||||
const value = lu.addProtocol(newValue);
|
||||
const subst = this.makeProxySubst(value, true);
|
||||
if (value != subst) {
|
||||
this.$nextTick(() => {
|
||||
this.bookmarkLink = subst;
|
||||
});
|
||||
}
|
||||
},
|
||||
closeAfterSubmit: function(newValue) {
|
||||
this.commitProp('closeAfterSubmit', newValue);
|
||||
},
|
||||
openInFrameOnEnter: function(newValue) {
|
||||
this.commitProp('openInFrameOnEnter', newValue);
|
||||
},
|
||||
openInFrameOnAdd: function(newValue) {
|
||||
this.commitProp('openInFrameOnAdd', newValue);
|
||||
},
|
||||
}
|
||||
})
|
||||
class ExternalLibs extends Vue {
|
||||
ready = false;
|
||||
frameVisible = false;
|
||||
rootLink = '';
|
||||
selectedLink = '';
|
||||
frameSrc = '';
|
||||
bookUrl = '';
|
||||
libs = {};
|
||||
fullScreenActive = false;
|
||||
transparentLayoutVisible = false;
|
||||
|
||||
addBookmarkVisible = false;
|
||||
optionsVisible = false;
|
||||
|
||||
addBookmarkMode = '';
|
||||
bookmarkLink = '';
|
||||
bookmarkDesc = '';
|
||||
defaultRootLink = '';
|
||||
|
||||
bookmarkSettingsActive = false;
|
||||
|
||||
closeAfterSubmit = false;
|
||||
openInFrameOnEnter = false;
|
||||
openInFrameOnAdd = false;
|
||||
frameScale = 1;
|
||||
|
||||
created() {
|
||||
this.oldStartLink = '';
|
||||
this.justOpened = true;
|
||||
this.$root.addKeyHook(this.keyHook);
|
||||
|
||||
this.$root.$on('resize', async() => {
|
||||
await utils.sleep(200);
|
||||
this.frameResize();
|
||||
});
|
||||
|
||||
document.addEventListener('fullscreenchange', () => {
|
||||
this.fullScreenActive = (document.fullscreenElement !== null);
|
||||
});
|
||||
|
||||
this.debouncedGoToLink = _.debounce((link) => {
|
||||
this.goToLink(link);
|
||||
}, 100, {'maxWait':200});
|
||||
//this.commit = this.$store.commit;
|
||||
//this.commit('reader/setLibs', rstore.libsDefaults);
|
||||
}
|
||||
|
||||
mounted() {
|
||||
//Поправка метода toggleOption компонента select фреймворка quasar, необходимо другое поведение
|
||||
//$emit('input'.. вызывается всегда
|
||||
this.toggleOption = function(opt, keepOpen) {
|
||||
if (this.editable !== true || opt === void 0 || this.isOptionDisabled(opt) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const optValue = this.getOptionValue(opt);
|
||||
|
||||
if (this.multiple !== true) {
|
||||
if (keepOpen !== true) {
|
||||
this.updateInputValue(this.fillInput === true ? this.getOptionLabel(opt) : '', true, true);
|
||||
this.hidePopup();
|
||||
}
|
||||
|
||||
this.$refs.target !== void 0 && this.$refs.target.focus();
|
||||
this.$emit('input', this.emitValue === true ? optValue : opt);
|
||||
}
|
||||
};
|
||||
|
||||
this.$refs.rootLink.toggleOption = this.toggleOption;
|
||||
this.$refs.selectedLink.toggleOption = this.toggleOption;
|
||||
|
||||
(async() => {
|
||||
//подождем this.mode
|
||||
let i = 0;
|
||||
while(!this.mode && i < 100) {
|
||||
await utils.sleep(100);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (this.mode != 'liberama.top') {
|
||||
this.$router.replace('/404');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$refs.window.init();
|
||||
|
||||
this.opener = null;
|
||||
const host = window.location.host;
|
||||
const openerHost = (host.indexOf('b.') == 0 ? host.substring(2) : host);
|
||||
const openerOrigin1 = `http://${openerHost}`;
|
||||
const openerOrigin2 = `https://${openerHost}`;
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.origin !== openerOrigin1 && event.origin !== openerOrigin2)
|
||||
return;
|
||||
if (!_.isObject(event.data) || event.data.from != 'LibsPage')
|
||||
return;
|
||||
if (event.origin == openerOrigin1)
|
||||
this.opener = window.opener;
|
||||
else
|
||||
this.opener = event.source;
|
||||
this.openerOrigin = event.origin;
|
||||
|
||||
//console.log(event);
|
||||
|
||||
this.recvMessage(event.data);
|
||||
});
|
||||
|
||||
//Ожидаем родителя
|
||||
i = 0;
|
||||
while(!this.opener) {
|
||||
await utils.sleep(1000);
|
||||
i++;
|
||||
if (i >= 5) {
|
||||
await this.$root.stdDialog.alert('Нет связи с читалкой. Окно будет закрыто', 'Ошибка');
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка закрытия родительского окна
|
||||
while(this.opener) {
|
||||
await this.checkOpener();
|
||||
await utils.sleep(1000);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
recvMessage(d) {
|
||||
if (d.type == 'mes') {
|
||||
switch(d.data) {
|
||||
case 'hello': this.sendMessage({type: 'mes', data: 'ready'}); break;
|
||||
}
|
||||
} else if (d.type == 'libs') {
|
||||
this.ready = true;
|
||||
this.libs = _.cloneDeep(d.data);
|
||||
} else if (d.type == 'notify') {
|
||||
this.$root.notify.success(d.data, '', {position: 'bottom-right'});
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(d) {
|
||||
(async() => {
|
||||
await this.checkOpener();
|
||||
if (this.opener && this.openerOrigin)
|
||||
this.opener.postMessage(Object.assign({}, {from: 'ExternalLibs'}, d), this.openerOrigin);
|
||||
})();
|
||||
}
|
||||
|
||||
async checkOpener() {
|
||||
if (this.opener.closed) {
|
||||
await this.$root.stdDialog.alert('Потеряна связь с читалкой. Окно будет закрыто', 'Ошибка');
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
commitLibs(libs) {
|
||||
this.sendMessage({type: 'libs', data: libs});
|
||||
}
|
||||
|
||||
commitProp(prop, value) {
|
||||
let libs = _.cloneDeep(this.libs);
|
||||
libs[prop] = value;
|
||||
this.commitLibs(libs);
|
||||
}
|
||||
|
||||
loadLibs() {
|
||||
const libs = this.libs;
|
||||
|
||||
if (!libs.helpShowed) {
|
||||
this.showHelp();
|
||||
(async() => {
|
||||
await utils.sleep(1000);
|
||||
this.commitProp('helpShowed', true);
|
||||
})();
|
||||
}
|
||||
|
||||
this.selectedLink = libs.startLink;
|
||||
this.closeAfterSubmit = libs.closeAfterSubmit || false;
|
||||
this.openInFrameOnEnter = libs.openInFrameOnEnter || false;
|
||||
this.openInFrameOnAdd = libs.openInFrameOnAdd || false;
|
||||
|
||||
this.frameScale = 1;
|
||||
const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.selectedLink);
|
||||
if (index >= 0)
|
||||
this.frameScale = this.libs.groups[index].frameScale || 1;
|
||||
|
||||
this.updateStartLink();
|
||||
}
|
||||
|
||||
doAction(event) {
|
||||
switch (event.action) {
|
||||
case 'setLibs': this.commitLibs(event.data); break;
|
||||
case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break;
|
||||
case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break;
|
||||
case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break;
|
||||
case 'addBookmark': this.addBookmark('add'); break;
|
||||
}
|
||||
}
|
||||
|
||||
get mode() {
|
||||
return this.$store.state.config.mode;
|
||||
}
|
||||
|
||||
get header() {
|
||||
let result = (this.ready ? 'Библиотека' : 'Загрузка...');
|
||||
if (this.ready && this.selectedLink) {
|
||||
result += ` | ${(this.libs.comment ? this.libs.comment + ' ': '') + lu.removeProtocol(this.libs.startLink)}`;
|
||||
}
|
||||
this.$root.$emit('set-app-title', result);
|
||||
return result;
|
||||
}
|
||||
|
||||
get rootLinkWithoutProtocol() {
|
||||
return lu.removeProtocol(this.rootLink);
|
||||
}
|
||||
|
||||
updateSelectedLinkByRoot() {
|
||||
if (!this.ready)
|
||||
return;
|
||||
|
||||
const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||
if (index >= 0)
|
||||
this.selectedLink = this.libs.groups[index].s;
|
||||
else
|
||||
this.selectedLink = '';
|
||||
}
|
||||
|
||||
updateStartLink(force) {
|
||||
if (!this.ready)
|
||||
return;
|
||||
|
||||
let index = -1;
|
||||
try {
|
||||
this.rootLink = lu.getOrigin(this.selectedLink);
|
||||
index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
let libs = _.cloneDeep(this.libs);
|
||||
const com = this.getCommentByLink(libs.groups[index].list, this.selectedLink);
|
||||
if (libs.groups[index].s != this.selectedLink ||
|
||||
libs.startLink != this.selectedLink ||
|
||||
libs.comment != com) {
|
||||
libs.groups[index].s = this.selectedLink;
|
||||
libs.startLink = this.selectedLink;
|
||||
libs.comment = com;
|
||||
this.commitLibs(libs);
|
||||
}
|
||||
|
||||
if (force || this.oldStartLink != libs.startLink) {
|
||||
this.oldStartLink = libs.startLink;
|
||||
this.debouncedGoToLink(this.selectedLink);
|
||||
}
|
||||
} else {
|
||||
this.rootLink = '';
|
||||
this.selectedLink = '';
|
||||
this.debouncedGoToLink(this.selectedLink);
|
||||
}
|
||||
}
|
||||
|
||||
get rootLinkOptions() {
|
||||
let result = [];
|
||||
if (!this.ready)
|
||||
return result;
|
||||
|
||||
this.libs.groups.forEach(group => {
|
||||
result.push({label: lu.removeProtocol(group.r), value: group.r});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
get defaultRootLinkOptions() {
|
||||
let result = [];
|
||||
|
||||
rstore.libsDefaults.groups.forEach(group => {
|
||||
result.push({label: lu.removeProtocol(group.r), value: group.r});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
get selectedLinkOptions() {
|
||||
let result = [];
|
||||
if (!this.ready)
|
||||
return result;
|
||||
|
||||
const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||
if (index >= 0) {
|
||||
this.libs.groups[index].list.forEach(link => {
|
||||
result.push({label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), value: link.l});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
openBookUrlInFrame() {
|
||||
if (this.bookUrl) {
|
||||
this.goToLink(lu.addProtocol(this.bookUrl));
|
||||
}
|
||||
}
|
||||
|
||||
goToLink(link) {
|
||||
if (!this.ready || !link)
|
||||
return;
|
||||
|
||||
if (!link) {
|
||||
this.frameVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.frameSrc = this.makeProxySubst(link);
|
||||
|
||||
this.frameVisible = false;
|
||||
this.$nextTick(() => {
|
||||
this.frameVisible = true;
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.frame) {
|
||||
this.$refs.frame.contentWindow.focus();
|
||||
this.frameResize();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
frameResize() {
|
||||
this.$refs.frameWrap.style = 'width: 1px; height: 1px;';
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.frame) {
|
||||
const w = this.$refs.frameBox.offsetWidth;
|
||||
const h = this.$refs.frameBox.offsetHeight;
|
||||
const normalSize = `width: ${w}px; height: ${h}px;`;
|
||||
this.$refs.frameWrap.style = normalSize;
|
||||
if (this.frameScale != 1) {
|
||||
const s = this.frameScale;
|
||||
this.$refs.frame.style = `width: ${w/s}px; height: ${h/s}px; transform: scale(${s}); transform-origin: 0 0;`;
|
||||
} else {
|
||||
this.$refs.frame.style = normalSize;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeScale(delta) {
|
||||
if ((this.frameScale > 0.1 && delta <= 0) || (this.frameScale < 5 && delta >= 0)) {
|
||||
this.frameScale = _.round(this.frameScale + delta, 1);
|
||||
|
||||
const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.selectedLink);
|
||||
if (index >= 0) {
|
||||
let libs = _.cloneDeep(this.libs);
|
||||
libs.groups[index].frameScale = this.frameScale;
|
||||
this.commitLibs(libs);
|
||||
}
|
||||
|
||||
this.frameResize();
|
||||
this.$root.notify.success(`Масштаб изменен: ${(this.frameScale*100).toFixed(0)}%`, '', {position: 'bottom-right'});
|
||||
}
|
||||
}
|
||||
|
||||
getCommentByLink(list, link) {
|
||||
const item = lu.getListItemByLink(list, link);
|
||||
return (item ? item.c : '');
|
||||
}
|
||||
|
||||
makeProxySubst(url, reverse = false) {
|
||||
for (const [key, value] of Object.entries(proxySubst)) {
|
||||
if (reverse && value == url.substring(0, value.length)) {
|
||||
return key + url.substring(value.length);
|
||||
} else if (!reverse && key == url.substring(0, key.length)) {
|
||||
return value + url.substring(key.length);
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
selectAllOnFocus(event) {
|
||||
if (event.target.select)
|
||||
event.target.select();
|
||||
}
|
||||
|
||||
rootLinkInput() {
|
||||
this.updateSelectedLinkByRoot();
|
||||
this.updateStartLink(true);
|
||||
}
|
||||
|
||||
selectedLinkInput() {
|
||||
this.updateStartLink(true);
|
||||
}
|
||||
|
||||
submitUrl() {
|
||||
if (this.bookUrl) {
|
||||
this.sendMessage({type: 'submitUrl', data: {
|
||||
url: this.bookUrl,
|
||||
force: true
|
||||
}});
|
||||
this.bookUrl = '';
|
||||
if (this.closeAfterSubmit)
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
addBookmark(mode = 'add', link = '', desc = '') {
|
||||
|
||||
if (mode == 'edit') {
|
||||
this.editBookmarkLink = this.bookmarkLink = link;
|
||||
this.editBookmarkDesc = this.bookmarkDesc = desc;
|
||||
} else {
|
||||
this.bookmarkLink = this.bookUrl;
|
||||
this.bookmarkDesc = '';
|
||||
}
|
||||
|
||||
this.addBookmarkMode = mode;
|
||||
this.addBookmarkVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.bookmarkLink.focus();
|
||||
this.$refs.defaultRootLink.toggleOption = this.toggleOption;
|
||||
});
|
||||
}
|
||||
|
||||
updateBookmarkLink() {
|
||||
const index = lu.getSafeRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink);
|
||||
if (index >= 0) {
|
||||
this.bookmarkLink = rstore.libsDefaults.groups[index].s;
|
||||
this.bookmarkDesc = this.getCommentByLink(rstore.libsDefaults.groups[index].list, this.bookmarkLink);
|
||||
} else {
|
||||
this.bookmarkLink = '';
|
||||
this.bookmarkDesc = '';
|
||||
}
|
||||
}
|
||||
|
||||
defaultRootLinkInput() {
|
||||
this.updateBookmarkLink();
|
||||
}
|
||||
|
||||
bookmarkLinkKeyDown(event) {
|
||||
if (event.key == 'Enter') {
|
||||
this.$refs.bookmarkDesc.focus();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkDescKeyDown(event) {
|
||||
if (event.key == 'Enter') {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
this.okAddBookmark();
|
||||
}
|
||||
}
|
||||
|
||||
async okAddBookmark() {
|
||||
if (!this.bookmarkLink)
|
||||
return;
|
||||
|
||||
const link = (this.addBookmarkMode == 'edit' ? lu.addProtocol(this.editBookmarkLink) : lu.addProtocol(this.bookmarkLink));
|
||||
let index = -1;
|
||||
try {
|
||||
index = lu.getRootIndexByUrl(this.libs.groups, link);
|
||||
} catch (e) {
|
||||
await this.$root.stdDialog.alert('Неверный формат ссылки', 'Ошибка');
|
||||
return;
|
||||
}
|
||||
|
||||
let libs = _.cloneDeep(this.libs);
|
||||
|
||||
//добавление
|
||||
//есть группа в закладках
|
||||
if (index >= 0) {
|
||||
const item = lu.getListItemByLink(libs.groups[index].list, link);
|
||||
|
||||
//редактирование
|
||||
if (item && this.addBookmarkMode == 'edit') {
|
||||
if (item) {
|
||||
//редактируем
|
||||
item.l = link;
|
||||
item.c = this.bookmarkDesc;
|
||||
this.commitLibs(libs);
|
||||
} else {
|
||||
await this.$root.stdDialog.alert('Не удалось отредактировать закладку', 'Ошибка');
|
||||
}
|
||||
} else if (!item) {
|
||||
//добавляем
|
||||
if (libs.groups[index].list.length >= 100) {
|
||||
await this.$root.stdDialog.alert('Достигнут предел количества закладок для этого сайта', 'Ошибка');
|
||||
return;
|
||||
}
|
||||
|
||||
libs.groups[index].list.push({l: link, c: this.bookmarkDesc});
|
||||
|
||||
if (this.openInFrameOnAdd) {
|
||||
libs.startLink = link;
|
||||
libs.comment = this.bookmarkDesc;
|
||||
}
|
||||
|
||||
this.commitLibs(libs);
|
||||
} else if (item.c != this.bookmarkDesc) {
|
||||
if (await this.$root.stdDialog.confirm(`Такая закладка уже существует с другим описанием.<br>` +
|
||||
`Заменить '${this.$sanitize(item.c)}' на '${this.$sanitize(this.bookmarkDesc)}'?`, ' ')) {
|
||||
item.c = this.bookmarkDesc;
|
||||
this.commitLibs(libs);
|
||||
} else
|
||||
return;
|
||||
} else {
|
||||
await this.$root.stdDialog.alert('Такая закладка уже существует', ' ');
|
||||
return;
|
||||
}
|
||||
} else {//нет группы в закладках
|
||||
if (libs.groups.length >= 100) {
|
||||
await this.$root.stdDialog.alert('Достигнут предел количества различных сайтов в закладках', 'Ошибка');
|
||||
return;
|
||||
}
|
||||
|
||||
//добавляем сначала группу
|
||||
libs.groups.push({r: lu.getOrigin(link), s: link, list: []});
|
||||
|
||||
index = lu.getSafeRootIndexByUrl(libs.groups, link);
|
||||
if (index >= 0)
|
||||
libs.groups[index].list.push({l: link, c: this.bookmarkDesc});
|
||||
|
||||
if (this.openInFrameOnAdd) {
|
||||
libs.startLink = link;
|
||||
libs.comment = this.bookmarkDesc;
|
||||
}
|
||||
|
||||
this.commitLibs(libs);
|
||||
}
|
||||
|
||||
this.addBookmarkVisible = false;
|
||||
}
|
||||
|
||||
fullScreenToggle() {
|
||||
this.fullScreenActive = !this.fullScreenActive;
|
||||
if (this.fullScreenActive) {
|
||||
this.$q.fullscreen.request();
|
||||
} else {
|
||||
this.$q.fullscreen.exit();
|
||||
}
|
||||
}
|
||||
|
||||
transparentLayoutClick() {
|
||||
this.transparentLayoutVisible = false;
|
||||
}
|
||||
|
||||
onSelectPopupShow() {
|
||||
this.transparentLayoutVisible = true;
|
||||
}
|
||||
|
||||
onSelectPopupHide() {
|
||||
this.transparentLayoutVisible = false;
|
||||
}
|
||||
|
||||
close() {
|
||||
this.sendMessage({type: 'close'});
|
||||
}
|
||||
|
||||
bookUrlKeyDown(event) {
|
||||
if (event.key == 'Enter') {
|
||||
if (!this.openInFrameOnEnter) {
|
||||
this.submitUrl();
|
||||
} else {
|
||||
if (this.bookUrl)
|
||||
this.goToLink(this.bookUrl);
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkSettings() {
|
||||
this.bookmarkSettingsActive = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.bookmarkSettings.init();
|
||||
});
|
||||
}
|
||||
|
||||
closeBookmarkSettings() {
|
||||
this.bookmarkSettingsActive = false;
|
||||
}
|
||||
|
||||
showHelp() {
|
||||
this.$root.stdDialog.alert(`
|
||||
<p>Окно 'Библиотека' позволяет открывать ссылки в читалке без переключения между окнами,
|
||||
что особенно актуально для мобильных устройств.</p>
|
||||
|
||||
<p>'Библиотека' разрешает свободный доступ к сайту flibusta.is. Имеется возможность управлять закладками
|
||||
на понравившиеся ресурсы, книги или страницы авторов. Открытие ссылок и навигация происходят во фрейме, но,
|
||||
к сожалению, в нем открываются не все страницы.
|
||||
</p>
|
||||
|
||||
<p>Из-за проблем с безопасностью, навигация 'вперед-назад' во фрейме осуществляется с помощью контекстного меню правой кнопкой мыши.
|
||||
На мобильных устройствах для этого служит системная клавиша 'Назад (стрелка влево)' и опция 'Вперед (стрелка вправо)' в меню браузера.
|
||||
</p>
|
||||
|
||||
<p>Приятного пользования ;-)
|
||||
</p>
|
||||
`, 'Справка', {iconName: 'la la-info-circle'});
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (this.$root.rootRoute() == '/external-libs') {
|
||||
if (this.$root.stdDialog.active)
|
||||
return false;
|
||||
|
||||
if (this.bookmarkSettingsActive && this.$refs.bookmarkSettings.keyHook(event))
|
||||
return true;
|
||||
|
||||
if (this.addBookmarkVisible || this.optionsVisible)
|
||||
return false;
|
||||
|
||||
if (event.type == 'keydown' && event.key == 'F4') {
|
||||
this.addBookmark();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.type == 'keydown' && event.key == 'Escape' &&
|
||||
(document.activeElement != this.$refs.rootLink.$refs.target || !this.$refs.rootLink.menu) &&
|
||||
(document.activeElement != this.$refs.selectedLink.$refs.target || !this.$refs.selectedLink.menu)
|
||||
) {
|
||||
this.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.separator {
|
||||
height: 1px;
|
||||
background-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.full-screen-button {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.full-screen-button:hover {
|
||||
background-color: #69C05F;
|
||||
}
|
||||
|
||||
.transparent-layout {
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
48
client/components/ExternalLibs/linkUtils.js
Normal file
@@ -0,0 +1,48 @@
|
||||
export function addProtocol(url) {
|
||||
if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0))
|
||||
return 'http://' + url;
|
||||
return url;
|
||||
}
|
||||
|
||||
export function removeProtocol(url) {
|
||||
return url.replace(/(^\w+:|^)\/\//, '');
|
||||
}
|
||||
|
||||
export function getOrigin(url) {
|
||||
const parsed = new URL(url);
|
||||
return parsed.origin;
|
||||
}
|
||||
|
||||
export function removeOrigin(url) {
|
||||
const parsed = new URL(url);
|
||||
const result = url.substring(parsed.origin.length);
|
||||
return (result ? result : '/');
|
||||
}
|
||||
|
||||
export function getRootIndexByUrl(groups, url) {
|
||||
const origin = getOrigin(url);
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
if (groups[i].r == origin)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function getSafeRootIndexByUrl(groups, url) {
|
||||
let index = -1;
|
||||
try {
|
||||
index = getRootIndexByUrl(groups, url);
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
export function getListItemByLink(list, link) {
|
||||
for (const item of list) {
|
||||
if (item.l == link)
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
242
client/components/Reader/ContentsPage/ContentsPage.vue
Normal file
@@ -0,0 +1,242 @@
|
||||
<template>
|
||||
<Window width="600px" ref="window" @close="close">
|
||||
<template slot="header">
|
||||
Оглавление/закладки
|
||||
</template>
|
||||
|
||||
<div class="bg-grey-3 row">
|
||||
<q-tabs
|
||||
v-model="selectedTab"
|
||||
active-color="black"
|
||||
active-bg-color="white"
|
||||
indicator-color="white"
|
||||
dense
|
||||
no-caps
|
||||
inline-label
|
||||
class="no-mp bg-grey-4 text-grey-7"
|
||||
>
|
||||
<q-tab name="contents" icon="la la-list" label="Оглавление" />
|
||||
<q-tab name="bookmarks" icon="la la-bookmark" label="Закладки" />
|
||||
</q-tabs>
|
||||
</div>
|
||||
|
||||
<div class="q-mb-sm"/>
|
||||
|
||||
<div class="tab-panel" v-show="selectedTab == 'contents'">
|
||||
<div>
|
||||
<div v-for="item in contents" :key="item.key" class="column" style="width: 540px">
|
||||
<div class="row item q-px-sm no-wrap">
|
||||
<div v-if="item.list.length" class="row justify-center items-center expand-button clickable" @click="expandClick(item.key)">
|
||||
<q-icon name="la la-arrow-circle-down" class="icon" :class="{'expanded-icon': item.expanded}" color="green-8" size="24px"/>
|
||||
</div>
|
||||
<div v-else class="no-expand-button clickable" @click="setBookPos(item.offset)">
|
||||
</div>
|
||||
<div class="col row clickable" @click="setBookPos(item.offset)">
|
||||
<div :style="item.indentStyle"></div>
|
||||
<div class="q-mr-sm col overflow-hidden column justify-center" v-html="item.label"></div>
|
||||
<div class="column justify-center">{{ item.perc }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="item.expanded" :ref="`subitem${item.key}`" class="subitems-transition">
|
||||
<div v-for="subitem in item.list" :key="subitem.key" class="row subitem q-px-sm no-wrap">
|
||||
<div class="col row clickable" @click="setBookPos(subitem.offset)">
|
||||
<div class="no-expand-button"></div>
|
||||
<div :style="subitem.indentStyle"></div>
|
||||
<div class="q-mr-sm col overflow-hidden column justify-center" v-html="subitem.label"></div>
|
||||
<div class="column justify-center">{{ subitem.perc }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-panel" v-show="selectedTab == 'bookmarks'">
|
||||
<div class="column justify-center items-center" style="height: 100px">
|
||||
Раздел находится в разработке
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</Window>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
//import _ from 'lodash';
|
||||
|
||||
import Window from '../../share/Window.vue';
|
||||
import * as utils from '../../../share/utils';
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
Window,
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
})
|
||||
class ContentsPage extends Vue {
|
||||
selectedTab = 'contents';
|
||||
contents = [];
|
||||
|
||||
created() {
|
||||
}
|
||||
|
||||
async init(currentBook, parsed) {
|
||||
this.$refs.window.init();
|
||||
|
||||
//закладки
|
||||
|
||||
//далее формаирование оглавления
|
||||
if (this.parsed == parsed)
|
||||
return;
|
||||
|
||||
this.parsed = parsed;
|
||||
this.contents = [];
|
||||
await this.$nextTick();
|
||||
|
||||
const prepareLabel = (title, bolder = false) => {
|
||||
let titleParts = title.split('<p>');
|
||||
const textParts = titleParts.filter(v => v).map(v => `<div>${v.replace(/(<([^>]+)>)/ig, '')}</div>`);
|
||||
if (bolder && textParts.length > 1)
|
||||
textParts[0] = `<b>${textParts[0]}</b>`;
|
||||
return textParts.join('');
|
||||
}
|
||||
|
||||
const insetStyle = inset => `width: ${inset*20}px`;
|
||||
const pc = parsed.contents;
|
||||
const newpc = [];
|
||||
|
||||
//преобразуем не первые разделы body в title-subtitle
|
||||
let curSubtitles = [];
|
||||
let prevBodyIndex = -1;
|
||||
for (let i = 0; i < pc.length; i++) {
|
||||
const cont = pc[i];
|
||||
if (prevBodyIndex != cont.bodyIndex)
|
||||
curSubtitles = [];
|
||||
|
||||
prevBodyIndex = cont.bodyIndex;
|
||||
|
||||
if (cont.bodyIndex > 1) {
|
||||
if (cont.inset < 1) {
|
||||
newpc.push(Object.assign({}, cont, {subtitles: curSubtitles}));
|
||||
} else {
|
||||
curSubtitles.push(Object.assign({}, cont, {inset: cont.inset - 1}));
|
||||
}
|
||||
} else {
|
||||
newpc.push(cont);
|
||||
}
|
||||
}
|
||||
|
||||
//формируем newContents
|
||||
let i = 0;
|
||||
const newContents = [];
|
||||
newpc.forEach((cont) => {
|
||||
const label = prepareLabel(cont.title, true);
|
||||
const indentStyle = insetStyle(cont.inset);
|
||||
|
||||
let j = 0;
|
||||
const list = [];
|
||||
cont.subtitles.forEach((sub) => {
|
||||
const l = prepareLabel(sub.title);
|
||||
const s = insetStyle(sub.inset + 1);
|
||||
const p = parsed.para[sub.paraIndex];
|
||||
list[j] = {perc: (p.offset/parsed.textLength*100).toFixed(2), label: l, key: j, offset: p.offset, indentStyle: s};
|
||||
j++;
|
||||
});
|
||||
|
||||
const p = parsed.para[cont.paraIndex];
|
||||
newContents[i] = {perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset, indentStyle, expanded: false, list};
|
||||
|
||||
i++;
|
||||
});
|
||||
|
||||
this.contents = newContents;
|
||||
}
|
||||
|
||||
async expandClick(key) {
|
||||
const item = this.contents[key];
|
||||
const expanded = !item.expanded;
|
||||
|
||||
if (!expanded) {
|
||||
const subitems = this.$refs[`subitem${key}`][0];
|
||||
subitems.style.height = '0';
|
||||
await utils.sleep(200);
|
||||
}
|
||||
|
||||
this.$set(this.contents, key, Object.assign({}, item, {expanded}));
|
||||
|
||||
if (expanded) {
|
||||
await this.$nextTick();
|
||||
const subitems = this.$refs[`subitem${key}`][0];
|
||||
subitems.style.height = subitems.scrollHeight + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
async setBookPos(newValue) {
|
||||
this.$emit('book-pos-changed', {bookPos: newValue});
|
||||
await this.$nextTick();
|
||||
this.close();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.$emit('do-action', {action: 'contents'});
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (!this.$root.stdDialog.active && event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tab-panel {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
font-size: 90%;
|
||||
padding: 0 10px 0px 10px;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.item, .subitem {
|
||||
height: 40px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.item:hover, .subitem:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.expand-button, .no-expand-button {
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.expand-button:hover {
|
||||
background-color: white;
|
||||
border-radius: 15px;
|
||||
border: 1px solid #d0d0d0;
|
||||
}
|
||||
|
||||
.subitems-transition {
|
||||
height: 0;
|
||||
transition: height 0.2s linear;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.icon {
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.expanded-icon {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
</style>
|
||||
@@ -95,7 +95,7 @@ class CopyTextPage extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (event.type == 'keydown' && (event.code == 'Escape')) {
|
||||
if (event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
на файл из онлайн-библиотеки (например, скопировав адрес ссылки или кнопки "скачать fb2").</p>
|
||||
<p>Поддерживаемые форматы: <b>fb2, fb2.zip, html, txt</b> и другие.</p>
|
||||
|
||||
<div v-show="mode == 'omnireader'">
|
||||
<div v-show="mode == 'omnireader' || mode == 'liberama.top'">
|
||||
<p>Вы можете добавить в свой браузер закладку, указав в ее свойствах вместо адреса следующий код:
|
||||
<br><strong>javascript:location.href='https://omnireader.ru/?url='+location.href;</strong>
|
||||
<q-icon class="copy-icon" name="la la-copy" @click="copyText('javascript:location.href=\'https://omnireader.ru/?url=\'+location.href;', 'Код для адреса закладки успешно скопирован в буфер обмена')">
|
||||
<br><strong>{{ bookmarkText }}</strong>
|
||||
<q-icon class="copy-icon" name="la la-copy" @click="copyText(bookmarkText, 'Код для адреса закладки успешно скопирован в буфер обмена')">
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="center middle" content-style="font-size: 80%">Скопировать</q-tooltip>
|
||||
</q-icon>
|
||||
|
||||
<br>или перетащив на панель закладок следующую ссылку:
|
||||
<br><a style="margin-left: 50px" href="javascript:location.href='https://omnireader.ru/?url='+location.href;">Omni Reader</a>
|
||||
<br><a style="margin-left: 50px" :href="bookmarkText">{{ (mode == 'omnireader' ? 'Omni' : 'Liberama') }} Reader</a>
|
||||
<br>Тогда, активировав получившуюся закладку на любой странице интернета, вы автоматически загрузите эту страницу в Omni Reader.
|
||||
<br>В Chrome для Android можно вызывать такую закладку по имени прямо в адресной строке браузера (имя стоит сделать попроще).
|
||||
</p>
|
||||
@@ -56,6 +56,10 @@ class CommonHelpPage extends Vue {
|
||||
return this.$store.state.config.mode;
|
||||
}
|
||||
|
||||
get bookmarkText() {
|
||||
return `javascript:location.href='https://${window.location.host}/?url='+location.href;`
|
||||
}
|
||||
|
||||
async copyText(text, mes) {
|
||||
const result = await copyTextToClipboard(text);
|
||||
const msg = (result ? mes : 'Копирование не удалось');
|
||||
|
||||
@@ -81,7 +81,7 @@ class HelpPage extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (event.type == 'keydown' && (event.code == 'Escape')) {
|
||||
if (event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
131
client/components/Reader/LibsPage/LibsPage.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div class="hidden"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
|
||||
import Window from '../../share/Window.vue';
|
||||
import * as utils from '../../../share/utils';
|
||||
//import rstore from '../../../store/modules/reader';
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
Window
|
||||
},
|
||||
watch: {
|
||||
libs: function() {
|
||||
this.sendLibs();
|
||||
},
|
||||
}
|
||||
})
|
||||
class LibsPage extends Vue {
|
||||
created() {
|
||||
this.popupWindow = null;
|
||||
this.commit = this.$store.commit;
|
||||
this.messageListener = null;
|
||||
//this.commit('reader/setLibs', rstore.libsDefaults);
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.mode != 'liberama.top')
|
||||
return;
|
||||
|
||||
this.childReady = false;
|
||||
const subdomain = (window.location.protocol != 'http:' ? 'b.' : '');
|
||||
this.origin = `http://${subdomain}${window.location.host}`;
|
||||
|
||||
this.messageListener = (event) => {
|
||||
if (event.origin !== this.origin)
|
||||
return;
|
||||
|
||||
//console.log(event.data);
|
||||
|
||||
this.recvMessage(event.data);
|
||||
};
|
||||
|
||||
this.popupWindow = window.open(`${this.origin}/#/external-libs`);
|
||||
|
||||
if (this.popupWindow) {
|
||||
|
||||
window.addEventListener('message', this.messageListener);
|
||||
|
||||
//Проверка закрытия окна
|
||||
(async() => {
|
||||
while(this.popupWindow) {
|
||||
if (this.popupWindow && this.popupWindow.closed)
|
||||
this.close();
|
||||
await utils.sleep(1000);
|
||||
}
|
||||
})();
|
||||
|
||||
//Установление связи с окном
|
||||
(async() => {
|
||||
let i = 0;
|
||||
while(!this.childReady && this.popupWindow && i < 100) {
|
||||
this.sendMessage({type: 'mes', data: 'hello'});
|
||||
await utils.sleep(100);
|
||||
i++;
|
||||
}
|
||||
this.sendLibs();
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
recvMessage(d) {
|
||||
if (d.type == 'mes') {
|
||||
switch(d.data) {
|
||||
case 'ready':
|
||||
this.childReady = true;
|
||||
break;
|
||||
}
|
||||
} else if (d.type == 'libs') {
|
||||
this.commit('reader/setLibs', d.data);
|
||||
} else if (d.type == 'close') {
|
||||
this.close();
|
||||
} else if (d.type == 'submitUrl') {
|
||||
this.$emit('load-book', d.data);
|
||||
this.sendMessage({type: 'notify', data: 'Ссылка передана в читалку'});
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(d) {
|
||||
if (this.popupWindow)
|
||||
this.popupWindow.postMessage(Object.assign({}, {from: 'LibsPage'}, d), this.origin);
|
||||
}
|
||||
|
||||
done() {
|
||||
window.removeEventListener('message', this.messageListener);
|
||||
if (this.popupWindow) {
|
||||
this.popupWindow.close();
|
||||
this.popupWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
get mode() {
|
||||
return this.$store.state.config.mode;
|
||||
}
|
||||
|
||||
get libs() {
|
||||
return this.$store.state.reader.libs;
|
||||
}
|
||||
|
||||
sendLibs() {
|
||||
this.sendMessage({type: 'libs', data: this.libs});
|
||||
}
|
||||
|
||||
close() {
|
||||
this.$emit('libs-close');
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.separator {
|
||||
height: 1px;
|
||||
background-color: #A0A0A0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div ref="main" class="column no-wrap" style="min-height: 500px">
|
||||
<div class="relative-position">
|
||||
<div v-if="mode != 'liberama.top'" class="relative-position">
|
||||
<GithubCorner url="https://github.com/bookpauk/liberama" cornerColor="#1B695F" gitColor="#EBE2C9"></GithubCorner>
|
||||
</div>
|
||||
<div class="col column justify-center items-center no-wrap overflow-hidden" style="min-height: 230px">
|
||||
@@ -31,7 +31,7 @@
|
||||
</q-btn>
|
||||
|
||||
<div class="q-my-md"></div>
|
||||
<div v-if="mode == 'omnireader'">
|
||||
<!--div v-if="mode == 'omnireader'">
|
||||
<div ref="yaShare2" class="ya-share2"
|
||||
data-services="collections,vkontakte,facebook,odnoklassniki,twitter,telegram"
|
||||
data-description="Чтение fb2-книг онлайн. Загрузка любой страницы интернета одним кликом, синхронизация между устройствами, удобное управление, регистрация не требуется."
|
||||
@@ -39,7 +39,7 @@
|
||||
data-url="https://omnireader.ru">
|
||||
</div>
|
||||
</div>
|
||||
<div class="q-my-sm"></div>
|
||||
<div class="q-my-sm"></div-->
|
||||
<span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Отзывы о читалке</span>
|
||||
<span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openOldVersion">Старая версия</span>
|
||||
</div>
|
||||
@@ -82,8 +82,8 @@ class LoaderPage extends Vue {
|
||||
|
||||
mounted() {
|
||||
this.progress = this.$refs.progress;
|
||||
if (this.mode == 'omnireader')
|
||||
Ya.share2(this.$refs.yaShare2);// eslint-disable-line no-undef
|
||||
/*if (this.mode == 'omnireader')
|
||||
Ya.share2(this.$refs.yaShare2);// eslint-disable-line no-undef*/
|
||||
}
|
||||
|
||||
activated() {
|
||||
@@ -93,6 +93,8 @@ class LoaderPage extends Vue {
|
||||
get title() {
|
||||
if (this.mode == 'omnireader')
|
||||
return 'Omni Reader - браузерная онлайн-читалка.';
|
||||
if (this.mode == 'liberama.top')
|
||||
return 'Liberama Reader - браузерная онлайн-читалка.';
|
||||
return 'Универсальная читалка книг и ресурсов интернета.';
|
||||
|
||||
}
|
||||
@@ -171,7 +173,7 @@ class LoaderPage extends Vue {
|
||||
|
||||
//недостатки сторонних ui
|
||||
const input = this.$refs.input.$refs.input;
|
||||
if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
|
||||
if (document.activeElement === input && event.type == 'keydown' && event.key == 'Enter') {
|
||||
this.submitUrl();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class PasteTextPage extends Vue {
|
||||
|
||||
keyHook(event) {
|
||||
if (event.type == 'keydown') {
|
||||
switch (event.code) {
|
||||
switch (event.key) {
|
||||
case 'F2':
|
||||
this.loadBuffer();
|
||||
break;
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
<div class="column no-wrap">
|
||||
<div ref="header" class="header" v-show="toolBarActive">
|
||||
<div ref="buttons" class="row justify-between no-wrap">
|
||||
<button ref="loader" class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')" v-ripple>
|
||||
<q-icon name="la la-arrow-left" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">{{ rstore.readerActions['loader'] }}</q-tooltip>
|
||||
</button>
|
||||
<div>
|
||||
<button ref="loader" class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')" v-ripple>
|
||||
<q-icon name="la la-arrow-left" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">{{ rstore.readerActions['loader'] }}</q-tooltip>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button ref="undoAction" v-show="showToolButton['undoAction']" class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')" v-ripple>
|
||||
@@ -37,14 +39,22 @@
|
||||
<q-icon name="la la-copy" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['copyText'] }}</q-tooltip>
|
||||
</button>
|
||||
<button ref="splitToPara" v-show="showToolButton['splitToPara']" class="tool-button" :class="buttonActiveClass('splitToPara')" @click="buttonClick('splitToPara')" v-ripple>
|
||||
<q-icon name="la la-retweet" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['splitToPara'] }}</q-tooltip>
|
||||
</button>
|
||||
<button ref="refresh" v-show="showToolButton['refresh']" class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')" v-ripple>
|
||||
<q-icon name="la la-sync" size="32px" :class="{clear: !showRefreshIcon}"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['refresh'] }}</q-tooltip>
|
||||
</button>
|
||||
<div class="space"></div>
|
||||
<button ref="offlineMode" v-show="showToolButton['offlineMode']" class="tool-button" :class="buttonActiveClass('offlineMode')" @click="buttonClick('offlineMode')" v-ripple>
|
||||
<q-icon name="la la-unlink" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['offlineMode'] }}</q-tooltip>
|
||||
<button ref="contents" v-show="showToolButton['contents']" class="tool-button" :class="buttonActiveClass('contents')" @click="buttonClick('contents')" v-ripple>
|
||||
<q-icon name="la la-list" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['contents'] }}</q-tooltip>
|
||||
</button>
|
||||
<button ref="libs" v-show="mode == 'liberama.top' && showToolButton['libs']" class="tool-button" :class="buttonActiveClass('libs')" @click="buttonClick('libs')" v-ripple>
|
||||
<q-icon name="la la-sitemap" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['libs'] }}</q-tooltip>
|
||||
</button>
|
||||
<button ref="recentBooks" v-show="showToolButton['recentBooks']" class="tool-button" :class="buttonActiveClass('recentBooks')" @click="buttonClick('recentBooks')" v-ripple>
|
||||
<q-icon name="la la-book-open" size="32px"/>
|
||||
@@ -52,10 +62,16 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button ref="settings" class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')" v-ripple>
|
||||
<q-icon name="la la-cog" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom left" content-style="font-size: 80%">{{ rstore.readerActions['settings'] }}</q-tooltip>
|
||||
</button>
|
||||
<div>
|
||||
<button ref="offlineMode" v-show="showToolButton['offlineMode']" class="tool-button" :class="buttonActiveClass('offlineMode')" @click="buttonClick('offlineMode')" v-ripple>
|
||||
<q-icon name="la la-unlink" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">{{ rstore.readerActions['offlineMode'] }}</q-tooltip>
|
||||
</button>
|
||||
<button ref="settings" class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')" v-ripple>
|
||||
<q-icon name="la la-cog" size="32px"/>
|
||||
<q-tooltip :delay="1500" anchor="bottom left" content-style="font-size: 80%">{{ rstore.readerActions['settings'] }}</q-tooltip>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -77,70 +93,15 @@
|
||||
@stop-text-search="stopTextSearch">
|
||||
</SearchPage>
|
||||
<CopyTextPage v-if="copyTextActive" ref="copyTextPage" @do-action="doAction"></CopyTextPage>
|
||||
<LibsPage v-show="hidden" ref="libsPage" @load-book="loadBook" @libs-close="libsClose" @do-action="doAction"></LibsPage>
|
||||
<RecentBooksPage v-show="recentBooksActive" ref="recentBooksPage" @load-book="loadBook" @recent-books-close="recentBooksClose"></RecentBooksPage>
|
||||
<SettingsPage v-show="settingsActive" ref="settingsPage" @do-action="doAction"></SettingsPage>
|
||||
<HelpPage v-if="helpActive" ref="helpPage" @do-action="doAction"></HelpPage>
|
||||
<ClickMapPage v-show="clickMapActive" ref="clickMapPage"></ClickMapPage>
|
||||
<ServerStorage v-show="hidden" ref="serverStorage"></ServerStorage>
|
||||
<ContentsPage v-show="contentsActive" ref="contentsPage" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage>
|
||||
|
||||
<Dialog ref="dialog1" v-model="whatsNewVisible">
|
||||
<template slot="header">
|
||||
Что нового:
|
||||
</template>
|
||||
|
||||
<div style="line-height: 20px" v-html="whatsNewContent"></div>
|
||||
|
||||
<span class="clickable" @click="openVersionHistory">Посмотреть историю версий</span>
|
||||
<span slot="footer">
|
||||
<q-btn class="q-px-md" dense no-caps @click="whatsNewDisable">Больше не показывать</q-btn>
|
||||
</span>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref="dialog2" v-model="donationVisible">
|
||||
<template slot="header">
|
||||
Здравствуйте, уважаемые читатели!
|
||||
</template>
|
||||
|
||||
<div style="word-break: normal">
|
||||
Стартовала ежегодная акция "Оплатим хостинг вместе".<br><br>
|
||||
|
||||
Для оплаты годового хостинга читалки, необходимо собрать около 2000 рублей.
|
||||
В настоящий момент у автора эта сумма есть в наличии. Однако будет справедливо, если каждый
|
||||
сможет проголосовать рублем за то, чтобы читалка так и оставалась:
|
||||
|
||||
<ul>
|
||||
<li>непрерывно улучшаемой</li>
|
||||
<li>без рекламы</li>
|
||||
<li>без регистрации</li>
|
||||
<li>Open Source</li>
|
||||
</ul>
|
||||
|
||||
Автор также обращается с просьбой о помощи в распространении
|
||||
<a href="https://omnireader.ru" target="_blank">ссылки</a>
|
||||
<q-icon class="copy-icon" name="la la-copy" @click="copyLink('https://omnireader.ru')">
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="center middle" content-style="font-size: 80%">Скопировать</q-tooltip>
|
||||
</q-icon>
|
||||
на читалку через тематические форумы, соцсети, мессенджеры и пр.
|
||||
Чем нас больше, тем легче оставаться на плаву и тем больше мотивации у разработчика, чтобы продолжать работать над проектом.
|
||||
|
||||
<br><br>
|
||||
Если соберется бóльшая сумма, то разработка децентрализованной библиотеки для свободного обмена книгами будет по возможности ускорена.
|
||||
<br><br>
|
||||
P.S. При необходимости можно воспользоваться подходящим обменником на <a href="https://www.bestchange.ru" target="_blank">bestchange.ru</a>
|
||||
|
||||
<br><br>
|
||||
<div class="row justify-center">
|
||||
<q-btn class="q-px-sm" color="primary" dense no-caps rounded @click="openDonate">Помочь проекту</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span slot="footer">
|
||||
<span class="clickable row justify-end" style="font-size: 60%; color: grey" @click="donationDialogDisable">Больше не показывать</span>
|
||||
<br>
|
||||
<q-btn class="q-px-sm" dense no-caps @click="donationDialogRemind">Напомнить позже</q-btn>
|
||||
</span>
|
||||
</Dialog>
|
||||
|
||||
<ReaderDialogs ref="dialogs" @donate-toggle="donateToggle" @version-history-toggle="versionHistoryToggle"></ReaderDialogs>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -159,18 +120,20 @@ import ProgressPage from './ProgressPage/ProgressPage.vue';
|
||||
import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
|
||||
import SearchPage from './SearchPage/SearchPage.vue';
|
||||
import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
|
||||
import LibsPage from './LibsPage/LibsPage.vue';
|
||||
import RecentBooksPage from './RecentBooksPage/RecentBooksPage.vue';
|
||||
import SettingsPage from './SettingsPage/SettingsPage.vue';
|
||||
import HelpPage from './HelpPage/HelpPage.vue';
|
||||
import ClickMapPage from './ClickMapPage/ClickMapPage.vue';
|
||||
import ServerStorage from './ServerStorage/ServerStorage.vue';
|
||||
import Dialog from '../share/Dialog.vue';
|
||||
import ContentsPage from './ContentsPage/ContentsPage.vue';
|
||||
|
||||
import ReaderDialogs from './ReaderDialogs/ReaderDialogs.vue';
|
||||
|
||||
import bookManager from './share/bookManager';
|
||||
import rstore from '../../store/modules/reader';
|
||||
import readerApi from '../../api/reader';
|
||||
import * as utils from '../../share/utils';
|
||||
import {versionHistory} from './versionHistory';
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
@@ -181,12 +144,15 @@ export default @Component({
|
||||
SetPositionPage,
|
||||
SearchPage,
|
||||
CopyTextPage,
|
||||
LibsPage,
|
||||
RecentBooksPage,
|
||||
SettingsPage,
|
||||
HelpPage,
|
||||
ClickMapPage,
|
||||
ServerStorage,
|
||||
Dialog,
|
||||
ContentsPage,
|
||||
|
||||
ReaderDialogs,
|
||||
},
|
||||
watch: {
|
||||
bookPos: function(newValue) {
|
||||
@@ -230,6 +196,7 @@ export default @Component({
|
||||
class Reader extends Vue {
|
||||
rstore = {};
|
||||
loaderActive = false;
|
||||
offlineModeActive = false;
|
||||
progressActive = false;
|
||||
fullScreenActive = false;
|
||||
|
||||
@@ -237,11 +204,12 @@ class Reader extends Vue {
|
||||
setPositionActive = false;
|
||||
searchActive = false;
|
||||
copyTextActive = false;
|
||||
libsActive = false;
|
||||
recentBooksActive = false;
|
||||
offlineModeActive = false;
|
||||
settingsActive = false;
|
||||
helpActive = false;
|
||||
clickMapActive = false;
|
||||
contentsActive = false;
|
||||
|
||||
bookPos = null;
|
||||
allowUrlParamBookPos = false;
|
||||
@@ -315,10 +283,15 @@ class Reader extends Vue {
|
||||
this.checkActivateDonateHelpPage();
|
||||
this.loading = false;
|
||||
|
||||
//проверим состояние Settings, и обновим, если надо
|
||||
const newSettings = rstore.addDefaultsToSettings(this.settings);
|
||||
if (newSettings) {
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
}
|
||||
|
||||
this.updateRoute();
|
||||
|
||||
await this.showWhatsNew();
|
||||
await this.showDonation();
|
||||
await this.$refs.dialogs.init();
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -329,8 +302,6 @@ class Reader extends Vue {
|
||||
this.showClickMapPage = settings.showClickMapPage;
|
||||
this.clickControl = settings.clickControl;
|
||||
this.blinkCachedLoad = settings.blinkCachedLoad;
|
||||
this.showWhatsNewDialog = settings.showWhatsNewDialog;
|
||||
this.showDonationDialog2020 = settings.showDonationDialog2020;
|
||||
this.showToolButton = settings.showToolButton;
|
||||
this.enableSitesFilter = settings.enableSitesFilter;
|
||||
|
||||
@@ -394,64 +365,6 @@ class Reader extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async showWhatsNew() {
|
||||
await utils.sleep(2000);
|
||||
|
||||
const whatsNew = versionHistory[0];
|
||||
if (this.showWhatsNewDialog &&
|
||||
whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
|
||||
whatsNew.header != this.whatsNewContentHash) {
|
||||
this.whatsNewContent = 'Версия ' + whatsNew.header + whatsNew.content;
|
||||
this.whatsNewVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
async showDonation() {
|
||||
await utils.sleep(3000);
|
||||
const today = utils.formatDate(new Date(), 'coDate');
|
||||
|
||||
if (this.mode == 'omnireader' && today < '2020-03-01' && this.showDonationDialog2020 && this.donationRemindDate != today) {
|
||||
this.donationVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
donationDialogDisable() {
|
||||
this.donationVisible = false;
|
||||
if (this.showDonationDialog2020) {
|
||||
const newSettings = Object.assign({}, this.settings, { showDonationDialog2020: false });
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
}
|
||||
}
|
||||
|
||||
donationDialogRemind() {
|
||||
this.donationVisible = false;
|
||||
this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coDate'));
|
||||
}
|
||||
|
||||
openDonate() {
|
||||
this.donationVisible = false;
|
||||
this.donateToggle();
|
||||
}
|
||||
|
||||
async copyLink(link) {
|
||||
const result = await utils.copyTextToClipboard(link);
|
||||
if (result)
|
||||
this.$root.notify.success(`Ссылка ${link} успешно скопирована в буфер обмена`);
|
||||
else
|
||||
this.$root.notify.error('Копирование не удалось');
|
||||
}
|
||||
|
||||
openVersionHistory() {
|
||||
this.whatsNewVisible = false;
|
||||
this.versionHistoryToggle();
|
||||
}
|
||||
|
||||
whatsNewDisable() {
|
||||
this.whatsNewVisible = false;
|
||||
const whatsNew = versionHistory[0];
|
||||
this.commit('reader/setWhatsNewContentHash', whatsNew.header);
|
||||
}
|
||||
|
||||
get routeParamPos() {
|
||||
let result = undefined;
|
||||
const q = this.$route.query;
|
||||
@@ -555,14 +468,6 @@ class Reader extends Vue {
|
||||
return this.$store.state.reader.settings;
|
||||
}
|
||||
|
||||
get whatsNewContentHash() {
|
||||
return this.$store.state.reader.whatsNewContentHash;
|
||||
}
|
||||
|
||||
get donationRemindDate() {
|
||||
return this.$store.state.reader.donationRemindDate;
|
||||
}
|
||||
|
||||
addAction(pos) {
|
||||
let a = this.actionList;
|
||||
if (!a.length || a[a.length - 1] != pos) {
|
||||
@@ -587,7 +492,7 @@ class Reader extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
closeAllTextPages() {
|
||||
closeAllWindows() {
|
||||
this.setPositionActive = false;
|
||||
this.copyTextActive = false;
|
||||
this.recentBooksActive = false;
|
||||
@@ -595,12 +500,13 @@ class Reader extends Vue {
|
||||
this.stopScrolling();
|
||||
this.stopSearch();
|
||||
this.helpActive = false;
|
||||
this.contentsActive = false;
|
||||
}
|
||||
|
||||
loaderToggle() {
|
||||
this.loaderActive = !this.loaderActive;
|
||||
if (this.loaderActive) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,7 +514,7 @@ class Reader extends Vue {
|
||||
this.setPositionActive = !this.setPositionActive;
|
||||
const page = this.$refs.page;
|
||||
if (this.setPositionActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.setPositionActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -660,7 +566,7 @@ class Reader extends Vue {
|
||||
this.searchActive = !this.searchActive;
|
||||
const page = this.$refs.page;
|
||||
if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.searchActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -676,7 +582,7 @@ class Reader extends Vue {
|
||||
this.copyTextActive = !this.copyTextActive;
|
||||
const page = this.$refs.page;
|
||||
if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.copyTextActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -687,6 +593,12 @@ class Reader extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
refreshBookSplitToPara() {
|
||||
if (this.mostRecentBook()) {
|
||||
this.loadBook({url: this.mostRecentBook().url, skipCheck: true, isText: true, force: true});
|
||||
}
|
||||
}
|
||||
|
||||
recentBooksClose() {
|
||||
this.recentBooksActive = false;
|
||||
}
|
||||
@@ -694,7 +606,7 @@ class Reader extends Vue {
|
||||
recentBooksToggle() {
|
||||
this.recentBooksActive = !this.recentBooksActive;
|
||||
if (this.recentBooksActive) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.$refs.recentBooksPage.init();
|
||||
this.recentBooksActive = true;
|
||||
} else {
|
||||
@@ -702,6 +614,35 @@ class Reader extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
contentsPageToggle() {
|
||||
this.contentsActive = !this.contentsActive;
|
||||
const page = this.$refs.page;
|
||||
if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
this.closeAllWindows();
|
||||
this.contentsActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
|
||||
});
|
||||
} else {
|
||||
this.contentsActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
libsClose() {
|
||||
if (this.libsActive)
|
||||
this.libsToogle();
|
||||
}
|
||||
|
||||
libsToogle() {
|
||||
this.libsActive = !this.libsActive;
|
||||
if (this.libsActive) {
|
||||
this.$refs.libsPage.init();
|
||||
} else {
|
||||
this.$refs.libsPage.done();
|
||||
}
|
||||
}
|
||||
|
||||
offlineModeToggle() {
|
||||
this.offlineModeActive = !this.offlineModeActive;
|
||||
this.$refs.serverStorage.offlineModeActive = this.offlineModeActive;
|
||||
@@ -710,7 +651,7 @@ class Reader extends Vue {
|
||||
settingsToggle() {
|
||||
this.settingsActive = !this.settingsActive;
|
||||
if (this.settingsActive) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.settingsActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -724,7 +665,7 @@ class Reader extends Vue {
|
||||
helpToggle() {
|
||||
this.helpActive = !this.helpActive;
|
||||
if (this.helpActive) {
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
this.helpActive = true;
|
||||
}
|
||||
}
|
||||
@@ -790,9 +731,12 @@ class Reader extends Vue {
|
||||
case 'scrolling':
|
||||
case 'search':
|
||||
case 'copyText':
|
||||
case 'splitToPara':
|
||||
case 'refresh':
|
||||
case 'offlineMode':
|
||||
case 'contents':
|
||||
case 'libs':
|
||||
case 'recentBooks':
|
||||
case 'offlineMode':
|
||||
case 'settings':
|
||||
if (this.progressActive) {
|
||||
classResult = classDisabled;
|
||||
@@ -818,10 +762,12 @@ class Reader extends Vue {
|
||||
case 'scrolling':
|
||||
case 'search':
|
||||
case 'copyText':
|
||||
case 'contents':
|
||||
classResult = classDisabled;
|
||||
break;
|
||||
case 'recentBooks':
|
||||
case 'splitToPara':
|
||||
case 'refresh':
|
||||
case 'recentBooks':
|
||||
if (!this.mostRecentBookReactive)
|
||||
classResult = classDisabled;
|
||||
break;
|
||||
@@ -896,7 +842,7 @@ class Reader extends Vue {
|
||||
return;
|
||||
}
|
||||
|
||||
this.closeAllTextPages();
|
||||
this.closeAllWindows();
|
||||
|
||||
let url = encodeURI(decodeURI(opts.url));
|
||||
|
||||
@@ -974,9 +920,16 @@ class Reader extends Vue {
|
||||
// не удалось, скачиваем книгу полностью с конвертацией
|
||||
let loadCached = true;
|
||||
if (!book) {
|
||||
book = await readerApi.loadBook({url, enableSitesFilter: this.enableSitesFilter}, (state) => {
|
||||
progress.setState(state);
|
||||
});
|
||||
book = await readerApi.loadBook({
|
||||
url,
|
||||
skipCheck: (opts.skipCheck ? true : false),
|
||||
isText: (opts.isText ? true : false),
|
||||
enableSitesFilter: this.enableSitesFilter
|
||||
},
|
||||
(state) => {
|
||||
progress.setState(state);
|
||||
}
|
||||
);
|
||||
loadCached = false;
|
||||
}
|
||||
|
||||
@@ -1071,9 +1024,6 @@ class Reader extends Vue {
|
||||
case 'help':
|
||||
this.helpToggle();
|
||||
break;
|
||||
case 'settings':
|
||||
this.settingsToggle();
|
||||
break;
|
||||
case 'undoAction':
|
||||
this.undoAction();
|
||||
break;
|
||||
@@ -1098,14 +1048,26 @@ class Reader extends Vue {
|
||||
case 'copyText':
|
||||
this.copyTextToggle();
|
||||
break;
|
||||
case 'splitToPara':
|
||||
this.refreshBookSplitToPara();
|
||||
break;
|
||||
case 'refresh':
|
||||
this.refreshBook();
|
||||
break;
|
||||
case 'contents':
|
||||
this.contentsPageToggle();
|
||||
break;
|
||||
case 'libs':
|
||||
this.libsToogle();
|
||||
break;
|
||||
case 'recentBooks':
|
||||
this.recentBooksToggle();
|
||||
break;
|
||||
case 'offlineMode':
|
||||
this.offlineModeToggle();
|
||||
break;
|
||||
case 'recentBooks':
|
||||
this.recentBooksToggle();
|
||||
case 'settings':
|
||||
this.settingsToggle();
|
||||
break;
|
||||
case 'switchToolbar':
|
||||
this.toolBarToggle();
|
||||
@@ -1170,32 +1132,37 @@ class Reader extends Vue {
|
||||
keyHook(event) {
|
||||
let result = false;
|
||||
if (this.$root.rootRoute() == '/reader') {
|
||||
if (this.$root.stdDialog.active || this.$refs.dialog1.active || this.$refs.dialog2.active)
|
||||
if (this.$root.stdDialog.active)
|
||||
return result;
|
||||
|
||||
let handled = false;
|
||||
if (!handled && this.helpActive)
|
||||
handled = this.$refs.helpPage.keyHook(event);
|
||||
if (!result)
|
||||
result = this.$refs.dialogs.keyHook(event);
|
||||
|
||||
if (!handled && this.settingsActive)
|
||||
handled = this.$refs.settingsPage.keyHook(event);
|
||||
if (!result && this.helpActive)
|
||||
result = this.$refs.helpPage.keyHook(event);
|
||||
|
||||
if (!handled && this.recentBooksActive)
|
||||
handled = this.$refs.recentBooksPage.keyHook(event);
|
||||
if (!result && this.settingsActive)
|
||||
result = this.$refs.settingsPage.keyHook(event);
|
||||
|
||||
if (!handled && this.setPositionActive)
|
||||
handled = this.$refs.setPositionPage.keyHook(event);
|
||||
if (!result && this.recentBooksActive)
|
||||
result = this.$refs.recentBooksPage.keyHook(event);
|
||||
|
||||
if (!handled && this.searchActive)
|
||||
handled = this.$refs.searchPage.keyHook(event);
|
||||
if (!result && this.setPositionActive)
|
||||
result = this.$refs.setPositionPage.keyHook(event);
|
||||
|
||||
if (!handled && this.copyTextActive)
|
||||
handled = this.$refs.copyTextPage.keyHook(event);
|
||||
if (!result && this.searchActive)
|
||||
result = this.$refs.searchPage.keyHook(event);
|
||||
|
||||
if (!handled && this.$refs.page && this.$refs.page.keyHook)
|
||||
handled = this.$refs.page.keyHook(event);
|
||||
if (!result && this.copyTextActive)
|
||||
result = this.$refs.copyTextPage.keyHook(event);
|
||||
|
||||
if (!handled && event.type == 'keydown') {
|
||||
if (!result && this.contentsActive)
|
||||
result = this.$refs.contentsPage.keyHook(event);
|
||||
|
||||
if (!result && this.$refs.page && this.$refs.page.keyHook)
|
||||
result = this.$refs.page.keyHook(event);
|
||||
|
||||
if (!result && event.type == 'keydown') {
|
||||
const action = this.$root.readerActionByKeyEvent(event);
|
||||
|
||||
if (action == 'loader') {
|
||||
@@ -1282,16 +1249,4 @@ class Reader extends Vue {
|
||||
.clear {
|
||||
color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
.clickable {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
cursor: pointer;
|
||||
font-size: 120%;
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
250
client/components/Reader/ReaderDialogs/ReaderDialogs.vue
Normal file
@@ -0,0 +1,250 @@
|
||||
<template>
|
||||
<div>
|
||||
<Dialog ref="dialog1" v-model="whatsNewVisible">
|
||||
<template slot="header">
|
||||
Что нового:
|
||||
</template>
|
||||
|
||||
<div style="line-height: 20px" v-html="whatsNewContent"></div>
|
||||
|
||||
<span class="clickable" @click="openVersionHistory">Посмотреть историю версий</span>
|
||||
<span slot="footer">
|
||||
<q-btn class="q-px-md" dense no-caps @click="whatsNewDisable">Больше не показывать</q-btn>
|
||||
</span>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref="dialog2" v-model="donationVisible">
|
||||
<template slot="header">
|
||||
Здравствуйте, уважаемые читатели!
|
||||
</template>
|
||||
|
||||
<div style="word-break: normal">
|
||||
Стартовала ежегодная акция "Оплатим хостинг вместе".<br><br>
|
||||
|
||||
Для оплаты годового хостинга читалки, необходимо собрать около 2000 рублей.
|
||||
В настоящий момент у автора эта сумма есть в наличии. Однако будет справедливо, если каждый
|
||||
сможет проголосовать рублем за то, чтобы читалка так и оставалась:
|
||||
|
||||
<ul>
|
||||
<li>непрерывно улучшаемой</li>
|
||||
<li>без рекламы</li>
|
||||
<li>без регистрации</li>
|
||||
<li>Open Source</li>
|
||||
</ul>
|
||||
|
||||
Автор также обращается с просьбой о помощи в распространении
|
||||
<a href="https://omnireader.ru" target="_blank">ссылки</a>
|
||||
<q-icon class="copy-icon" name="la la-copy" @click="copyLink('https://omnireader.ru')">
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="center middle" content-style="font-size: 80%">Скопировать</q-tooltip>
|
||||
</q-icon>
|
||||
на читалку через тематические форумы, соцсети, мессенджеры и пр.
|
||||
Чем нас больше, тем легче оставаться на плаву и тем больше мотивации у разработчика, чтобы продолжать работать над проектом.
|
||||
|
||||
<br><br>
|
||||
Если соберется бóльшая сумма, то разработка децентрализованной библиотеки для свободного обмена книгами будет по возможности ускорена.
|
||||
<br><br>
|
||||
P.S. При необходимости можно воспользоваться подходящим обменником на <a href="https://www.bestchange.ru" target="_blank">bestchange.ru</a>
|
||||
|
||||
<br><br>
|
||||
<div class="row justify-center">
|
||||
<q-btn class="q-px-sm" color="primary" dense no-caps rounded @click="openDonate">Помочь проекту</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span slot="footer">
|
||||
<span class="clickable row justify-end" style="font-size: 60%; color: grey" @click="donationDialogDisable">Больше не показывать</span>
|
||||
<br>
|
||||
<q-btn class="q-px-sm" dense no-caps @click="donationDialogRemind">Напомнить позже</q-btn>
|
||||
</span>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref="dialog3" v-model="liberamaTopVisible">
|
||||
<template slot="header">
|
||||
Здравствуйте, уважаемые читатели!
|
||||
</template>
|
||||
|
||||
<div style="word-break: normal">
|
||||
Создан новый ресурс:<br><br>
|
||||
|
||||
<a href="https://liberama.top" target="_blank">https://liberama.top</a>
|
||||
<br><br>
|
||||
Это клон читалки Omni Reader, но с некоторыми дополнениями, ориентированными в сторону более свободного обмена книгами:
|
||||
|
||||
<ul>
|
||||
<li>добавлено новое окно "Библиотека" для свободного доступа к Флибусте и другим ресурсам по желанию читателя</li>
|
||||
<li>планируется добавить возможность создания подборок книг и обмена ими между пользователями</li>
|
||||
</ul>
|
||||
|
||||
Легко мигрировать на новый сайт можно с помощью синхронизации с сервером.
|
||||
О багах и предложениях просьба сообщать на почту <a href="mailto:bookpauk@gmail.com">bookpauk@gmail.com</a><br><br>
|
||||
Спасибо, что вы с нами!
|
||||
<br><br>
|
||||
<div class="row justify-center">
|
||||
<q-btn class="q-px-sm" color="primary" dense no-caps rounded @click="openDonate">Помочь проекту</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span slot="footer">
|
||||
<q-btn class="q-px-sm" dense no-caps @click="liberamaTopDialogDisable">Больше не показывать</q-btn>
|
||||
</span>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
|
||||
import Dialog from '../../share/Dialog.vue';
|
||||
import * as utils from '../../../share/utils';
|
||||
import {versionHistory} from '../versionHistory';
|
||||
|
||||
export default @Component({
|
||||
components: {
|
||||
Dialog
|
||||
},
|
||||
watch: {
|
||||
settings: function() {
|
||||
this.loadSettings();
|
||||
},
|
||||
},
|
||||
})
|
||||
class ReaderDialogs extends Vue {
|
||||
whatsNewVisible = false;
|
||||
whatsNewContent = '';
|
||||
donationVisible = false;
|
||||
liberamaTopVisible = false;
|
||||
|
||||
created() {
|
||||
this.commit = this.$store.commit;
|
||||
this.loadSettings();
|
||||
}
|
||||
|
||||
mounted() {
|
||||
}
|
||||
|
||||
async init() {
|
||||
await this.showWhatsNew();
|
||||
await this.showDonation();
|
||||
await this.showLiberamaTop();
|
||||
}
|
||||
|
||||
loadSettings() {
|
||||
const settings = this.settings;
|
||||
this.showWhatsNewDialog = settings.showWhatsNewDialog;
|
||||
this.showDonationDialog2020 = settings.showDonationDialog2020;
|
||||
this.showLiberamaTopDialog2020 = settings.showLiberamaTopDialog2020;
|
||||
}
|
||||
|
||||
async showWhatsNew() {
|
||||
const whatsNew = versionHistory[0];
|
||||
if (this.showWhatsNewDialog &&
|
||||
whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
|
||||
whatsNew.header != this.whatsNewContentHash) {
|
||||
await utils.sleep(2000);
|
||||
this.whatsNewContent = 'Версия ' + whatsNew.header + whatsNew.content;
|
||||
this.whatsNewVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
async showDonation() {
|
||||
const today = utils.formatDate(new Date(), 'coDate');
|
||||
|
||||
if ((this.mode == 'omnireader' || this.mode == 'liberama.top') && today < '2020-03-01' && this.showDonationDialog2020 && this.donationRemindDate != today) {
|
||||
await utils.sleep(3000);
|
||||
this.donationVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
donationDialogDisable() {
|
||||
this.donationVisible = false;
|
||||
if (this.showDonationDialog2020) {
|
||||
this.commit('reader/setSettings', { showDonationDialog2020: false });
|
||||
}
|
||||
}
|
||||
|
||||
donationDialogRemind() {
|
||||
this.donationVisible = false;
|
||||
this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coDate'));
|
||||
}
|
||||
|
||||
openDonate() {
|
||||
this.donationVisible = false;
|
||||
this.liberamaTopVisible = false;
|
||||
this.$emit('donate-toggle');
|
||||
}
|
||||
|
||||
async copyLink(link) {
|
||||
const result = await utils.copyTextToClipboard(link);
|
||||
if (result)
|
||||
this.$root.notify.success(`Ссылка ${link} успешно скопирована в буфер обмена`);
|
||||
else
|
||||
this.$root.notify.error('Копирование не удалось');
|
||||
}
|
||||
|
||||
openVersionHistory() {
|
||||
this.whatsNewVisible = false;
|
||||
this.$emit('version-history-toggle');
|
||||
}
|
||||
|
||||
whatsNewDisable() {
|
||||
this.whatsNewVisible = false;
|
||||
const whatsNew = versionHistory[0];
|
||||
this.commit('reader/setWhatsNewContentHash', whatsNew.header);
|
||||
}
|
||||
|
||||
get mode() {
|
||||
return this.$store.state.config.mode;
|
||||
}
|
||||
|
||||
get settings() {
|
||||
return this.$store.state.reader.settings;
|
||||
}
|
||||
|
||||
get whatsNewContentHash() {
|
||||
return this.$store.state.reader.whatsNewContentHash;
|
||||
}
|
||||
|
||||
get donationRemindDate() {
|
||||
return this.$store.state.reader.donationRemindDate;
|
||||
}
|
||||
|
||||
async showLiberamaTop() {
|
||||
const today = utils.formatDate(new Date(), 'coDate');
|
||||
|
||||
if (this.mode == 'omnireader' && today < '2020-12-01' && this.showLiberamaTopDialog2020) {
|
||||
await utils.sleep(3000);
|
||||
this.liberamaTopVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
liberamaTopDialogDisable() {
|
||||
this.liberamaTopVisible = false;
|
||||
if (this.showLiberamaTopDialog2020) {
|
||||
this.commit('reader/setSettings', { showLiberamaTopDialog2020: false });
|
||||
}
|
||||
}
|
||||
|
||||
keyHook() {
|
||||
if (this.$refs.dialog1.active || this.$refs.dialog2.active || this.$refs.dialog3.active)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.clickable {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
cursor: pointer;
|
||||
font-size: 120%;
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
@@ -341,7 +341,7 @@ class RecentBooksPage extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (!this.$root.stdDialog.active && event.type == 'keydown' && event.code == 'Escape') {
|
||||
if (!this.$root.stdDialog.active && event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -174,7 +174,7 @@ class SearchPage extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (event.type == 'keydown' && (event.code == 'Escape')) {
|
||||
if (event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div></div>
|
||||
<div class="hidden"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -35,6 +35,9 @@ export default @Component({
|
||||
currentProfile: function() {
|
||||
this.currentProfileChanged(true);
|
||||
},
|
||||
libs: function() {
|
||||
this.debouncedSaveLibs();
|
||||
},
|
||||
},
|
||||
})
|
||||
class ServerStorage extends Vue {
|
||||
@@ -49,27 +52,32 @@ class ServerStorage extends Vue {
|
||||
this.saveSettings();
|
||||
}, 500);
|
||||
|
||||
this.debouncedSaveLibs = _.debounce(() => {
|
||||
this.saveLibs();
|
||||
}, 500);
|
||||
|
||||
this.debouncedNotifySuccess = _.debounce(() => {
|
||||
this.success('Данные синхронизированы с сервером');
|
||||
}, 1000);
|
||||
|
||||
this.oldProfiles = {};
|
||||
this.oldSettings = {};
|
||||
this.oldLibs = {};
|
||||
}
|
||||
|
||||
async init() {
|
||||
try {
|
||||
this.cachedRecent = await ssCacheStore.getItem('recent');
|
||||
if (!this.cachedRecent)
|
||||
await this.setCachedRecent({rev: 0, data: {}});
|
||||
await this.cleanCachedRecent('cachedRecent');
|
||||
|
||||
this.cachedRecentPatch = await ssCacheStore.getItem('recent-patch');
|
||||
if (!this.cachedRecentPatch)
|
||||
await this.setCachedRecentPatch({rev: 0, data: {}});
|
||||
await this.cleanCachedRecent('cachedRecentPatch');
|
||||
|
||||
this.cachedRecentMod = await ssCacheStore.getItem('recent-mod');
|
||||
if (!this.cachedRecentMod)
|
||||
await this.setCachedRecentMod({rev: 0, data: {}});
|
||||
await this.cleanCachedRecent('cachedRecentMod');
|
||||
|
||||
if (!this.serverStorageKey) {
|
||||
//генерируем новый ключ
|
||||
@@ -97,6 +105,15 @@ class ServerStorage extends Vue {
|
||||
this.cachedRecentMod = value;
|
||||
}
|
||||
|
||||
async cleanCachedRecent(whatToClean) {
|
||||
if (whatToClean == 'cachedRecent' || whatToClean == 'all')
|
||||
await this.setCachedRecent({rev: 0, data: {}});
|
||||
if (whatToClean == 'cachedRecentPatch' || whatToClean == 'all')
|
||||
await this.setCachedRecentPatch({rev: 0, data: {}});
|
||||
if (whatToClean == 'cachedRecentMod' || whatToClean == 'all')
|
||||
await this.setCachedRecentMod({rev: 0, data: {}});
|
||||
}
|
||||
|
||||
async generateNewServerStorageKey() {
|
||||
const key = utils.toBase58(utils.randomArray(32));
|
||||
this.commit('reader/setServerStorageKey', key);
|
||||
@@ -124,9 +141,14 @@ class ServerStorage extends Vue {
|
||||
await this.loadProfiles(force);
|
||||
this.checkCurrentProfile();
|
||||
await this.currentProfileChanged(force);
|
||||
await this.loadLibs(force);
|
||||
|
||||
if (force)
|
||||
await this.cleanCachedRecent('all');
|
||||
const loadSuccess = await this.loadRecent();
|
||||
if (loadSuccess && force)
|
||||
if (loadSuccess && force) {
|
||||
await this.saveRecent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +191,14 @@ class ServerStorage extends Vue {
|
||||
return this.settings.showServerStorageMessages;
|
||||
}
|
||||
|
||||
get libs() {
|
||||
return this.$store.state.reader.libs;
|
||||
}
|
||||
|
||||
get libsRev() {
|
||||
return this.$store.state.reader.libsRev;
|
||||
}
|
||||
|
||||
checkCurrentProfile() {
|
||||
if (!this.profiles[this.currentProfile]) {
|
||||
this.commit('reader/setCurrentProfile', '');
|
||||
@@ -338,13 +368,85 @@ class ServerStorage extends Vue {
|
||||
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
|
||||
} else if (result.state == 'success') {
|
||||
this.oldProfiles = _.cloneDeep(this.profiles);
|
||||
this.commit('reader/setProfilesRev', this.profilesRev + 1);
|
||||
this.commit('reader/setProfilesRev', this.profilesRev + 1);
|
||||
}
|
||||
} finally {
|
||||
this.savingProfiles = false;
|
||||
}
|
||||
}
|
||||
|
||||
async loadLibs(force = false, doNotifySuccess = true) {
|
||||
if (!this.keyInited || !this.serverSyncEnabled)
|
||||
return;
|
||||
|
||||
const oldRev = this.libsRev;
|
||||
//проверим ревизию на сервере
|
||||
if (!force) {
|
||||
try {
|
||||
const revs = await this.storageCheck({libs: {}});
|
||||
if (revs.state == 'success' && revs.items.libs.rev == oldRev) {
|
||||
return;
|
||||
}
|
||||
} catch(e) {
|
||||
this.error(`Ошибка соединения с сервером: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let libs = null;
|
||||
try {
|
||||
libs = await this.storageGet({libs: {}});
|
||||
} catch(e) {
|
||||
this.error(`Ошибка соединения с сервером: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (libs.state == 'success') {
|
||||
libs = libs.items.libs;
|
||||
|
||||
if (libs.rev == 0)
|
||||
libs.data = {};
|
||||
|
||||
this.oldLibs = _.cloneDeep(libs.data);
|
||||
this.commit('reader/setLibs', libs.data);
|
||||
this.commit('reader/setLibsRev', libs.rev);
|
||||
|
||||
if (doNotifySuccess)
|
||||
this.debouncedNotifySuccess();
|
||||
} else {
|
||||
this.warning(`Неверный ответ сервера: ${libs.state}`);
|
||||
}
|
||||
}
|
||||
|
||||
async saveLibs() {
|
||||
if (!this.keyInited || !this.serverSyncEnabled || this.savingLibs)
|
||||
return;
|
||||
|
||||
const diff = utils.getObjDiff(this.oldLibs, this.libs);
|
||||
if (utils.isEmptyObjDiff(diff))
|
||||
return;
|
||||
|
||||
this.savingLibs = true;
|
||||
try {
|
||||
let result = {state: ''};
|
||||
try {
|
||||
result = await this.storageSet({libs: {rev: this.libsRev + 1, data: this.libs}});
|
||||
} catch(e) {
|
||||
this.error(`Ошибка соединения с сервером (${e.message}). Данные не сохранены и могут быть перезаписаны.`);
|
||||
}
|
||||
|
||||
if (result.state == 'reject') {
|
||||
await this.loadLibs(true, false);
|
||||
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
|
||||
} else if (result.state == 'success') {
|
||||
this.oldLibs = _.cloneDeep(this.libs);
|
||||
this.commit('reader/setLibsRev', this.libsRev + 1);
|
||||
}
|
||||
} finally {
|
||||
this.savingLibs = false;
|
||||
}
|
||||
}
|
||||
|
||||
async loadRecent(skipRevCheck = false, doNotifySuccess = true) {
|
||||
if (!this.keyInited || !this.serverSyncEnabled || this.loadingRecent)
|
||||
return;
|
||||
@@ -403,7 +505,7 @@ class ServerStorage extends Vue {
|
||||
|
||||
const md = newRecentMod.data;
|
||||
if (md.key && result[md.key])
|
||||
result[md.key] = utils.applyObjDiff(result[md.key], md.mod, true);
|
||||
result[md.key] = utils.applyObjDiff(result[md.key], md.mod, {isAddChanged: true});
|
||||
|
||||
if (!bookManager.loaded) {
|
||||
this.warning('Ожидание загрузки списка книг перед синхронизацией');
|
||||
@@ -467,7 +569,7 @@ class ServerStorage extends Vue {
|
||||
|
||||
let applyMod = this.cachedRecentMod.data;
|
||||
if (applyMod && applyMod.key && newRecentPatch.data[applyMod.key])
|
||||
newRecentPatch.data[applyMod.key] = utils.applyObjDiff(newRecentPatch.data[applyMod.key], applyMod.mod, true);
|
||||
newRecentPatch.data[applyMod.key] = utils.applyObjDiff(newRecentPatch.data[applyMod.key], applyMod.mod, {isAddChanged: true});
|
||||
|
||||
newRecentMod = {rev: this.cachedRecentMod.rev + 1, data: {}};
|
||||
needSaveRecentPatch = true;
|
||||
|
||||
@@ -60,7 +60,7 @@ class SetPositionPage extends Vue {
|
||||
keyHook(event) {
|
||||
if (event.type == 'keydown') {
|
||||
const action = this.$root.readerActionByKeyEvent(event);
|
||||
if (event.code == 'Escape' || action == 'setPosition') {
|
||||
if (event.key == 'Escape' || action == 'setPosition') {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +108,10 @@ export default @Component({
|
||||
},
|
||||
vertShift: function(newValue) {
|
||||
const font = (this.webFontName ? this.webFontName : this.fontName);
|
||||
this.fontShifts = Object.assign({}, this.fontShifts, {[font]: newValue});
|
||||
this.fontVertShift = newValue;
|
||||
if (this.fontShifts[font] != newValue) {
|
||||
this.fontShifts = Object.assign({}, this.fontShifts, {[font]: newValue});
|
||||
this.fontVertShift = newValue;
|
||||
}
|
||||
},
|
||||
fontName: function(newValue) {
|
||||
const font = (this.webFontName ? this.webFontName : newValue);
|
||||
@@ -185,10 +187,18 @@ class SettingsPage extends Vue {
|
||||
settingsChanged() {
|
||||
if (_.isEqual(this.form, this.settings))
|
||||
return;
|
||||
|
||||
this.form = Object.assign({}, this.settings);
|
||||
if (!this.unwatch)
|
||||
this.unwatch = {};
|
||||
|
||||
for (let prop in rstore.settingDefaults) {
|
||||
if (this.unwatch && this.unwatch[prop])
|
||||
this.unwatch[prop]();
|
||||
|
||||
this[prop] = this.form[prop];
|
||||
this.$watch(prop, (newValue) => {
|
||||
|
||||
this.unwatch[prop] = this.$watch(prop, (newValue) => {
|
||||
this.form = Object.assign({}, this.form, {[prop]: newValue});
|
||||
});
|
||||
}
|
||||
@@ -397,7 +407,7 @@ class SettingsPage extends Vue {
|
||||
return;
|
||||
|
||||
try {
|
||||
const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Удаление профиля '${this.currentProfile}' необратимо.` +
|
||||
const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Удаление профиля '${this.$sanitize(this.currentProfile)}' необратимо.` +
|
||||
`<br>Все настройки профиля будут потеряны, однако список читаемых книг сохранится.` +
|
||||
`<br><br>Введите 'да' для подтверждения удаления:`, ' ', {
|
||||
inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Удаление не подтверждено'; },
|
||||
@@ -499,7 +509,7 @@ class SettingsPage extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (!this.$root.stdDialog.active && event.type == 'keydown' && event.code == 'Escape') {
|
||||
if (!this.$root.stdDialog.active && event.type == 'keydown' && event.key == 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -104,8 +104,12 @@ class UserHotKeys extends UserHotKeysProps {
|
||||
this.updateTableData();
|
||||
}
|
||||
|
||||
get mode() {
|
||||
return this.$store.state.config.mode;
|
||||
}
|
||||
|
||||
updateTableData() {
|
||||
let result = rstore.hotKeys.map(hk => hk.name);
|
||||
let result = rstore.hotKeys.map(hk => hk.name).filter(name => (this.mode == 'liberama.top' || name != 'libs'));
|
||||
|
||||
const search = this.search.toLowerCase();
|
||||
const codesIncludeSearch = (action) => {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<div class="part-header">Показывать кнопки панели</div>
|
||||
|
||||
<div class="item row" v-for="item in toolButtons" :key="item.name">
|
||||
<div class="item row" v-for="item in toolButtons" :key="item.name" v-show="item.name != 'libs' || mode == 'liberama.top'">
|
||||
<div class="label-3"></div>
|
||||
<div class="col row">
|
||||
<q-checkbox size="xs" @input="changeShowToolButton(item.name)" :value="showToolButton[item.name]" :label="rstore.readerActions[item.name]" />
|
||||
<q-checkbox size="xs" @input="changeShowToolButton(item.name)"
|
||||
:value="showToolButton[item.name]" :label="rstore.readerActions[item.name]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<q-select v-model="currentProfile" :options="currentProfileOptions"
|
||||
style="width: 275px"
|
||||
dropdown-icon="la la-angle-down la-sm"
|
||||
outlined dense emit-value map-options
|
||||
outlined dense emit-value map-options display-value-sanitize options-sanitize
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,7 +68,7 @@
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="center middle" content-style="font-size: 80%">Скопировать</q-tooltip>
|
||||
</q-icon>
|
||||
</div>
|
||||
<div v-if="mode == 'omnireader'">
|
||||
<div v-if="mode == 'omnireader' || mode == 'liberama.top'">
|
||||
<br>Переход по ссылке позволит автоматически ввести ключ доступа:
|
||||
<br><div class="text-center" style="margin-top: 5px">
|
||||
<a :href="setStorageKeyLink" target="_blank">Ссылка для ввода ключа</a>
|
||||
|
||||
@@ -839,7 +839,7 @@ class TextPage extends Vue {
|
||||
let i = this.pageLineCount;
|
||||
if (this.keepLastToFirst)
|
||||
i--;
|
||||
if (i >= 0 && this.linesDown.length >= 2*i) {
|
||||
if (i >= 0 && this.linesDown.length >= 2*i + (this.keepLastToFirst ? 1 : 0)) {
|
||||
this.currentAnimation = this.pageChangeAnimation;
|
||||
this.pageChangeDirectionDown = true;
|
||||
this.bookPos = this.linesDown[i].begin;
|
||||
@@ -904,8 +904,7 @@ class TextPage extends Vue {
|
||||
if (!this.settingsChanging) {
|
||||
this.settingsChanging = true;
|
||||
const newSize = (this.settings.fontSize + 1 < 200 ? this.settings.fontSize + 1 : 100);
|
||||
const newSettings = Object.assign({}, this.settings, {fontSize: newSize});
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
this.commit('reader/setSettings', {fontSize: newSize});
|
||||
await sleep(50);
|
||||
this.settingsChanging = false;
|
||||
}
|
||||
@@ -915,8 +914,7 @@ class TextPage extends Vue {
|
||||
if (!this.settingsChanging) {
|
||||
this.settingsChanging = true;
|
||||
const newSize = (this.settings.fontSize - 1 > 5 ? this.settings.fontSize - 1 : 5);
|
||||
const newSettings = Object.assign({}, this.settings, {fontSize: newSize});
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
this.commit('reader/setSettings', {fontSize: newSize});
|
||||
await sleep(50);
|
||||
this.settingsChanging = false;
|
||||
}
|
||||
@@ -926,8 +924,7 @@ class TextPage extends Vue {
|
||||
if (!this.settingsChanging) {
|
||||
this.settingsChanging = true;
|
||||
const newDelay = (this.settings.scrollingDelay - 50 > 1 ? this.settings.scrollingDelay - 50 : 1);
|
||||
const newSettings = Object.assign({}, this.settings, {scrollingDelay: newDelay});
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
this.commit('reader/setSettings', {scrollingDelay: newDelay});
|
||||
await sleep(50);
|
||||
this.settingsChanging = false;
|
||||
}
|
||||
@@ -937,8 +934,7 @@ class TextPage extends Vue {
|
||||
if (!this.settingsChanging) {
|
||||
this.settingsChanging = true;
|
||||
const newDelay = (this.settings.scrollingDelay + 50 < 10000 ? this.settings.scrollingDelay + 50 : 10000);
|
||||
const newSettings = Object.assign({}, this.settings, {scrollingDelay: newDelay});
|
||||
this.commit('reader/setSettings', newSettings);
|
||||
this.commit('reader/setSettings', {scrollingDelay: newDelay});
|
||||
await sleep(50);
|
||||
this.settingsChanging = false;
|
||||
}
|
||||
|
||||
@@ -46,11 +46,21 @@ export default class BookParser {
|
||||
let isFirstSection = true;
|
||||
let isFirstTitlePara = false;
|
||||
|
||||
//изображения
|
||||
this.binary = {};
|
||||
let binaryId = '';
|
||||
let binaryType = '';
|
||||
let dimPromises = [];
|
||||
|
||||
//оглавление
|
||||
this.contents = [];
|
||||
let curTitle = {paraIndex: -1, title: '', subtitles: []};
|
||||
let curSubtitle = {paraIndex: -1, title: ''};
|
||||
let inTitle = false;
|
||||
let inSubtitle = false;
|
||||
let sectionLevel = 0;
|
||||
let bodyIndex = 0;
|
||||
|
||||
let paraIndex = -1;
|
||||
let paraOffset = 0;
|
||||
let para = []; /*array of
|
||||
@@ -118,6 +128,12 @@ export default class BookParser {
|
||||
addIndex: (addIndex ? addIndex : 0),
|
||||
};
|
||||
|
||||
if (inSubtitle) {
|
||||
curSubtitle.title += '<p>';
|
||||
} else if (inTitle) {
|
||||
curTitle.title += '<p>';
|
||||
}
|
||||
|
||||
para[paraIndex] = p;
|
||||
paraOffset += p.length;
|
||||
};
|
||||
@@ -129,6 +145,7 @@ export default class BookParser {
|
||||
return;
|
||||
}
|
||||
|
||||
const prevParaIndex = paraIndex;
|
||||
let p = para[paraIndex];
|
||||
paraOffset -= p.length;
|
||||
//добавление пустых (addEmptyParagraphs) параграфов перед текущим
|
||||
@@ -143,6 +160,11 @@ export default class BookParser {
|
||||
p.offset = paraOffset;
|
||||
para[paraIndex] = p;
|
||||
|
||||
if (curTitle.paraIndex == prevParaIndex)
|
||||
curTitle.paraIndex = paraIndex;
|
||||
if (curSubtitle.paraIndex == prevParaIndex)
|
||||
curSubtitle.paraIndex = paraIndex;
|
||||
|
||||
//уберем начальный пробел
|
||||
p.length = 0;
|
||||
p.text = p.text.substr(1);
|
||||
@@ -151,6 +173,13 @@ export default class BookParser {
|
||||
p.length += len;
|
||||
p.text += text;
|
||||
|
||||
|
||||
if (inSubtitle) {
|
||||
curSubtitle.title += text;
|
||||
} else if (inTitle) {
|
||||
curTitle.title += text;
|
||||
}
|
||||
|
||||
para[paraIndex] = p;
|
||||
paraOffset += p.length;
|
||||
};
|
||||
@@ -160,7 +189,7 @@ export default class BookParser {
|
||||
return;
|
||||
|
||||
tag = elemName;
|
||||
path += '/' + elemName;
|
||||
path += '/' + tag;
|
||||
|
||||
if (tag == 'binary') {
|
||||
let attrs = sax.getAttrsSync(tail);
|
||||
@@ -187,7 +216,7 @@ export default class BookParser {
|
||||
}
|
||||
}
|
||||
|
||||
if (elemName == 'author' && path.indexOf('/fictionbook/description/title-info/author') == 0) {
|
||||
if (tag == 'author' && path.indexOf('/fictionbook/description/title-info/author') == 0) {
|
||||
if (!fb2.author)
|
||||
fb2.author = [];
|
||||
fb2.author.push({});
|
||||
@@ -198,6 +227,7 @@ export default class BookParser {
|
||||
if (!isFirstBody)
|
||||
newParagraph(' ', 1);
|
||||
isFirstBody = false;
|
||||
bodyIndex++;
|
||||
}
|
||||
|
||||
if (tag == 'title') {
|
||||
@@ -205,12 +235,17 @@ export default class BookParser {
|
||||
isFirstTitlePara = true;
|
||||
bold = true;
|
||||
center = true;
|
||||
|
||||
inTitle = true;
|
||||
curTitle = {paraIndex, title: '', inset: sectionLevel, bodyIndex, subtitles: []};
|
||||
this.contents.push(curTitle);
|
||||
}
|
||||
|
||||
if (tag == 'section') {
|
||||
if (!isFirstSection)
|
||||
newParagraph(' ', 1);
|
||||
isFirstSection = false;
|
||||
sectionLevel++;
|
||||
}
|
||||
|
||||
if (tag == 'emphasis' || tag == 'strong') {
|
||||
@@ -231,9 +266,13 @@ export default class BookParser {
|
||||
isFirstTitlePara = true;
|
||||
bold = true;
|
||||
center = true;
|
||||
|
||||
inSubtitle = true;
|
||||
curSubtitle = {paraIndex, inset: sectionLevel, title: ''};
|
||||
curTitle.subtitles.push(curSubtitle);
|
||||
}
|
||||
|
||||
if (tag == 'epigraph') {
|
||||
if (tag == 'epigraph' || tag == 'annotation') {
|
||||
italic = true;
|
||||
space += 1;
|
||||
}
|
||||
@@ -260,6 +299,11 @@ export default class BookParser {
|
||||
isFirstTitlePara = false;
|
||||
bold = false;
|
||||
center = false;
|
||||
inTitle = false;
|
||||
}
|
||||
|
||||
if (tag == 'section') {
|
||||
sectionLevel--;
|
||||
}
|
||||
|
||||
if (tag == 'emphasis' || tag == 'strong') {
|
||||
@@ -274,11 +318,14 @@ export default class BookParser {
|
||||
isFirstTitlePara = false;
|
||||
bold = false;
|
||||
center = false;
|
||||
inSubtitle = false;
|
||||
}
|
||||
|
||||
if (tag == 'epigraph') {
|
||||
if (tag == 'epigraph' || tag == 'annotation') {
|
||||
italic = false;
|
||||
space -= 1;
|
||||
if (tag == 'annotation')
|
||||
newParagraph(' ', 1);
|
||||
}
|
||||
|
||||
if (tag == 'stanza') {
|
||||
@@ -656,6 +703,7 @@ export default class BookParser {
|
||||
let style = {};
|
||||
let ofs = 0;//смещение от начала параграфа para.offset
|
||||
let imgW = 0;
|
||||
let imageInPara = false;
|
||||
const compactWidth = this.measureText('W', {})*this.compactTextPerc/100;
|
||||
// тут начинается самый замес, перенос по слогам и стилизация, а также изображения
|
||||
for (const part of parts) {
|
||||
@@ -664,7 +712,7 @@ export default class BookParser {
|
||||
|
||||
//изображения
|
||||
if (part.image.id && !part.image.inline) {
|
||||
parsed.visible = this.showImages;
|
||||
imageInPara = true;
|
||||
let bin = this.binary[part.image.id];
|
||||
if (!bin)
|
||||
bin = {h: 1, w: 1};
|
||||
@@ -832,10 +880,14 @@ export default class BookParser {
|
||||
}
|
||||
|
||||
//parsed.visible
|
||||
parsed.visible = !(
|
||||
(para.addIndex > this.addEmptyParagraphs) ||
|
||||
(para.addIndex == 0 && this.cutEmptyParagraphs && paragraphText.trim() == '')
|
||||
);
|
||||
if (imageInPara) {
|
||||
parsed.visible = this.showImages;
|
||||
} else {
|
||||
parsed.visible = !(
|
||||
(para.addIndex > this.addEmptyParagraphs) ||
|
||||
(para.addIndex == 0 && this.cutEmptyParagraphs && paragraphText.trim() == '')
|
||||
);
|
||||
}
|
||||
|
||||
parsed.lines = lines;
|
||||
para.parsed = parsed;
|
||||
|
||||
@@ -1,4 +1,63 @@
|
||||
export const versionHistory = [
|
||||
{
|
||||
showUntil: '2020-11-12',
|
||||
header: '0.9.8 (2020-11-13)',
|
||||
content:
|
||||
`
|
||||
<ul>
|
||||
<li>добавлено окно "Оглавление/закладки"</li>
|
||||
</ul>
|
||||
`
|
||||
},
|
||||
|
||||
{
|
||||
showUntil: '2020-11-11',
|
||||
header: '0.9.7 (2020-11-12)',
|
||||
content:
|
||||
`
|
||||
<ul>
|
||||
<li>исправления багов</li>
|
||||
</ul>
|
||||
`
|
||||
},
|
||||
|
||||
{
|
||||
showUntil: '2020-11-05',
|
||||
header: '0.9.6 (2020-11-06)',
|
||||
content:
|
||||
`
|
||||
<ul>
|
||||
<li>завершена работа над новым окном "Библиотека"</li>
|
||||
<li>исправления багов</li>
|
||||
</ul>
|
||||
`
|
||||
},
|
||||
|
||||
{
|
||||
showUntil: '2020-10-31',
|
||||
header: '0.9.5 (2020-11-01)',
|
||||
content:
|
||||
`
|
||||
<ul>
|
||||
<li>на панель инструментов добавлена новая кнопка "Обновить с разбиением на параграфы"</li>
|
||||
<li>исправления багов</li>
|
||||
</ul>
|
||||
`
|
||||
},
|
||||
|
||||
{
|
||||
showUntil: '2020-10-28',
|
||||
header: '0.9.4 (2020-10-29)',
|
||||
content:
|
||||
`
|
||||
<ul>
|
||||
<li>заработал новый сайт <a href="https://liberama.top">https://liberama.top</a>, где будет более свободный обмен книгами</li>
|
||||
<li>для liberama.top добавлено новое окно: "Библиотека"</li>
|
||||
<li>исправления багов</li>
|
||||
</ul>
|
||||
`
|
||||
},
|
||||
|
||||
{
|
||||
showUntil: '2020-05-20',
|
||||
header: '0.9.3 (2020-05-21)',
|
||||
|
||||
@@ -32,7 +32,7 @@ const DialogProps = Vue.extend({
|
||||
props: {
|
||||
value: Boolean,
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
export default @Component({
|
||||
})
|
||||
|
||||
@@ -19,11 +19,12 @@ class Notify extends Vue {
|
||||
iconColor = 'white',
|
||||
message = '',
|
||||
messageColor = 'black',
|
||||
position = 'top-right',
|
||||
} = opts;
|
||||
|
||||
caption = (caption ? `<div style="font-size: 120%; color: ${captionColor}"><b>${caption}</b></div><br>` : '');
|
||||
return this.$q.notify({
|
||||
position: 'top-right',
|
||||
position,
|
||||
color,
|
||||
textColor: iconColor,
|
||||
icon,
|
||||
@@ -38,20 +39,20 @@ class Notify extends Vue {
|
||||
});
|
||||
}
|
||||
|
||||
success(message, caption) {
|
||||
this.notify({color: 'positive', icon: 'la la-check-circle', message, caption});
|
||||
success(message, caption, options) {
|
||||
this.notify(Object.assign({color: 'positive', icon: 'la la-check-circle', message, caption}, options));
|
||||
}
|
||||
|
||||
warning(message, caption) {
|
||||
this.notify({color: 'warning', icon: 'la la-exclamation-circle', message, caption});
|
||||
warning(message, caption, options) {
|
||||
this.notify(Object.assign({color: 'warning', icon: 'la la-exclamation-circle', message, caption}, options));
|
||||
}
|
||||
|
||||
error(message, caption) {
|
||||
this.notify({color: 'negative', icon: 'la la-exclamation-circle', messageColor: 'yellow', captionColor: 'white', message, caption});
|
||||
error(message, caption, options) {
|
||||
this.notify(Object.assign({color: 'negative', icon: 'la la-exclamation-circle', messageColor: 'yellow', captionColor: 'white', message, caption}, options));
|
||||
}
|
||||
|
||||
info(message, caption) {
|
||||
this.notify({color: 'info', icon: 'la la-bell', message, caption});
|
||||
info(message, caption, options) {
|
||||
this.notify(Object.assign({color: 'info', icon: 'la la-bell', message, caption}, options));
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div v-show="type == 'alert'" class="bg-white no-wrap">
|
||||
<div class="header row">
|
||||
<div class="caption col row items-center q-ml-md">
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" name="las la-exclamation-circle" size="28px"></q-icon>
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" :name="iconName" size="28px"></q-icon>
|
||||
<div v-html="caption"></div>
|
||||
</div>
|
||||
<div class="close-icon column justify-center items-center">
|
||||
@@ -29,7 +29,7 @@
|
||||
<div v-show="type == 'confirm'" class="bg-white no-wrap">
|
||||
<div class="header row">
|
||||
<div class="caption col row items-center q-ml-md">
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" name="las la-exclamation-circle" size="28px"></q-icon>
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" :name="iconName" size="28px"></q-icon>
|
||||
<div v-html="caption"></div>
|
||||
</div>
|
||||
<div class="close-icon column justify-center items-center">
|
||||
@@ -53,7 +53,7 @@
|
||||
<div v-show="type == 'prompt'" class="bg-white no-wrap">
|
||||
<div class="header row">
|
||||
<div class="caption col row items-center q-ml-md">
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" name="las la-exclamation-circle" size="28px"></q-icon>
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" :name="iconName" size="28px"></q-icon>
|
||||
<div v-html="caption"></div>
|
||||
</div>
|
||||
<div class="close-icon column justify-center items-center">
|
||||
@@ -79,7 +79,7 @@
|
||||
<div v-show="type == 'hotKey'" class="bg-white no-wrap">
|
||||
<div class="header row">
|
||||
<div class="caption col row items-center q-ml-md">
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" name="las la-exclamation-circle" size="28px"></q-icon>
|
||||
<q-icon v-show="caption" class="q-mr-sm" :class="iconColor" :name="iconName" size="28px"></q-icon>
|
||||
<div v-html="caption"></div>
|
||||
</div>
|
||||
<div class="close-icon column justify-center items-center">
|
||||
@@ -127,6 +127,7 @@ class StdDialog extends Vue {
|
||||
inputValue = '';
|
||||
error = '';
|
||||
iconColor = '';
|
||||
iconName = '';
|
||||
hotKeyCode = '';
|
||||
|
||||
created() {
|
||||
@@ -144,12 +145,18 @@ class StdDialog extends Vue {
|
||||
this.inputValidator = null;
|
||||
this.inputValue = '';
|
||||
this.error = '';
|
||||
this.showed = false;
|
||||
|
||||
this.iconColor = 'text-warning';
|
||||
if (opts && opts.color) {
|
||||
this.iconColor = `text-${opts.color}`;
|
||||
}
|
||||
|
||||
this.iconName = 'las la-exclamation-circle';
|
||||
if (opts && opts.iconName) {
|
||||
this.iconName = opts.iconName;
|
||||
}
|
||||
|
||||
this.hotKeyCode = '';
|
||||
if (opts && opts.hotKeyCode) {
|
||||
this.hotKeyCode = opts.hotKeyCode;
|
||||
@@ -161,6 +168,7 @@ class StdDialog extends Vue {
|
||||
this.hideTrigger();
|
||||
this.hideTrigger = null;
|
||||
}
|
||||
this.showed = false;
|
||||
}
|
||||
|
||||
onShow() {
|
||||
@@ -170,6 +178,7 @@ class StdDialog extends Vue {
|
||||
this.validate(this.inputValue);
|
||||
this.$refs.input.focus();
|
||||
}
|
||||
this.showed = true;
|
||||
}
|
||||
|
||||
validate(value) {
|
||||
@@ -276,7 +285,7 @@ class StdDialog extends Vue {
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
if (this.active) {
|
||||
if (this.active && this.showed) {
|
||||
let handled = false;
|
||||
if (this.type == 'hotKey') {
|
||||
if (event.type == 'keydown') {
|
||||
@@ -284,12 +293,12 @@ class StdDialog extends Vue {
|
||||
handled = true;
|
||||
}
|
||||
} else {
|
||||
if (event.code == 'Enter') {
|
||||
if (event.key == 'Enter') {
|
||||
this.okClick();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if (event.code == 'Escape') {
|
||||
if (event.key == 'Escape') {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.dialog.hide();
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<template>
|
||||
<div ref="main" class="main xyfit absolute" @click="close" @mouseup="onMouseUp" @mousemove="onMouseMove">
|
||||
<div ref="windowBox" class="xyfit absolute flex no-wrap" @click.stop>
|
||||
<div class="window flexfit column no-wrap">
|
||||
<div ref="window" class="window flexfit column no-wrap">
|
||||
<div ref="header" class="header row justify-end" @mousedown.prevent.stop="onMouseDown"
|
||||
@touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchmove.stop="onTouchMove">
|
||||
<span class="header-text col"><slot name="header"></slot></span>
|
||||
<slot name="buttons"></slot>
|
||||
<span class="close-button row justify-center items-center" @mousedown.stop @click="close"><q-icon name="la la-times" size="16px"/></span>
|
||||
</div>
|
||||
|
||||
@@ -25,11 +26,15 @@ export default @Component({
|
||||
width: { type: String, default: '100%' },
|
||||
maxWidth: { type: String, default: '' },
|
||||
topShift: { type: Number, default: 0 },
|
||||
margin: '',
|
||||
}
|
||||
})
|
||||
class Window extends Vue {
|
||||
init() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.main.style.top = 0;
|
||||
this.$refs.main.style.left = 0;
|
||||
|
||||
this.$refs.windowBox.style.height = this.height;
|
||||
this.$refs.windowBox.style.width = this.width;
|
||||
if (this.maxWidth)
|
||||
@@ -39,6 +44,9 @@ class Window extends Vue {
|
||||
const top = (this.$refs.main.offsetHeight - this.$refs.windowBox.offsetHeight)/2 + this.topShift;
|
||||
this.$refs.windowBox.style.left = (left > 0 ? left : 0) + 'px';
|
||||
this.$refs.windowBox.style.top = (top > 0 ? top : 0) + 'px';
|
||||
|
||||
if (this.margin)
|
||||
this.$refs.window.style.margin = this.margin;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,5 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="https://yastatic.net/share2/share.js" async="async"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,6 +4,9 @@ import router from './router';
|
||||
import store from './store';
|
||||
import './quasar';
|
||||
|
||||
import vueSanitize from 'vue-sanitize';
|
||||
Vue.use(vueSanitize);
|
||||
|
||||
import App from './components/App.vue';
|
||||
//Vue.config.productionTip = false;
|
||||
Vue.prototype.$isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
|
||||
|
||||
@@ -21,7 +21,7 @@ import {QSlider} from 'quasar/src/components/slider';
|
||||
import {QTabs, QTab} from 'quasar/src/components/tabs';
|
||||
//import {QTabPanels, QTabPanel} from 'quasar/src/components/tab-panels';
|
||||
import {QSeparator} from 'quasar/src/components/separator';
|
||||
import {QList, QItem, QItemSection, QItemLabel} from 'quasar/src/components/item';
|
||||
//import {QList, QItem, QItemSection, QItemLabel} from 'quasar/src/components/item';
|
||||
import {QTooltip} from 'quasar/src/components/tooltip';
|
||||
import {QSpinner} from 'quasar/src/components/spinner';
|
||||
import {QTable, QTh, QTr, QTd} from 'quasar/src/components/table';
|
||||
@@ -31,6 +31,8 @@ import {QColor} from 'quasar/src/components/color';
|
||||
import {QPopupProxy} from 'quasar/src/components/popup-proxy';
|
||||
import {QDialog} from 'quasar/src/components/dialog';
|
||||
import {QChip} from 'quasar/src/components/chip';
|
||||
import {QTree} from 'quasar/src/components/tree';
|
||||
//import {QExpansionItem} from 'quasar/src/components/expansion-item';
|
||||
|
||||
const components = {
|
||||
//QLayout,
|
||||
@@ -47,7 +49,7 @@ const components = {
|
||||
QTabs, QTab,
|
||||
//QTabPanels, QTabPanel,
|
||||
QSeparator,
|
||||
QList, QItem, QItemSection, QItemLabel,
|
||||
//QList, QItem, QItemSection, QItemLabel,
|
||||
QTooltip,
|
||||
QSpinner,
|
||||
QTable, QTh, QTr, QTd,
|
||||
@@ -57,6 +59,8 @@ const components = {
|
||||
QPopupProxy,
|
||||
QDialog,
|
||||
QChip,
|
||||
QTree,
|
||||
//QExpansionItem,
|
||||
};
|
||||
|
||||
//directives
|
||||
|
||||
@@ -2,42 +2,41 @@ import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import _ from 'lodash';
|
||||
|
||||
//немедленная загрузка
|
||||
import CardIndex from './components/CardIndex/CardIndex.vue';
|
||||
//const CardIndex = () => import('./components/CardIndex/CardIndex.vue');
|
||||
|
||||
const CardIndex = () => import('./components/CardIndex/CardIndex.vue');
|
||||
const Search = () => import('./components/CardIndex/Search/Search.vue');
|
||||
const Card = () => import('./components/CardIndex/Card/Card.vue');
|
||||
const Book = () => import('./components/CardIndex/Book/Book.vue');
|
||||
const History = () => import('./components/CardIndex/History/History.vue');
|
||||
|
||||
//немедленная загрузка
|
||||
//const Reader = () => import('./components/Reader/Reader.vue');
|
||||
import Reader from './components/Reader/Reader.vue';
|
||||
//import Reader from './components/Reader/Reader.vue';
|
||||
const Reader = () => import('./components/Reader/Reader.vue');
|
||||
const ExternalLibs = () => import('./components/ExternalLibs/ExternalLibs.vue');
|
||||
|
||||
//const Forum = () => import('./components/Forum/Forum.vue');
|
||||
const Income = () => import('./components/Income/Income.vue');
|
||||
const Sources = () => import('./components/Sources/Sources.vue');
|
||||
const Settings = () => import('./components/Settings/Settings.vue');
|
||||
const Help = () => import('./components/Help/Help.vue');
|
||||
//const NotFound404 = () => import('./components/NotFound404/NotFound404.vue');
|
||||
const NotFound404 = () => import('./components/NotFound404/NotFound404.vue');
|
||||
|
||||
const myRoutes = [
|
||||
['/', null, null, '/cardindex'],
|
||||
['/cardindex', CardIndex ],
|
||||
['/cardindex~search', Search ],
|
||||
['/cardindex~card', Card ],
|
||||
['/cardindex~card/:authorId', Card ],
|
||||
['/cardindex~book', Book ],
|
||||
['/cardindex~book/:bookId', Book ],
|
||||
['/cardindex~history', History ],
|
||||
['/cardindex', CardIndex],
|
||||
['/cardindex~search', Search],
|
||||
['/cardindex~card', Card],
|
||||
['/cardindex~card/:authorId', Card],
|
||||
['/cardindex~book', Book],
|
||||
['/cardindex~book/:bookId', Book],
|
||||
['/cardindex~history', History],
|
||||
|
||||
['/reader', Reader ],
|
||||
['/income', Income ],
|
||||
['/sources', Sources ],
|
||||
['/settings', Settings ],
|
||||
['/help', Help ],
|
||||
['*', null, null, '/cardindex' ],
|
||||
['/reader', Reader],
|
||||
['/external-libs', ExternalLibs],
|
||||
['/income', Income],
|
||||
['/sources', Sources],
|
||||
['/settings', Settings],
|
||||
['/help', Help],
|
||||
['/404', NotFound404],
|
||||
['*', null, null, '/cardindex'],
|
||||
];
|
||||
|
||||
let routes = {};
|
||||
|
||||
@@ -103,47 +103,107 @@ export function fromBase64(data) {
|
||||
));
|
||||
}
|
||||
|
||||
export function getObjDiff(oldObj, newObj) {
|
||||
const result = {__isDiff: true, change: {}, add: {}, del: []};
|
||||
export function getObjDiff(oldObj, newObj, opts = {}) {
|
||||
const {
|
||||
exclude = [],
|
||||
excludeAdd = [],
|
||||
excludeDel = [],
|
||||
} = opts;
|
||||
|
||||
for (const key of Object.keys(oldObj)) {
|
||||
if (newObj.hasOwnProperty(key)) {
|
||||
if (!_.isEqual(oldObj[key], newObj[key])) {
|
||||
if (_.isObject(oldObj[key]) && _.isObject(newObj[key])) {
|
||||
result.change[key] = getObjDiff(oldObj[key], newObj[key]);
|
||||
} else {
|
||||
result.change[key] = _.cloneDeep(newObj[key]);
|
||||
const ex = new Set(exclude);
|
||||
const exAdd = new Set(excludeAdd);
|
||||
const exDel = new Set(excludeDel);
|
||||
|
||||
const makeObjDiff = (oldObj, newObj, keyPath) => {
|
||||
const result = {__isDiff: true, change: {}, add: {}, del: []};
|
||||
|
||||
keyPath = `${keyPath}${keyPath ? '/' : ''}`;
|
||||
|
||||
for (const key of Object.keys(oldObj)) {
|
||||
const kp = `${keyPath}${key}`;
|
||||
|
||||
if (newObj.hasOwnProperty(key)) {
|
||||
if (ex.has(kp))
|
||||
continue;
|
||||
|
||||
if (!_.isEqual(oldObj[key], newObj[key])) {
|
||||
if (_.isObject(oldObj[key]) && _.isObject(newObj[key])) {
|
||||
result.change[key] = makeObjDiff(oldObj[key], newObj[key], kp);
|
||||
} else {
|
||||
result.change[key] = _.cloneDeep(newObj[key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (exDel.has(kp))
|
||||
continue;
|
||||
result.del.push(key);
|
||||
}
|
||||
} else {
|
||||
result.del.push(key);
|
||||
}
|
||||
|
||||
for (const key of Object.keys(newObj)) {
|
||||
const kp = `${keyPath}${key}`;
|
||||
if (exAdd.has(kp))
|
||||
continue;
|
||||
|
||||
if (!oldObj.hasOwnProperty(key)) {
|
||||
result.add[key] = _.cloneDeep(newObj[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
for (const key of Object.keys(newObj)) {
|
||||
if (!oldObj.hasOwnProperty(key)) {
|
||||
result.add[key] = _.cloneDeep(newObj[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return makeObjDiff(oldObj, newObj, '');
|
||||
}
|
||||
|
||||
export function isObjDiff(diff) {
|
||||
return (_.isObject(diff) && diff.__isDiff);
|
||||
return (_.isObject(diff) && diff.__isDiff && diff.change && diff.add && diff.del);
|
||||
}
|
||||
|
||||
export function isEmptyObjDiff(diff) {
|
||||
return (!_.isObject(diff) || !diff.__isDiff ||
|
||||
(!Object.keys(diff.change).length &&
|
||||
!Object.keys(diff.add).length &&
|
||||
!diff.del.length
|
||||
return (!isObjDiff(diff) ||
|
||||
!(Object.keys(diff.change).length ||
|
||||
Object.keys(diff.add).length ||
|
||||
diff.del.length
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function applyObjDiff(obj, diff, isAddChanged) {
|
||||
const result = _.cloneDeep(obj);
|
||||
export function isEmptyObjDiffDeep(diff, opts = {}) {
|
||||
if (!isObjDiff(diff))
|
||||
return true;
|
||||
|
||||
const {
|
||||
isApplyChange = true,
|
||||
isApplyAdd = true,
|
||||
isApplyDel = true,
|
||||
} = opts;
|
||||
|
||||
let notEmptyDeep = false;
|
||||
const change = diff.change;
|
||||
for (const key of Object.keys(change)) {
|
||||
if (_.isObject(change[key]))
|
||||
notEmptyDeep |= !isEmptyObjDiffDeep(change[key], opts);
|
||||
else if (isApplyChange)
|
||||
notEmptyDeep = true;
|
||||
}
|
||||
|
||||
return !(
|
||||
notEmptyDeep ||
|
||||
(isApplyAdd && Object.keys(diff.add).length) ||
|
||||
(isApplyDel && diff.del.length)
|
||||
);
|
||||
}
|
||||
|
||||
export function applyObjDiff(obj, diff, opts = {}) {
|
||||
const {
|
||||
isAddChanged = false,
|
||||
isApplyChange = true,
|
||||
isApplyAdd = true,
|
||||
isApplyDel = true,
|
||||
} = opts;
|
||||
|
||||
let result = _.cloneDeep(obj);
|
||||
if (!diff.__isDiff)
|
||||
return result;
|
||||
|
||||
@@ -151,21 +211,28 @@ export function applyObjDiff(obj, diff, isAddChanged) {
|
||||
for (const key of Object.keys(change)) {
|
||||
if (result.hasOwnProperty(key)) {
|
||||
if (_.isObject(change[key])) {
|
||||
result[key] = applyObjDiff(result[key], change[key], isAddChanged);
|
||||
result[key] = applyObjDiff(result[key], change[key], opts);
|
||||
} else {
|
||||
result[key] = _.cloneDeep(change[key]);
|
||||
if (isApplyChange)
|
||||
result[key] = _.cloneDeep(change[key]);
|
||||
}
|
||||
} else if (isAddChanged) {
|
||||
result[key] = _.cloneDeep(change[key]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of Object.keys(diff.add)) {
|
||||
result[key] = _.cloneDeep(diff.add[key]);
|
||||
if (isApplyAdd) {
|
||||
for (const key of Object.keys(diff.add)) {
|
||||
result[key] = _.cloneDeep(diff.add[key]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of diff.del) {
|
||||
delete result[key];
|
||||
if (isApplyDel && diff.del.length) {
|
||||
for (const key of diff.del) {
|
||||
delete result[key];
|
||||
}
|
||||
if (_.isArray(result))
|
||||
result = result.filter(v => v);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import * as utils from '../../share/utils';
|
||||
|
||||
const readerActions = {
|
||||
'help': 'Вызвать cправку',
|
||||
'loader': 'На страницу загрузки',
|
||||
@@ -10,8 +12,11 @@ const readerActions = {
|
||||
'setPosition': 'Установить позицию',
|
||||
'search': 'Найти в тексте',
|
||||
'copyText': 'Скопировать текст со страницы',
|
||||
'splitToPara': 'Обновить с разбиением на параграфы',
|
||||
'refresh': 'Принудительно обновить книгу',
|
||||
'offlineMode': 'Автономный режим (без интернета)',
|
||||
'contents': 'Оглавление/закладки',
|
||||
'libs': 'Библиотека',
|
||||
'recentBooks': 'Открыть недавние',
|
||||
'switchToolbar': 'Показать/скрыть панель управления',
|
||||
'donate': '',
|
||||
@@ -36,9 +41,12 @@ const toolButtons = [
|
||||
{name: 'setPosition', show: true},
|
||||
{name: 'search', show: true},
|
||||
{name: 'copyText', show: false},
|
||||
{name: 'splitToPara', show: false},
|
||||
{name: 'refresh', show: true},
|
||||
{name: 'offlineMode', show: false},
|
||||
{name: 'contents', show: true},
|
||||
{name: 'libs', show: true},
|
||||
{name: 'recentBooks', show: true},
|
||||
{name: 'offlineMode', show: false},
|
||||
];
|
||||
|
||||
//readerActions[name]
|
||||
@@ -53,9 +61,12 @@ const hotKeys = [
|
||||
{name: 'setPosition', codes: ['P']},
|
||||
{name: 'search', codes: ['Ctrl+F']},
|
||||
{name: 'copyText', codes: ['Ctrl+C']},
|
||||
{name: 'splitToPara', codes: ['Shift+R']},
|
||||
{name: 'refresh', codes: ['R']},
|
||||
{name: 'offlineMode', codes: ['O']},
|
||||
{name: 'contents', codes: ['C']},
|
||||
{name: 'libs', codes: ['L']},
|
||||
{name: 'recentBooks', codes: ['X']},
|
||||
{name: 'offlineMode', codes: ['O']},
|
||||
|
||||
{name: 'switchToolbar', codes: ['Tab', 'Q']},
|
||||
{name: 'bookBegin', codes: ['Home']},
|
||||
@@ -243,6 +254,7 @@ const settingDefaults = {
|
||||
showServerStorageMessages: true,
|
||||
showWhatsNewDialog: true,
|
||||
showDonationDialog2020: true,
|
||||
showLiberamaTopDialog2020: true,
|
||||
enableSitesFilter: true,
|
||||
|
||||
fontShifts: {},
|
||||
@@ -259,6 +271,47 @@ for (const button of toolButtons)
|
||||
for (const hotKey of hotKeys)
|
||||
settingDefaults.userHotKeys[hotKey.name] = hotKey.codes;
|
||||
|
||||
const excludeDiffHotKeys = [];
|
||||
for (const hotKey of hotKeys)
|
||||
excludeDiffHotKeys.push(`userHotKeys/${hotKey.name}`);
|
||||
|
||||
function addDefaultsToSettings(settings) {
|
||||
const diff = utils.getObjDiff(settings, settingDefaults, {exclude: excludeDiffHotKeys});
|
||||
if (!utils.isEmptyObjDiffDeep(diff, {isApplyChange: false})) {
|
||||
return utils.applyObjDiff(settings, diff, {isApplyChange: false});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const libsDefaults = {
|
||||
startLink: 'http://flibusta.is',
|
||||
comment: 'Флибуста | Книжное братство',
|
||||
closeAfterSubmit: false,
|
||||
openInFrameOnEnter: false,
|
||||
openInFrameOnAdd: false,
|
||||
groups: [
|
||||
{r: 'http://flibusta.is', s: 'http://flibusta.is', list: [
|
||||
{l: 'http://flibusta.is', c: 'Флибуста | Книжное братство'},
|
||||
]},
|
||||
{r: 'https://flibs.in', s: 'https://flibs.in', list: [
|
||||
{l: 'https://flibs.in', c: 'Flibs'},
|
||||
]},
|
||||
{r: 'http://fantasy-worlds.org', s: 'http://fantasy-worlds.org', list: [
|
||||
{l: 'http://fantasy-worlds.org', c: 'Миры Фэнтези'},
|
||||
]},
|
||||
{r: 'http://samlib.ru', s: 'http://samlib.ru', list: [
|
||||
{l: 'http://samlib.ru', c: 'Журнал "Самиздат"'},
|
||||
]},
|
||||
{r: 'http://lib.ru', s: 'http://lib.ru', list: [
|
||||
{l: 'http://lib.ru', c: 'Библиотека Максима Мошкова'},
|
||||
]},
|
||||
{r: 'https://aldebaran.ru', s: 'https://aldebaran.ru', list: [
|
||||
{l: 'https://aldebaran.ru', c: 'АЛЬДЕБАРАН | Электронная библиотека книг'},
|
||||
]},
|
||||
]
|
||||
};
|
||||
|
||||
// initial state
|
||||
const state = {
|
||||
toolBarActive: true,
|
||||
@@ -272,6 +325,8 @@ const state = {
|
||||
currentProfile: '',
|
||||
settings: Object.assign({}, settingDefaults),
|
||||
settingsRev: {},
|
||||
libs: Object.assign({}, libsDefaults),
|
||||
libsRev: 0,
|
||||
};
|
||||
|
||||
// getters
|
||||
@@ -310,11 +365,23 @@ const mutations = {
|
||||
state.currentProfile = value;
|
||||
},
|
||||
setSettings(state, value) {
|
||||
state.settings = Object.assign({}, state.settings, value);
|
||||
const newSettings = Object.assign({}, state.settings, value);
|
||||
const added = addDefaultsToSettings(newSettings);
|
||||
if (added) {
|
||||
state.settings = added;
|
||||
} else {
|
||||
state.settings = newSettings;
|
||||
}
|
||||
},
|
||||
setSettingsRev(state, value) {
|
||||
state.settingsRev = Object.assign({}, state.settingsRev, value);
|
||||
},
|
||||
setLibs(state, value) {
|
||||
state.libs = value;
|
||||
},
|
||||
setLibsRev(state, value) {
|
||||
state.libsRev = value;
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -324,6 +391,8 @@ export default {
|
||||
fonts,
|
||||
webFonts,
|
||||
settingDefaults,
|
||||
addDefaultsToSettings,
|
||||
libsDefaults,
|
||||
|
||||
namespaced: true,
|
||||
state,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo -H -u www-data bash -c "\
|
||||
while true; do\
|
||||
trap '' 2;\
|
||||
cd /var/www;\
|
||||
/home/beta.liberama/liberama;\
|
||||
trap 2;\
|
||||
echo \"Restart after 5 sec. Press Ctrl+C to exit.\";\
|
||||
sleep 5;\
|
||||
done;"
|
||||
85
docs/beta/beta.liberama
Normal file
@@ -0,0 +1,85 @@
|
||||
server {
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/beta.liberama.top/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/beta.liberama.top/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
server_name beta.liberama.top;
|
||||
|
||||
client_max_body_size 50m;
|
||||
proxy_read_timeout 1h;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types *;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:34082;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:34082;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location / {
|
||||
root /home/beta.liberama/public;
|
||||
|
||||
location /tmp {
|
||||
types { } default_type "application/xml; charset=utf-8";
|
||||
add_header Content-Encoding gzip;
|
||||
}
|
||||
|
||||
location ~* \.(?:manifest|appcache|html)$ {
|
||||
expires -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name beta.liberama.top;
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name b.beta.liberama.top;
|
||||
|
||||
client_max_body_size 50m;
|
||||
proxy_read_timeout 1h;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types *;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:34082;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:34082;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location / {
|
||||
root /home/beta.liberama/public;
|
||||
|
||||
location /tmp {
|
||||
types { } default_type "application/xml; charset=utf-8";
|
||||
add_header Content-Encoding gzip;
|
||||
}
|
||||
|
||||
location ~* \.(?:manifest|appcache|html)$ {
|
||||
expires -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
docs/beta/run_server.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo -H -u www-data /home/beta.liberama/liberama
|
||||
143
docs/liberama.top/liberama
Normal file
@@ -0,0 +1,143 @@
|
||||
server {
|
||||
server_name _;
|
||||
listen 80 default_server;
|
||||
listen 443 ssl default_server;
|
||||
|
||||
#openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
|
||||
ssl_certificate /etc/nginx/ssl/nginx.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/nginx.key;
|
||||
return 403;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/liberama.top/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/liberama.top/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
server_name liberama.top;
|
||||
|
||||
client_max_body_size 50m;
|
||||
proxy_read_timeout 1h;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types *;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:55081;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:55081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location / {
|
||||
root /home/liberama/public;
|
||||
|
||||
location /tmp {
|
||||
types { } default_type "application/xml; charset=utf-8";
|
||||
add_header Content-Encoding gzip;
|
||||
}
|
||||
|
||||
location ~* \.(?:manifest|appcache|html)$ {
|
||||
expires -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name liberama.top;
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name b.liberama.top;
|
||||
|
||||
client_max_body_size 50m;
|
||||
proxy_read_timeout 1h;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types *;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:55081;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:55081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location / {
|
||||
root /home/liberama/public;
|
||||
|
||||
location /tmp {
|
||||
types { } default_type "application/xml; charset=utf-8";
|
||||
add_header Content-Encoding gzip;
|
||||
}
|
||||
|
||||
location ~* \.(?:manifest|appcache|html)$ {
|
||||
expires -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 23480;
|
||||
server_name flibusta_proxy;
|
||||
|
||||
valid_referers liberama.top b.liberama.top;
|
||||
|
||||
if ($invalid_referer) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://flibusta.is;
|
||||
proxy_redirect http://static.flibusta.is:443 http://b.liberama.top:23481;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 23481;
|
||||
server_name flibusta_proxy_static;
|
||||
|
||||
valid_referers liberama.top b.liberama.top;
|
||||
|
||||
if ($invalid_referer) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://static.flibusta.is:443;
|
||||
proxy_set_header Referer "";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 23580;
|
||||
server_name fw_proxy;
|
||||
|
||||
valid_referers liberama.top b.liberama.top;
|
||||
|
||||
if ($invalid_referer) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://fantasy-worlds.org;
|
||||
}
|
||||
}
|
||||
@@ -39,11 +39,11 @@ sudo apt install poppler-utils
|
||||
```
|
||||
|
||||
### nginx, server config
|
||||
Для своего домена необходимо будет подправить docs/omnireader/omnireader.
|
||||
Для своего домена необходимо будет подправить docs/omnireader.ru/omnireader.
|
||||
Можно также настроить сервер для HTTP, без SSL.
|
||||
```
|
||||
sudo apt install nginx
|
||||
sudo cp docs/omnireader/omnireader /etc/nginx/sites-available/omnireader
|
||||
sudo cp docs/omnireader.ru/omnireader /etc/nginx/sites-available/omnireader
|
||||
sudo ln -s /etc/nginx/sites-available/omnireader /etc/nginx/sites-enabled/omnireader
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
sudo service nginx reload
|
||||
@@ -59,14 +59,20 @@ sudo service php7.2-fpm restart
|
||||
|
||||
sudo mkdir /home/oldreader
|
||||
sudo chown www-data.www-data /home/oldreader
|
||||
sudo -u www-data cp -r docs/omnireader/old/* /home/oldreader
|
||||
sudo -u www-data cp -r docs/omnireader.ru/old/* /home/oldreader
|
||||
```
|
||||
|
||||
## Запуск по крону
|
||||
```
|
||||
* * * * * /root/liberama/docs/omnireader.ru/cron_server.sh
|
||||
```
|
||||
|
||||
## Деплой и запуск
|
||||
```
|
||||
cd docs/omnireader
|
||||
cd docs/omnireader.ru
|
||||
./stop_server.sh
|
||||
./deploy.sh
|
||||
./run_server.sh
|
||||
./start_server.sh
|
||||
```
|
||||
|
||||
После первого запуска будет создан конфигурационный файл `/home/liberama/data/config.json`.
|
||||
@@ -81,4 +87,4 @@ cd docs/omnireader
|
||||
}
|
||||
]
|
||||
```
|
||||
и перезапустить `run_server.sh`
|
||||
и перезапустить сервер
|
||||
8
docs/omnireader.ru/cron_server.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! pgrep -x "liberama" > /dev/null ; then
|
||||
sudo -H -u www-data /home/liberama/liberama
|
||||
else
|
||||
echo "Process 'liberama' already running"
|
||||
fi
|
||||
|
||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
4
docs/omnireader.ru/start_server.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo -H -u www-data /home/liberama/liberama &
|
||||
sudo service cron start
|
||||
4
docs/omnireader.ru/stop_server.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo service cron stop
|
||||
sudo killall liberama
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo -H -u www-data bash -c "\
|
||||
while true; do\
|
||||
trap '' 2;\
|
||||
cd /var/www;\
|
||||
/home/liberama/liberama;\
|
||||
trap 2;\
|
||||
echo \"Restart after 5 sec. Press Ctrl+C to exit.\";\
|
||||
sleep 5;\
|
||||
done;"
|
||||
181
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Liberama",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.8",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -36,12 +36,6 @@
|
||||
"pkg-up": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001062",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz",
|
||||
"integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.446",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz",
|
||||
@@ -321,12 +315,6 @@
|
||||
"pkg-up": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001062",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz",
|
||||
"integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.446",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz",
|
||||
@@ -1603,12 +1591,6 @@
|
||||
"pkg-up": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001062",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz",
|
||||
"integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.446",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz",
|
||||
@@ -4017,9 +3999,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30000989",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000989.tgz",
|
||||
"integrity": "sha512-vrMcvSuMz16YY6GSVZ0dWDTJP8jqk3iFQ/Aq5iqblPwxSVVZI+zxDyTX0VPqtQsDnfdrBDcsmhgTEOh5R8Lbpw==",
|
||||
"version": "1.0.30001154",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001154.tgz",
|
||||
"integrity": "sha512-y9DvdSti8NnYB9Be92ddMZQrcOe04kcQtcxtBx4NkB04+qZ+JUWotnXBJTmxlKudhxNTQ3RRknMwNU2YQl/Org==",
|
||||
"dev": true
|
||||
},
|
||||
"caseless": {
|
||||
@@ -4373,6 +4355,11 @@
|
||||
"simple-swizzle": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"colorette": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
|
||||
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
@@ -4759,12 +4746,6 @@
|
||||
"pkg-up": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001062",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz",
|
||||
"integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.446",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz",
|
||||
@@ -8696,6 +8677,11 @@
|
||||
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
|
||||
"dev": true
|
||||
},
|
||||
"klona": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/klona/-/klona-2.0.4.tgz",
|
||||
"integrity": "sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA=="
|
||||
},
|
||||
"last-call-webpack-plugin": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/last-call-webpack-plugin/-/last-call-webpack-plugin-3.0.0.tgz",
|
||||
@@ -8790,6 +8776,30 @@
|
||||
"immediate": "~3.0.5"
|
||||
}
|
||||
},
|
||||
"line-column": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/line-column/-/line-column-1.0.2.tgz",
|
||||
"integrity": "sha1-0lryk2tvSEkXKzEuR5LR2Ye8NKI=",
|
||||
"requires": {
|
||||
"isarray": "^1.0.0",
|
||||
"isobject": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"isobject": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
|
||||
"integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
|
||||
"requires": {
|
||||
"isarray": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"loader-runner": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz",
|
||||
@@ -9372,6 +9382,11 @@
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
|
||||
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
|
||||
},
|
||||
"nanoid": {
|
||||
"version": "3.1.16",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.16.tgz",
|
||||
"integrity": "sha512-+AK8MN0WHji40lj8AEuwLOvLSbWYApQpre/aFJZD71r43wVRLrOYS4FmJOPQYon1TqB462RzrrxlfA74XRES8w=="
|
||||
},
|
||||
"nanomatch": {
|
||||
"version": "1.2.13",
|
||||
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||
@@ -10010,6 +10025,11 @@
|
||||
"integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=",
|
||||
"dev": true
|
||||
},
|
||||
"parse-srcset": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz",
|
||||
"integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE="
|
||||
},
|
||||
"parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
@@ -12597,9 +12617,9 @@
|
||||
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
|
||||
},
|
||||
"quasar": {
|
||||
"version": "1.11.3",
|
||||
"resolved": "https://registry.npmjs.org/quasar/-/quasar-1.11.3.tgz",
|
||||
"integrity": "sha512-ZlWNn7nfo7dgh8pmhdYB5Jn9Sv/mFsYfoY0K/hYrCE/mJq2ZYWHTVCAFqbp1MEirbSz4RcRXu5kMa+sf/v/uAg=="
|
||||
"version": "1.14.3",
|
||||
"resolved": "https://registry.npmjs.org/quasar/-/quasar-1.14.3.tgz",
|
||||
"integrity": "sha512-0baTygeaRhrOK9e+mtc32i6+xOnPKXaplgELJJdGWeoQBCwwfUX0tah0fgUmrdOEft3XmwhYW0a9yv/TAPUz7A=="
|
||||
},
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
@@ -13306,6 +13326,97 @@
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sanitize-html": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.1.1.tgz",
|
||||
"integrity": "sha512-yb+I+K25cn6PzsRJb+kGdlOBC3SkvEwJrr/Xl+6YR42oDZDeu61yWeEMSEi0hCKlRSYlWWE4tUnF2Ds+c/M1Vg==",
|
||||
"requires": {
|
||||
"deepmerge": "^4.2.2",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"htmlparser2": "^4.1.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"klona": "^2.0.3",
|
||||
"parse-srcset": "^1.0.2",
|
||||
"postcss": "^8.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dom-serializer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.1.0.tgz",
|
||||
"integrity": "sha512-ox7bvGXt2n+uLWtCRLybYx60IrOlWL/aCebWJk1T0d4m3y2tzf4U3ij9wBMUb6YJZpz06HCCYuyCDveE2xXmzQ==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0",
|
||||
"entities": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"domelementtype": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.2.tgz",
|
||||
"integrity": "sha512-wFwTwCVebUrMgGeAwRL/NhZtHAUyT9n9yg4IMDwf10+6iCMxSkVq9MGCVEH+QZWo1nNidy8kNvwmv4zWHDTqvA=="
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz",
|
||||
"integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.2.tgz",
|
||||
"integrity": "sha512-NKbgaM8ZJOecTZsIzW5gSuplsX2IWW2mIK7xVr8hTQF2v1CJWTmLZ1HOCh5sH+IzVPAGE5IucooOkvwBRAdowA==",
|
||||
"requires": {
|
||||
"dom-serializer": "^1.0.1",
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"entities": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz",
|
||||
"integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w=="
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz",
|
||||
"integrity": "sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0",
|
||||
"domutils": "^2.0.0",
|
||||
"entities": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
|
||||
},
|
||||
"postcss": {
|
||||
"version": "8.1.4",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.1.4.tgz",
|
||||
"integrity": "sha512-LfqcwgMq9LOd8pX7K2+r2HPitlIGC5p6PoZhVELlqhh2YGDVcXKpkCseqan73Hrdik6nBd2OvoDPUaP/oMj9hQ==",
|
||||
"requires": {
|
||||
"colorette": "^1.2.1",
|
||||
"line-column": "^1.0.2",
|
||||
"nanoid": "^3.1.15",
|
||||
"source-map": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
@@ -15193,6 +15304,14 @@
|
||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.1.6.tgz",
|
||||
"integrity": "sha512-GYhn2ynaZlysZMkFE5oCHRUTqE8BWs/a9YbKpNLi0i7xD6KG1EzDqpHQmv1F5gXjr8kL5iIVS8EOtRaVUEXTqA=="
|
||||
},
|
||||
"vue-sanitize": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/vue-sanitize/-/vue-sanitize-0.2.1.tgz",
|
||||
"integrity": "sha512-MhrfAaAqIQ8JXWfdlhK6f+H2WnZ7KQwkOgLNeUyfACI2bq/3HPZ2zeUQDathnLdsXMXAa8pJehOgPYtlaG9Jew==",
|
||||
"requires": {
|
||||
"sanitize-html": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"vue-style-loader": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Liberama",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.8",
|
||||
"author": "Book Pauk <bookpauk@gmail.com>",
|
||||
"license": "CC0-1.0",
|
||||
"repository": "bookpauk/liberama",
|
||||
@@ -72,7 +72,7 @@
|
||||
"multer": "^1.4.2",
|
||||
"pako": "^1.0.11",
|
||||
"path-browserify": "^1.0.0",
|
||||
"quasar": "^1.11.3",
|
||||
"quasar": "^1.14.3",
|
||||
"safe-buffer": "^5.2.0",
|
||||
"sjcl": "^1.0.8",
|
||||
"sql-template-strings": "^2.2.2",
|
||||
@@ -81,6 +81,7 @@
|
||||
"unbzip2-stream": "^1.3.3",
|
||||
"vue": "github:bookpauk/vue",
|
||||
"vue-router": "^3.1.6",
|
||||
"vue-sanitize": "^0.2.1",
|
||||
"vuex": "^3.1.2",
|
||||
"vuex-persistedstate": "^2.7.1",
|
||||
"webdav": "^2.10.2",
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
loggingEnabled: true,
|
||||
|
||||
maxUploadFileSize: 50*1024*1024,//50Мб
|
||||
maxTempPublicDirSize: 512*1024*1024,//512Мб
|
||||
maxTempPublicDirSize: 512*1024*1024,//512Мб + 20% квота если проблема с remoteWebDavStorage
|
||||
maxUploadPublicDirSize: 200*1024*1024,//100Мб
|
||||
|
||||
useExternalBookConverter: false,
|
||||
|
||||
@@ -19,7 +19,9 @@ class ReaderController extends BaseController {
|
||||
throw new Error(`key 'url' is empty`);
|
||||
const workerId = this.readerWorker.loadBookUrl({
|
||||
url: request.url,
|
||||
enableSitesFilter: (request.hasOwnProperty('enableSitesFilter') ? request.enableSitesFilter : true)
|
||||
enableSitesFilter: (request.hasOwnProperty('enableSitesFilter') ? request.enableSitesFilter : true),
|
||||
skipCheck: (request.hasOwnProperty('skipCheck') ? request.skipCheck : false),
|
||||
isText: (request.hasOwnProperty('isText') ? request.isText : false),
|
||||
});
|
||||
const state = this.workerState.getState(workerId);
|
||||
return (state ? state : {});
|
||||
|
||||
@@ -119,14 +119,19 @@ class FileDecompressor {
|
||||
try {
|
||||
return await zip.unpack(filename, outputDir, {
|
||||
limitFileSize: this.limitFileSize,
|
||||
limitFileCount: 1000
|
||||
});
|
||||
limitFileCount: 1000,
|
||||
decodeEntryNameCallback: (nameRaw) => {
|
||||
return utils.bufferRemoveZeroes(nameRaw);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
fs.emptyDir(outputDir);
|
||||
return await zip.unpack(filename, outputDir, {
|
||||
limitFileSize: this.limitFileSize,
|
||||
limitFileCount: 1000,
|
||||
decodeEntryNameCallback: (nameRaw) => {
|
||||
nameRaw = utils.bufferRemoveZeroes(nameRaw);
|
||||
const enc = textUtils.getEncodingLite(nameRaw);
|
||||
if (enc.indexOf('ISO-8859') < 0) {
|
||||
return iconv.decode(nameRaw, enc);
|
||||
|
||||
@@ -200,7 +200,7 @@ class ConvertHtml extends ConvertBase {
|
||||
|
||||
titleInfo['book-title'] = title;
|
||||
//подозрение на чистый текст, надо разбить на параграфы
|
||||
if (isText || pars.length < buf.length/2000) {
|
||||
if (isText || (buf.length > 30*1024 && pars.length < buf.length/2000)) {
|
||||
let total = 0;
|
||||
let count = 1;
|
||||
for (let i = 0; i < spaceCounter.length; i++) {
|
||||
|
||||
@@ -266,30 +266,38 @@ class ReaderWorker {
|
||||
files.push({name, stat});
|
||||
}
|
||||
}
|
||||
log(`clean dir ${dir}, maxSize=${maxSize}, found ${files.length} files`);
|
||||
log(`clean dir ${dir}, maxSize=${maxSize}, found ${files.length} files, total size=${size}`);
|
||||
|
||||
files.sort((a, b) => a.stat.mtimeMs - b.stat.mtimeMs);
|
||||
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
while (i < files.length && size > maxSize) {
|
||||
const file = files[i];
|
||||
const oldFile = `${dir}/${file.name}`;
|
||||
|
||||
let remoteSuccess = true;
|
||||
//отправляем только this.config.tempPublicDir
|
||||
//TODO: убрать в будущем, т.к. уже делается ленивое сохранение compFilename в удаленном хранилище
|
||||
if (this.remoteWebDavStorage && dir === this.config.tempPublicDir) {
|
||||
remoteSuccess = false;
|
||||
try {
|
||||
//log(`remoteWebDavStorage.putFile ${path.basename(oldFile)}`);
|
||||
await this.remoteWebDavStorage.putFile(oldFile);
|
||||
remoteSuccess = true;
|
||||
} catch (e) {
|
||||
log(LM_ERR, e.stack);
|
||||
}
|
||||
}
|
||||
await fs.remove(oldFile);
|
||||
//реально удаляем только если сохранили в хранилище
|
||||
if (remoteSuccess || size > maxSize*1.2) {
|
||||
await fs.remove(oldFile);
|
||||
j++;
|
||||
}
|
||||
|
||||
size -= file.stat.size;
|
||||
i++;
|
||||
}
|
||||
log(`removed ${i} files`);
|
||||
log(`removed ${j} files`);
|
||||
} catch(e) {
|
||||
log(LM_ERR, e.stack);
|
||||
} finally {
|
||||
|
||||
@@ -766,7 +766,7 @@ ZipEntry.prototype.readDataHeader = function(data) {
|
||||
};
|
||||
|
||||
ZipEntry.prototype.read = function(data, offset) {
|
||||
this.nameRaw = data.slice(offset, offset += this.fnameLen);
|
||||
this.nameRaw = Buffer.from(data.slice(offset, offset += this.fnameLen));
|
||||
this.name = this.nameRaw.toString();
|
||||
var lastChar = data[offset - 1];
|
||||
this.isDirectory = (lastChar == 47) || (lastChar == 92);
|
||||
|
||||
@@ -93,6 +93,12 @@ function parseSync(xstr, options) {
|
||||
}
|
||||
tag = tag.toLowerCase();
|
||||
|
||||
if (innerCut.has(tag) && (!cutCounter || cutTag === tag)) {
|
||||
if (!cutCounter)
|
||||
cutTag = tag;
|
||||
cutCounter++;
|
||||
}
|
||||
|
||||
let endTag = (singleTag ? tag : '');
|
||||
if (tag === '' || tag[0] !== '/') {
|
||||
_onStartNode(tag, tail, singleTag, cutCounter, cutTag);
|
||||
@@ -103,12 +109,6 @@ function parseSync(xstr, options) {
|
||||
if (endTag)
|
||||
_onEndNode(endTag, tail, singleTag, cutCounter, cutTag);
|
||||
|
||||
if (innerCut.has(tag) && (!cutCounter || cutTag === tag)) {
|
||||
if (!cutCounter)
|
||||
cutTag = tag;
|
||||
cutCounter++;
|
||||
}
|
||||
|
||||
if (cutTag === endTag) {
|
||||
cutCounter = (cutCounter > 0 ? cutCounter - 1 : 0);
|
||||
if (!cutCounter)
|
||||
@@ -125,9 +125,9 @@ function parseSync(xstr, options) {
|
||||
|
||||
if (i < len) {
|
||||
if (inCdata) {
|
||||
_onCdata(xstr.substr(leftData, len - leftData), cutCounter, cutTag);
|
||||
_onCdata(xstr.substr(leftData + 1, len - leftData - 1), cutCounter, cutTag);
|
||||
} else if (inComment) {
|
||||
_onComment(xstr.substr(leftData, len - leftData), cutCounter, cutTag);
|
||||
_onComment(xstr.substr(leftData + 1, len - leftData - 1), cutCounter, cutTag);
|
||||
} else {
|
||||
_onTextNode(xstr.substr(i, len - i), cutCounter, cutTag);
|
||||
}
|
||||
@@ -233,6 +233,12 @@ async function parse(xstr, options) {
|
||||
}
|
||||
tag = tag.toLowerCase();
|
||||
|
||||
if (innerCut.has(tag) && (!cutCounter || cutTag === tag)) {
|
||||
if (!cutCounter)
|
||||
cutTag = tag;
|
||||
cutCounter++;
|
||||
}
|
||||
|
||||
let endTag = (singleTag ? tag : '');
|
||||
if (tag === '' || tag[0] !== '/') {
|
||||
await _onStartNode(tag, tail, singleTag, cutCounter, cutTag);
|
||||
@@ -243,12 +249,6 @@ async function parse(xstr, options) {
|
||||
if (endTag)
|
||||
await _onEndNode(endTag, tail, singleTag, cutCounter, cutTag);
|
||||
|
||||
if (innerCut.has(tag) && (!cutCounter || cutTag === tag)) {
|
||||
if (!cutCounter)
|
||||
cutTag = tag;
|
||||
cutCounter++;
|
||||
}
|
||||
|
||||
if (cutTag === endTag) {
|
||||
cutCounter = (cutCounter > 0 ? cutCounter - 1 : 0);
|
||||
if (!cutCounter)
|
||||
@@ -265,9 +265,9 @@ async function parse(xstr, options) {
|
||||
|
||||
if (i < len) {
|
||||
if (inCdata) {
|
||||
await _onCdata(xstr.substr(leftData, len - leftData), cutCounter, cutTag);
|
||||
await _onCdata(xstr.substr(leftData + 1, len - leftData - 1), cutCounter, cutTag);
|
||||
} else if (inComment) {
|
||||
await _onComment(xstr.substr(leftData, len - leftData), cutCounter, cutTag);
|
||||
await _onComment(xstr.substr(leftData + 1, len - leftData - 1), cutCounter, cutTag);
|
||||
} else {
|
||||
await _onTextNode(xstr.substr(i, len - i), cutCounter, cutTag);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,14 @@ function fromBase36(data) {
|
||||
return bs36.decode(data);
|
||||
}
|
||||
|
||||
function bufferRemoveZeroes(buf) {
|
||||
const i = buf.indexOf(0);
|
||||
if (i >= 0) {
|
||||
return buf.slice(0, i);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
function getFileHash(filename, hashName, enc) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const hash = crypto.createHash(hashName);
|
||||
@@ -86,6 +94,7 @@ function spawnProcess(cmd, opts) {
|
||||
module.exports = {
|
||||
toBase36,
|
||||
fromBase36,
|
||||
bufferRemoveZeroes,
|
||||
getFileHash,
|
||||
sleep,
|
||||
randomHexString,
|
||||
|
||||