Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd1dd54b99 | ||
|
|
32cbb2a82c | ||
|
|
048b7c08ca | ||
|
|
d98251e34a | ||
|
|
1eea4e8fc1 | ||
|
|
da330bc615 | ||
|
|
1134250954 | ||
|
|
d8fddd4128 | ||
|
|
42656cd690 | ||
|
|
746f9517d9 | ||
|
|
2a373de5f5 | ||
|
|
b507f00929 | ||
|
|
aea8a254bf | ||
|
|
4247665ba4 | ||
|
|
d59d0a6a42 | ||
|
|
8d40ed0bda | ||
|
|
67bc893e22 | ||
|
|
0f5d3b34a5 | ||
|
|
39b577e935 | ||
|
|
91380d2aed | ||
|
|
f995c24264 | ||
|
|
c7db0ec643 | ||
|
|
f9e000034f | ||
|
|
8ddd2d6290 | ||
|
|
f6c8666f06 | ||
|
|
1bf173fcae | ||
|
|
696866f065 | ||
|
|
c82283c7f0 | ||
|
|
0e62f25557 | ||
|
|
e2c51f44bf | ||
|
|
d4768392a6 | ||
|
|
580744819d | ||
|
|
959794de10 | ||
|
|
3a32c09feb | ||
|
|
09bfce4590 | ||
|
|
092697a4b2 | ||
|
|
a36de9424e | ||
|
|
db4bc2afb2 | ||
|
|
73bfc07082 | ||
|
|
b3cf88aac3 | ||
|
|
69bcc61a01 | ||
|
|
bdc124052c | ||
|
|
cfcee9eb99 | ||
|
|
e93c873c17 | ||
|
|
2b1bb6a299 | ||
|
|
3d7c039fd4 | ||
|
|
9971f1d4bf | ||
|
|
59702d3d50 | ||
|
|
736e6ec075 | ||
|
|
abdd6d4142 | ||
|
|
16edc85e39 | ||
|
|
bbeb92a9da | ||
|
|
daaf9ac70b | ||
|
|
0805353a9e | ||
|
|
594ff954b1 | ||
|
|
cf5203687e | ||
|
|
55ad2d664d | ||
|
|
4d1485a61f | ||
|
|
f260378c93 | ||
|
|
08f9175705 | ||
|
|
ca7cc322d7 | ||
|
|
a631befdf9 | ||
|
|
b7875644bc | ||
|
|
9d8507a1e4 | ||
|
|
50042aa36d | ||
|
|
d21cf6286a | ||
|
|
b0709abfa2 | ||
|
|
dedb729dfe | ||
|
|
27e2f26d5d | ||
|
|
ae30c3865d | ||
|
|
b3453af0fe | ||
|
|
550dcbc081 | ||
|
|
5af1f81bc3 | ||
|
|
d306f972cc | ||
|
|
0f6747f2db | ||
|
|
559b96d56f | ||
|
|
69606429b8 | ||
|
|
824fe68194 | ||
|
|
b056feda59 | ||
|
|
32635dedb0 | ||
|
|
835f9374f6 | ||
|
|
edece5e17f | ||
|
|
298317d352 | ||
|
|
c7637eb941 | ||
|
|
c8f9e0ac9d | ||
|
|
3e3f259920 | ||
|
|
c88baf3c2c | ||
|
|
0d27dabd62 | ||
|
|
5c29594b3d | ||
|
|
1e71d0ae2f |
@@ -6,7 +6,7 @@ const api = axios.create({
|
|||||||
|
|
||||||
class Misc {
|
class Misc {
|
||||||
async loadConfig() {
|
async loadConfig() {
|
||||||
const response = await api.post('/config', {params: ['name', 'version', 'mode']});
|
const response = await api.post('/config', {params: ['name', 'version', 'mode', 'maxUploadFileSize', 'branch']});
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {sleep} from '../share/utils';
|
import {sleep} from '../share/utils';
|
||||||
|
|
||||||
const maxFileUploadSize = 50*1024*1024;
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: '/api/reader'
|
baseURL: '/api/reader'
|
||||||
});
|
});
|
||||||
@@ -75,9 +74,11 @@ class Reader {
|
|||||||
return await axios.get(url, options);
|
return await axios.get(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(file, callback) {
|
async uploadFile(file, maxUploadFileSize, callback) {
|
||||||
if (file.size > maxFileUploadSize)
|
if (!maxUploadFileSize)
|
||||||
throw new Error(`Размер файла превышает ${maxFileUploadSize} байт`);
|
maxUploadFileSize = 10*1024*1024;
|
||||||
|
if (file.size > maxUploadFileSize)
|
||||||
|
throw new Error(`Размер файла превышает ${maxUploadFileSize} байт`);
|
||||||
|
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class App extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//yandex-метрика для omnireader
|
//yandex-метрика для omnireader
|
||||||
if (this.mode == 'omnireader' && !this.yaMetricsDone) {
|
if (this.config.branch == 'production' && this.mode == 'omnireader' && !this.yaMetricsDone) {
|
||||||
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||||||
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||||||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");// eslint-disable-line no-unexpected-multiline
|
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");// eslint-disable-line no-unexpected-multiline
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<li>кэширование файлов книг на клиенте и на сервере</li>
|
<li>кэширование файлов книг на клиенте и на сервере</li>
|
||||||
<li>открытие книг с локального диска</li>
|
<li>открытие книг с локального диска</li>
|
||||||
<li>плавный скроллинг текста</li>
|
<li>плавный скроллинг текста</li>
|
||||||
<li>анимация перелистывания (скоро)</li>
|
<li>анимация перелистывания</li>
|
||||||
<li>поиск по тексту и копирование фрагмента</li>
|
<li>поиск по тексту и копирование фрагмента</li>
|
||||||
<li>запоминание недавних книг, скачивание книги из читалки в формате fb2</li>
|
<li>запоминание недавних книг, скачивание книги из читалки в формате fb2</li>
|
||||||
<li>управление кликом и с клавиатуры</li>
|
<li>управление кликом и с клавиатуры</li>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><b>F1, H</b> - открыть справку</li>
|
<li><b>F1, H</b> - открыть справку</li>
|
||||||
<li><b>Escape</b> - показать/скрыть страницу загрузки</li>
|
<li><b>Escape</b> - показать/скрыть страницу загрузки</li>
|
||||||
<li><b>Tab</b> - показать/скрыть панель управления</li>
|
<li><b>Tab, Q</b> - показать/скрыть панель управления</li>
|
||||||
<li><b>PageUp, Left, Shift+Space, Backspace</b> - страницу назад</li>
|
<li><b>PageUp, Left, Shift+Space, Backspace</b> - страницу назад</li>
|
||||||
<li><b>PageDown, Right, Space</b> - страницу вперед</li>
|
<li><b>PageDown, Right, Space</b> - страницу вперед</li>
|
||||||
<li><b>Home</b> - в начало книги</li>
|
<li><b>Home</b> - в начало книги</li>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<li><b>ПКМ</b> - показать/скрыть панель управления</li>
|
<li><b>ПКМ</b> - показать/скрыть панель управления</li>
|
||||||
<li><b>СКМ</b> - вкл./выкл. плавный скроллинг текста</li>
|
<li><b>СКМ</b> - вкл./выкл. плавный скроллинг текста</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
* Для управления с помощью мыши/тачпада необходимо установить галочку "Включить управление кликом" в настройках
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,10 @@ class HistoryPage extends Vue {
|
|||||||
updateTableData() {
|
updateTableData() {
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
for (let bookKey in bookManager.recent) {
|
const sorted = bookManager.getSortedRecent();
|
||||||
const book = bookManager.recent[bookKey];
|
const len = (sorted.length < 100 ? sorted.length : 100);
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const book = sorted[i];
|
||||||
let d = new Date();
|
let d = new Date();
|
||||||
d.setTime(book.touchTime);
|
d.setTime(book.touchTime);
|
||||||
const t = formatDate(d).split(' ');
|
const t = formatDate(d).split(' ');
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ class LoaderPage extends Vue {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.type == 'keydown' && (document.activeElement !== input && event.code == 'KeyQ')) {
|
||||||
|
this.$emit('tool-bar-toggle');
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -133,12 +133,16 @@ export default @Component({
|
|||||||
this.loadBook({url: newValue, bookPos: this.routeParamPos});
|
this.loadBook({url: newValue, bookPos: this.routeParamPos});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
settings: function(newValue) {
|
settings: function() {
|
||||||
this.allowUrlParamBookPos = newValue.allowUrlParamBookPos;
|
this.loadSettings();
|
||||||
this.copyFullText = newValue.copyFullText;
|
|
||||||
this.showClickMapPage = newValue.showClickMapPage;
|
|
||||||
this.updateRoute();
|
this.updateRoute();
|
||||||
},
|
},
|
||||||
|
loaderActive: function(newValue) {
|
||||||
|
const recent = this.mostRecentBook();
|
||||||
|
if (!newValue && !this.loading && recent && !bookManager.hasBookParsed(recent)) {
|
||||||
|
this.loadBook(recent);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
class Reader extends Vue {
|
class Reader extends Vue {
|
||||||
@@ -168,6 +172,7 @@ class Reader extends Vue {
|
|||||||
this.commit = this.$store.commit;
|
this.commit = this.$store.commit;
|
||||||
this.dispatch = this.$store.dispatch;
|
this.dispatch = this.$store.dispatch;
|
||||||
this.reader = this.$store.state.reader;
|
this.reader = this.$store.state.reader;
|
||||||
|
this.config = this.$store.state.config;
|
||||||
|
|
||||||
this.$root.addKeyHook(this.keyHook);
|
this.$root.addKeyHook(this.keyHook);
|
||||||
|
|
||||||
@@ -179,7 +184,7 @@ class Reader extends Vue {
|
|||||||
|
|
||||||
this.debouncedSetRecentBook = _.debounce(async(newValue) => {
|
this.debouncedSetRecentBook = _.debounce(async(newValue) => {
|
||||||
const recent = this.mostRecentBook();
|
const recent = this.mostRecentBook();
|
||||||
if (recent && recent.bookPos != newValue) {
|
if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
|
||||||
await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
|
await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
|
||||||
|
|
||||||
if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue))
|
if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue))
|
||||||
@@ -191,9 +196,7 @@ class Reader extends Vue {
|
|||||||
this.fullScreenActive = (document.fullscreenElement !== null);
|
this.fullScreenActive = (document.fullscreenElement !== null);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.allowUrlParamBookPos = this.settings.allowUrlParamBookPos;
|
this.loadSettings();
|
||||||
this.copyFullText = this.settings.copyFullText;
|
|
||||||
this.showClickMapPage = this.settings.showClickMapPage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -204,8 +207,6 @@ class Reader extends Vue {
|
|||||||
if (this.$root.rootRoute == '/reader') {
|
if (this.$root.rootRoute == '/reader') {
|
||||||
if (this.routeParamUrl) {
|
if (this.routeParamUrl) {
|
||||||
this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos});
|
this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos});
|
||||||
} else if (this.mostRecentBook()) {
|
|
||||||
this.loadBook({url: this.mostRecentBook().url});
|
|
||||||
} else {
|
} else {
|
||||||
this.loaderActive = true;
|
this.loaderActive = true;
|
||||||
}
|
}
|
||||||
@@ -214,6 +215,15 @@ class Reader extends Vue {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadSettings() {
|
||||||
|
const settings = this.settings;
|
||||||
|
this.allowUrlParamBookPos = settings.allowUrlParamBookPos;
|
||||||
|
this.copyFullText = settings.copyFullText;
|
||||||
|
this.showClickMapPage = settings.showClickMapPage;
|
||||||
|
this.clickControl = settings.clickControl;
|
||||||
|
this.blinkCachedLoad = settings.blinkCachedLoad;
|
||||||
|
}
|
||||||
|
|
||||||
get routeParamPos() {
|
get routeParamPos() {
|
||||||
let result = undefined;
|
let result = undefined;
|
||||||
const q = this.$route.query;
|
const q = this.$route.query;
|
||||||
@@ -438,6 +448,12 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshBook() {
|
||||||
|
if (this.mostRecentBook()) {
|
||||||
|
this.loadBook({url: this.mostRecentBook().url, force: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buttonClick(button) {
|
buttonClick(button) {
|
||||||
const activeClass = this.buttonActiveClass(button);
|
const activeClass = this.buttonActiveClass(button);
|
||||||
|
|
||||||
@@ -481,9 +497,7 @@ class Reader extends Vue {
|
|||||||
this.historyToggle();
|
this.historyToggle();
|
||||||
break;
|
break;
|
||||||
case 'refresh':
|
case 'refresh':
|
||||||
if (this.mostRecentBook()) {
|
this.refreshBook();
|
||||||
this.loadBook({url: this.mostRecentBook().url, force: true});
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'settings':
|
case 'settings':
|
||||||
this.settingsToggle();
|
this.settingsToggle();
|
||||||
@@ -542,8 +556,8 @@ class Reader extends Vue {
|
|||||||
return classResult;
|
return classResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
async acivateClickMapPage() {
|
async activateClickMapPage() {
|
||||||
if (this.showClickMapPage && !this.clickMapActive) {
|
if (this.clickControl && this.showClickMapPage && !this.clickMapActive) {
|
||||||
this.clickMapActive = true;
|
this.clickMapActive = true;
|
||||||
await this.$refs.clickMapPage.slowDisappear();
|
await this.$refs.clickMapPage.slowDisappear();
|
||||||
this.clickMapActive = false;
|
this.clickMapActive = false;
|
||||||
@@ -648,7 +662,7 @@ class Reader extends Vue {
|
|||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
this.blinkCachedLoadMessage();
|
this.blinkCachedLoadMessage();
|
||||||
|
|
||||||
await this.acivateClickMapPage();
|
await this.activateClickMapPage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +710,7 @@ class Reader extends Vue {
|
|||||||
} else
|
} else
|
||||||
this.stopBlink = true;
|
this.stopBlink = true;
|
||||||
|
|
||||||
await this.acivateClickMapPage();
|
await this.activateClickMapPage();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
this.loaderActive = true;
|
this.loaderActive = true;
|
||||||
@@ -713,7 +727,7 @@ class Reader extends Vue {
|
|||||||
progress.show();
|
progress.show();
|
||||||
progress.setState({state: 'upload'});
|
progress.setState({state: 'upload'});
|
||||||
|
|
||||||
const url = await readerApi.uploadFile(opts.file, (state) => {
|
const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => {
|
||||||
progress.setState(state);
|
progress.setState(state);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -729,6 +743,9 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blinkCachedLoadMessage() {
|
blinkCachedLoadMessage() {
|
||||||
|
if (!this.blinkCachedLoad)
|
||||||
|
return;
|
||||||
|
|
||||||
this.blinkCount = 30;
|
this.blinkCount = 30;
|
||||||
if (!this.inBlink) {
|
if (!this.inBlink) {
|
||||||
this.inBlink = true;
|
this.inBlink = true;
|
||||||
@@ -789,6 +806,9 @@ class Reader extends Vue {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
case 'KeyZ':
|
||||||
|
this.scrollingToggle();
|
||||||
|
break;
|
||||||
case 'KeyP':
|
case 'KeyP':
|
||||||
this.setPositionToggle();
|
this.setPositionToggle();
|
||||||
break;
|
break;
|
||||||
@@ -806,8 +826,8 @@ class Reader extends Vue {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'KeyZ':
|
case 'KeyR':
|
||||||
this.scrollingToggle();
|
this.refreshBook();
|
||||||
break;
|
break;
|
||||||
case 'KeyX':
|
case 'KeyX':
|
||||||
this.historyToggle();
|
this.historyToggle();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Размер">
|
<el-form-item label="Размер">
|
||||||
<el-col :span="17">
|
<el-col :span="17">
|
||||||
<el-input-number v-model="fontSize" :min="5" :max="100"></el-input-number>
|
<el-input-number v-model="fontSize" :min="5" :max="200"></el-input-number>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1">
|
<el-col :span="1">
|
||||||
<a href="https://fonts.google.com/?subset=cyrillic" target="_blank">Примеры</a>
|
<a href="https://fonts.google.com/?subset=cyrillic" target="_blank">Примеры</a>
|
||||||
@@ -112,10 +112,10 @@
|
|||||||
<div class="partHeader">Текст</div>
|
<div class="partHeader">Текст</div>
|
||||||
|
|
||||||
<el-form-item label="Интервал">
|
<el-form-item label="Интервал">
|
||||||
<el-input-number v-model="lineInterval" :min="0" :max="100"></el-input-number>
|
<el-input-number v-model="lineInterval" :min="0" :max="200"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Параграф">
|
<el-form-item label="Параграф">
|
||||||
<el-input-number v-model="p" :min="0" :max="200"></el-input-number>
|
<el-input-number v-model="p" :min="0" :max="2000"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Отступ">
|
<el-form-item label="Отступ">
|
||||||
<el-col :span="11">
|
<el-col :span="11">
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
<template slot="content">
|
<template slot="content">
|
||||||
Слева/справа
|
Слева/справа
|
||||||
</template>
|
</template>
|
||||||
<el-input-number v-model="indentLR" :min="0" :max="200"></el-input-number>
|
<el-input-number v-model="indentLR" :min="0" :max="2000"></el-input-number>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1">
|
<el-col :span="1">
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
<template slot="content">
|
<template slot="content">
|
||||||
Сверху/снизу
|
Сверху/снизу
|
||||||
</template>
|
</template>
|
||||||
<el-input-number v-model="indentTB" :min="0" :max="200"></el-input-number>
|
<el-input-number v-model="indentTB" :min="0" :max="2000"></el-input-number>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -184,6 +184,16 @@
|
|||||||
<el-checkbox v-model="textAlignJustify">По ширине</el-checkbox>
|
<el-checkbox v-model="textAlignJustify">По ширине</el-checkbox>
|
||||||
<el-checkbox v-model="wordWrap">Перенос по слогам</el-checkbox>
|
<el-checkbox v-model="wordWrap">Перенос по слогам</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="Обработка">
|
||||||
|
<el-checkbox v-model="cutEmptyParagraphs">Убирать пустые параграфы</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="">
|
||||||
|
<el-col :span="12">
|
||||||
|
Добавлять пустые
|
||||||
|
</el-col>
|
||||||
|
<el-input-number v-model="addEmptyParagraphs" :min="0" :max="2"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
||||||
@@ -194,7 +204,7 @@
|
|||||||
<el-checkbox v-model="statusBarTop" :disabled="!showStatusBar">Вверху/внизу</el-checkbox>
|
<el-checkbox v-model="statusBarTop" :disabled="!showStatusBar">Вверху/внизу</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Высота">
|
<el-form-item label="Высота">
|
||||||
<el-input-number v-model="statusBarHeight" :min="5" :max="50" :disabled="!showStatusBar"></el-input-number>
|
<el-input-number v-model="statusBarHeight" :min="5" :max="100" :disabled="!showStatusBar"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Прозрачность">
|
<el-form-item label="Прозрачность">
|
||||||
<el-input-number v-model="statusBarColorAlpha" :min="0" :max="1" :precision="2" :step="0.1" :disabled="!showStatusBar"></el-input-number>
|
<el-input-number v-model="statusBarColorAlpha" :min="0" :max="1" :precision="2" :step="0.1" :disabled="!showStatusBar"></el-input-number>
|
||||||
@@ -208,11 +218,19 @@
|
|||||||
<div class="partHeader">Анимация</div>
|
<div class="partHeader">Анимация</div>
|
||||||
|
|
||||||
<el-form-item label="Вид">
|
<el-form-item label="Вид">
|
||||||
не готово
|
<el-col :span="11">
|
||||||
|
<el-select v-model="pageChangeAnimation">
|
||||||
|
<el-option label="Нет" value=""></el-option>
|
||||||
|
<el-option label="Вверх-вниз" value="downShift"></el-option>
|
||||||
|
<el-option label="Вправо-влево" value="rightShift"></el-option>
|
||||||
|
<el-option label="Протаивание" value="thaw"></el-option>
|
||||||
|
<el-option label="Мерцание" value="blink"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="Скорость">
|
<el-form-item label="Скорость">
|
||||||
не готово
|
<el-input-number v-model="pageChangeAnimationSpeed" :min="0" :max="100" :disabled="pageChangeAnimation == ''"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
@@ -234,14 +252,26 @@
|
|||||||
<!--------------------------------------------------------------------------->
|
<!--------------------------------------------------------------------------->
|
||||||
<el-tab-pane label="Прочее">
|
<el-tab-pane label="Прочее">
|
||||||
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
||||||
|
<el-form-item label="Управление">
|
||||||
|
<el-checkbox v-model="clickControl">Включить управление кликом</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="Подсказка">
|
<el-form-item label="Подсказка">
|
||||||
<el-tooltip :open-delay="500" effect="light">
|
<el-tooltip :open-delay="500" effect="light">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
Показывать или нет подсказку при каждой загрузке книги
|
Показывать или нет подсказку при каждой загрузке книги
|
||||||
</template>
|
</template>
|
||||||
<el-checkbox v-model="showClickMapPage">Показывать области управления кликом</el-checkbox>
|
<el-checkbox v-model="showClickMapPage" :disabled="!clickControl">Показывать области управления кликом</el-checkbox>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="Подсказка">
|
||||||
|
<el-tooltip :open-delay="500" effect="light">
|
||||||
|
<template slot="content">
|
||||||
|
Мерцать сообщением в строке статуса и на кнопке<br>
|
||||||
|
обновления при загрузке книги из кэша
|
||||||
|
</template>
|
||||||
|
<el-checkbox v-model="blinkCachedLoad">Предупреждать о загрузке из кэша</el-checkbox>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="URL">
|
<el-form-item label="URL">
|
||||||
<el-tooltip :open-delay="500" effect="light">
|
<el-tooltip :open-delay="500" effect="light">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
@@ -274,9 +304,11 @@
|
|||||||
<el-checkbox v-model="copyFullText">Загружать весь текст</el-checkbox>
|
<el-checkbox v-model="copyFullText">Загружать весь текст</el-checkbox>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</el-tab-pane>
|
||||||
|
<!--------------------------------------------------------------------------->
|
||||||
|
<el-tab-pane label="Сброс">
|
||||||
|
<el-button @click="setDefaults">Установить по-умолчанию</el-button>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
@@ -384,10 +416,31 @@ class SettingsPage extends Vue {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
needReload() {
|
||||||
|
this.$notify.warning({message: 'Необходимо обновить страницу (F5), чтобы изменения возымели эффект'});
|
||||||
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.$emit('settings-toggle');
|
this.$emit('settings-toggle');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setDefaults() {
|
||||||
|
try {
|
||||||
|
if (await this.$confirm('Подтвердите установку настроек по-умолчанию', '', {
|
||||||
|
confirmButtonText: 'OK',
|
||||||
|
cancelButtonText: 'Отмена',
|
||||||
|
type: 'warning'
|
||||||
|
})) {
|
||||||
|
this.form = Object.assign({}, rstore.settingDefaults);
|
||||||
|
for (let prop in rstore.settingDefaults) {
|
||||||
|
this[prop] = this.form[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
keyHook(event) {
|
keyHook(event) {
|
||||||
if (event.type == 'keydown' && event.code == 'Escape') {
|
if (event.type == 'keydown' && event.code == 'Escape') {
|
||||||
this.close();
|
this.close();
|
||||||
|
|||||||
@@ -1,8 +1,109 @@
|
|||||||
|
import {sleep} from '../../../share/utils';
|
||||||
|
|
||||||
export default class DrawHelper {
|
export default class DrawHelper {
|
||||||
fontBySize(size) {
|
fontBySize(size) {
|
||||||
return `${size}px ${this.fontName}`;
|
return `${size}px ${this.fontName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fontByStyle(style) {
|
||||||
|
return `${style.italic ? 'italic' : this.fontStyle} ${style.bold ? 'bold' : this.fontWeight} ${this.fontSize}px ${this.fontName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
measureText(text, style) {// eslint-disable-line no-unused-vars
|
||||||
|
this.context.font = this.fontByStyle(style);
|
||||||
|
return this.context.measureText(text).width;
|
||||||
|
}
|
||||||
|
|
||||||
|
measureTextFont(text, font) {// eslint-disable-line no-unused-vars
|
||||||
|
this.context.font = font;
|
||||||
|
return this.context.measureText(text).width;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPage(lines, isScrolling) {
|
||||||
|
if (!this.lastBook || this.pageLineCount < 1 || !this.book || !lines || !this.parsed.textLength)
|
||||||
|
return '';
|
||||||
|
|
||||||
|
const font = this.fontByStyle({});
|
||||||
|
const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
|
||||||
|
|
||||||
|
let out = `<div class="layout" style="width: ${this.w}px; height: ${this.h}px;` +
|
||||||
|
` position: absolute; top: ${this.fontSize*this.textShift}px; color: ${this.textColor}; font: ${font}; ${justify}` +
|
||||||
|
` line-height: ${this.lineHeight}px;">`;
|
||||||
|
|
||||||
|
let len = lines.length;
|
||||||
|
const lineCount = this.pageLineCount + (isScrolling ? 1 : 0);
|
||||||
|
len = (len > lineCount ? lineCount : len);
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const line = lines[i];
|
||||||
|
/* line:
|
||||||
|
{
|
||||||
|
begin: Number,
|
||||||
|
end: Number,
|
||||||
|
first: Boolean,
|
||||||
|
last: Boolean,
|
||||||
|
parts: array of {
|
||||||
|
style: {bold: Boolean, italic: Boolean, center: Boolean}
|
||||||
|
text: String,
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
let sel = new Set();
|
||||||
|
if (i == 0 && this.searching) {
|
||||||
|
let pureText = '';
|
||||||
|
for (const part of line.parts) {
|
||||||
|
pureText += part.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
pureText = pureText.toLowerCase();
|
||||||
|
let j = 0;
|
||||||
|
while (1) {// eslint-disable-line no-constant-condition
|
||||||
|
j = pureText.indexOf(this.needle, j);
|
||||||
|
if (j >= 0) {
|
||||||
|
for (let k = 0; k < this.needle.length; k++) {
|
||||||
|
sel.add(j + k);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let lineText = '';
|
||||||
|
let center = false;
|
||||||
|
let j = 0;
|
||||||
|
for (const part of line.parts) {
|
||||||
|
let tOpen = (part.style.bold ? '<b>' : '');
|
||||||
|
tOpen += (part.style.italic ? '<i>' : '');
|
||||||
|
let tClose = (part.style.italic ? '</i>' : '');
|
||||||
|
tClose += (part.style.bold ? '</b>' : '');
|
||||||
|
|
||||||
|
let text = '';
|
||||||
|
if (i == 0 && this.searching) {
|
||||||
|
for (let k = 0; k < part.text.length; k++) {
|
||||||
|
text += (sel.has(j) ? `<ins>${part.text[k]}</ins>` : part.text[k]);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
text = part.text;
|
||||||
|
|
||||||
|
lineText += `${tOpen}${text}${tClose}`;
|
||||||
|
|
||||||
|
center = center || part.style.center;
|
||||||
|
}
|
||||||
|
|
||||||
|
const centerStyle = (center ? `text-align: center; text-align-last: center; width: ${this.w}px` : '')
|
||||||
|
if (line.first)
|
||||||
|
lineText = `<span style="display: inline-block; margin-left: ${this.p}px"></span>${lineText}`;
|
||||||
|
if (line.last || center)
|
||||||
|
lineText = `<span style="display: inline-block; ${centerStyle}">${lineText}</span>`;
|
||||||
|
|
||||||
|
out += (i > 0 ? '<br>' : '') + lineText;
|
||||||
|
}
|
||||||
|
|
||||||
|
out += '</div>';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
drawPercentBar(x, y, w, h, font, fontSize, bookPos, textLength) {
|
drawPercentBar(x, y, w, h, font, fontSize, bookPos, textLength) {
|
||||||
const pad = 3;
|
const pad = 3;
|
||||||
const fh = h - 2*pad;
|
const fh = h - 2*pad;
|
||||||
@@ -95,4 +196,75 @@ export default class DrawHelper {
|
|||||||
return `<div style="position: absolute; left: ${x}px; top: ${y}px; ` +
|
return `<div style="position: absolute; left: ${x}px; top: ${y}px; ` +
|
||||||
`width: ${w}px; height: ${h}px; box-sizing: border-box; border: 1px solid ${color}"></div>`;
|
`width: ${w}px; height: ${h}px; box-sizing: border-box; border: 1px solid ${color}"></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async doPageAnimationThaw(page1, page2, duration, isDown, animation1Finish) {
|
||||||
|
page1.style.animation = `page1-animation-thaw ${duration}ms ease-in 1`;
|
||||||
|
page2.style.animation = `page2-animation-thaw ${duration}ms ease-in 1`;
|
||||||
|
await animation1Finish(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
async doPageAnimationBlink(page1, page2, duration, isDown, animation1Finish, animation2Finish) {
|
||||||
|
page1.style.opacity = '0';
|
||||||
|
page2.style.opacity = '0';
|
||||||
|
page2.style.animation = `page2-animation-thaw ${duration/2}ms ease-out 1`;
|
||||||
|
await animation2Finish(duration/2);
|
||||||
|
|
||||||
|
page1.style.opacity = '1';
|
||||||
|
page1.style.animation = `page1-animation-thaw ${duration/2}ms ease-in 1`;
|
||||||
|
await animation1Finish(duration/2);
|
||||||
|
|
||||||
|
page2.style.opacity = '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
async doPageAnimationRightShift(page1, page2, duration, isDown, animation1Finish) {
|
||||||
|
const s = this.w + this.fontSize;
|
||||||
|
|
||||||
|
if (isDown) {
|
||||||
|
page1.style.transform = `translateX(${s}px)`;
|
||||||
|
await sleep(30);
|
||||||
|
|
||||||
|
page1.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page1.style.transform = `translateX(0px)`;
|
||||||
|
|
||||||
|
page2.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page2.style.transform = `translateX(-${s}px)`;
|
||||||
|
await animation1Finish(duration);
|
||||||
|
} else {
|
||||||
|
page1.style.transform = `translateX(-${s}px)`;
|
||||||
|
await sleep(30);
|
||||||
|
|
||||||
|
page1.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page1.style.transform = `translateX(0px)`;
|
||||||
|
|
||||||
|
page2.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page2.style.transform = `translateX(${s}px)`;
|
||||||
|
await animation1Finish(duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async doPageAnimationDownShift(page1, page2, duration, isDown, animation1Finish) {
|
||||||
|
const s = this.h + this.fontSize/2;
|
||||||
|
|
||||||
|
if (isDown) {
|
||||||
|
page1.style.transform = `translateY(${s}px)`;
|
||||||
|
await sleep(30);
|
||||||
|
|
||||||
|
page1.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page1.style.transform = `translateY(0px)`;
|
||||||
|
|
||||||
|
page2.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page2.style.transform = `translateY(-${s}px)`;
|
||||||
|
await animation1Finish(duration);
|
||||||
|
} else {
|
||||||
|
page1.style.transform = `translateY(-${s}px)`;
|
||||||
|
await sleep(30);
|
||||||
|
|
||||||
|
page1.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page1.style.transform = `translateY(0px)`;
|
||||||
|
|
||||||
|
page2.style.transition = `${duration}ms ease-in-out`;
|
||||||
|
page2.style.transform = `translateY(${s}px)`;
|
||||||
|
await animation1Finish(duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="main" class="main">
|
<div ref="main" class="main">
|
||||||
<div class="layout back">
|
<div class="layout back" @wheel.prevent.stop="onMouseWheel">
|
||||||
<div v-html="background"></div>
|
<div v-html="background"></div>
|
||||||
<!-- img -->
|
<!-- img -->
|
||||||
</div>
|
</div>
|
||||||
<div ref="scrollBox1" class="layout" style="overflow: hidden">
|
<div ref="scrollBox1" class="layout" style="overflow: hidden" @wheel.prevent.stop="onMouseWheel">
|
||||||
<div ref="scrollingPage" class="layout" @transitionend="onScrollingTransitionEnd">
|
<div ref="scrollingPage1" class="layout" @transitionend="onPage1TransitionEnd" @animationend="onPage1AnimationEnd">
|
||||||
<div v-html="page1"></div>
|
<div v-html="page1"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ref="scrollBox2" class="layout" style="overflow: hidden">
|
<div ref="scrollBox2" class="layout" style="overflow: hidden" @wheel.prevent.stop="onMouseWheel">
|
||||||
<div v-html="page2"></div>
|
<div ref="scrollingPage2" class="layout" @transitionend="onPage2TransitionEnd" @animationend="onPage2AnimationEnd">
|
||||||
|
<div v-html="page2"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="showStatusBar" ref="statusBar" class="layout">
|
<div v-show="showStatusBar" ref="statusBar" class="layout">
|
||||||
<div v-html="statusBar"></div>
|
<div v-html="statusBar"></div>
|
||||||
</div>
|
</div>
|
||||||
<div ref="layoutEvents" class="layout events" @mousedown.prevent.stop="onMouseDown" @mouseup.prevent.stop="onMouseUp"
|
<div v-show="clickControl" ref="layoutEvents" class="layout events" @mousedown.prevent.stop="onMouseDown" @mouseup.prevent.stop="onMouseUp"
|
||||||
@wheel.prevent.stop="onMouseWheel"
|
@wheel.prevent.stop="onMouseWheel"
|
||||||
@touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchcancel.prevent.stop="onTouchCancel"
|
@touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchcancel.prevent.stop="onTouchCancel"
|
||||||
oncontextmenu="return false;">
|
oncontextmenu="return false;">
|
||||||
@@ -23,6 +25,8 @@
|
|||||||
@click.prevent.stop="onStatusBarClick"></div>
|
@click.prevent.stop="onStatusBarClick"></div>
|
||||||
<div v-show="fontsLoading" ref="fontsLoading"></div>
|
<div v-show="fontsLoading" ref="fontsLoading"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-show="!clickControl && showStatusBar" class="layout" v-html="statusBarClickable" @mousedown.prevent.stop @touchstart.stop
|
||||||
|
@click.prevent.stop="onStatusBarClick"></div>
|
||||||
<!-- невидимым делать нельзя, вовремя не подгружаютя шрифты -->
|
<!-- невидимым делать нельзя, вовремя не подгружаютя шрифты -->
|
||||||
<canvas ref="offscreenCanvas" class="layout" style="width: 0px; height: 0px"></canvas>
|
<canvas ref="offscreenCanvas" class="layout" style="width: 0px; height: 0px"></canvas>
|
||||||
</div>
|
</div>
|
||||||
@@ -45,21 +49,29 @@ const minLayoutWidth = 100;
|
|||||||
|
|
||||||
export default @Component({
|
export default @Component({
|
||||||
watch: {
|
watch: {
|
||||||
bookPos: function(newValue) {
|
bookPos: function() {
|
||||||
this.$emit('book-pos-changed', {bookPos: newValue, bookPosSeen: this.bookPosSeen});
|
this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
|
||||||
this.draw();
|
this.draw();
|
||||||
},
|
},
|
||||||
|
bookPosSeen: function() {
|
||||||
|
this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
|
||||||
|
},
|
||||||
settings: function() {
|
settings: function() {
|
||||||
this.debouncedLoadSettings();
|
this.debouncedLoadSettings();
|
||||||
},
|
},
|
||||||
toggleLayout: function() {
|
toggleLayout: function() {
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
},
|
},
|
||||||
|
inAnimation: function() {
|
||||||
|
this.updateLayout();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
class TextPage extends Vue {
|
class TextPage extends Vue {
|
||||||
toggleLayout = false;
|
toggleLayout = false;
|
||||||
showStatusBar = false;
|
showStatusBar = false;
|
||||||
|
clickControl = true;
|
||||||
|
|
||||||
background = null;
|
background = null;
|
||||||
page1 = null;
|
page1 = null;
|
||||||
page2 = null;
|
page2 = null;
|
||||||
@@ -69,10 +81,14 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
lastBook = null;
|
lastBook = null;
|
||||||
bookPos = 0;
|
bookPos = 0;
|
||||||
|
bookPosSeen = null;
|
||||||
|
|
||||||
fontStyle = null;
|
fontStyle = null;
|
||||||
fontSize = null;
|
fontSize = null;
|
||||||
fontName = null;
|
fontName = null;
|
||||||
|
fontWeight = null;
|
||||||
|
|
||||||
|
inAnimation = false;
|
||||||
|
|
||||||
meta = null;
|
meta = null;
|
||||||
|
|
||||||
@@ -100,15 +116,20 @@ class TextPage extends Vue {
|
|||||||
this.loadSettings();
|
this.loadSettings();
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
this.debouncedUpdatePage = _.debounce((lines) => {
|
this.debouncedUpdatePage = _.debounce(async(lines) => {
|
||||||
this.toggleLayout = !this.toggleLayout;
|
if (!this.pageChangeAnimation)
|
||||||
|
this.toggleLayout = !this.toggleLayout;
|
||||||
|
else {
|
||||||
|
this.page2 = this.page1;
|
||||||
|
this.toggleLayout = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.toggleLayout)
|
if (this.toggleLayout)
|
||||||
this.page1 = this.drawPage(lines);
|
this.page1 = this.drawHelper.drawPage(lines);
|
||||||
else
|
else
|
||||||
this.page2 = this.drawPage(lines);
|
this.page2 = this.drawHelper.drawPage(lines);
|
||||||
|
|
||||||
this.doPageTransition();
|
await this.doPageAnimation();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
this.$root.$on('resize', () => {this.$nextTick(this.onResize)});
|
this.$root.$on('resize', () => {this.$nextTick(this.onResize)});
|
||||||
@@ -140,16 +161,39 @@ class TextPage extends Vue {
|
|||||||
this.lineHeight = this.fontSize + this.lineInterval;
|
this.lineHeight = this.fontSize + this.lineInterval;
|
||||||
this.pageLineCount = 1 + Math.floor((this.h - this.fontSize)/this.lineHeight);
|
this.pageLineCount = 1 + Math.floor((this.h - this.fontSize)/this.lineHeight);
|
||||||
|
|
||||||
if (this.parsed) {
|
this.$refs.scrollingPage1.style.width = this.w + 'px';
|
||||||
this.parsed.p = this.p;
|
this.$refs.scrollingPage2.style.width = this.w + 'px';
|
||||||
this.parsed.w = this.w;// px, ширина текста
|
|
||||||
this.parsed.font = this.font;
|
//stuff
|
||||||
this.parsed.wordWrap = this.wordWrap;
|
this.currentAnimation = '';
|
||||||
let t = '';
|
this.pageChangeDirectionDown = true;
|
||||||
while (this.measureText(t, {}) < this.w) t += 'Щ';
|
this.fontShift = this.fontVertShift/100;
|
||||||
this.parsed.maxWordLength = t.length - 1;
|
this.textShift = this.textVertShift/100 + this.fontShift;
|
||||||
this.parsed.measureText = this.measureText;
|
|
||||||
}
|
//drawHelper
|
||||||
|
this.drawHelper.realWidth = this.realWidth;
|
||||||
|
this.drawHelper.realHeight = this.realHeight;
|
||||||
|
this.drawHelper.lastBook = this.lastBook;
|
||||||
|
this.drawHelper.book = this.book;
|
||||||
|
this.drawHelper.parsed = this.parsed;
|
||||||
|
this.drawHelper.pageLineCount = this.pageLineCount;
|
||||||
|
|
||||||
|
this.drawHelper.backgroundColor = this.backgroundColor;
|
||||||
|
this.drawHelper.statusBarColor = this.statusBarColor;
|
||||||
|
this.drawHelper.fontStyle = this.fontStyle;
|
||||||
|
this.drawHelper.fontWeight = this.fontWeight;
|
||||||
|
this.drawHelper.fontSize = this.fontSize;
|
||||||
|
this.drawHelper.fontName = this.fontName;
|
||||||
|
this.drawHelper.fontShift = this.fontShift;
|
||||||
|
this.drawHelper.textColor = this.textColor;
|
||||||
|
this.drawHelper.textShift = this.textShift;
|
||||||
|
this.drawHelper.p = this.p;
|
||||||
|
this.drawHelper.w = this.w;
|
||||||
|
this.drawHelper.h = this.h;
|
||||||
|
this.drawHelper.indentLR = this.indentLR;
|
||||||
|
this.drawHelper.textAlignJustify = this.textAlignJustify;
|
||||||
|
this.drawHelper.lineHeight = this.lineHeight;
|
||||||
|
this.drawHelper.context = this.context;
|
||||||
|
|
||||||
//сообщение "Загрузка шрифтов..."
|
//сообщение "Загрузка шрифтов..."
|
||||||
const flText = 'Загрузка шрифта...';
|
const flText = 'Загрузка шрифта...';
|
||||||
@@ -158,29 +202,27 @@ class TextPage extends Vue {
|
|||||||
fontsLoadingStyle.position = 'absolute';
|
fontsLoadingStyle.position = 'absolute';
|
||||||
fontsLoadingStyle.fontSize = this.fontSize + 'px';
|
fontsLoadingStyle.fontSize = this.fontSize + 'px';
|
||||||
fontsLoadingStyle.top = (this.realHeight/2 - 2*this.fontSize) + 'px';
|
fontsLoadingStyle.top = (this.realHeight/2 - 2*this.fontSize) + 'px';
|
||||||
fontsLoadingStyle.left = (this.realWidth - this.measureText(flText, {}))/2 + 'px';
|
fontsLoadingStyle.left = (this.realWidth - this.drawHelper.measureText(flText, {}))/2 + 'px';
|
||||||
|
|
||||||
//stuff
|
//parsed
|
||||||
this.statusBarColor = this.hex2rgba(this.textColor || '#000000', this.statusBarColorAlpha);
|
if (this.parsed) {
|
||||||
this.currentTransition = '';
|
this.parsed.p = this.p;
|
||||||
this.pageChangeDirectionDown = true;
|
this.parsed.w = this.w;// px, ширина текста
|
||||||
this.fontShift = this.fontVertShift/100;
|
this.parsed.font = this.font;
|
||||||
this.textShift = this.textVertShift/100 + this.fontShift;
|
this.parsed.wordWrap = this.wordWrap;
|
||||||
|
this.parsed.cutEmptyParagraphs = this.cutEmptyParagraphs;
|
||||||
//drawHelper
|
this.parsed.addEmptyParagraphs = this.addEmptyParagraphs;
|
||||||
this.drawHelper.realWidth = this.realWidth;
|
let t = '';
|
||||||
this.drawHelper.realHeight = this.realHeight;
|
while (this.drawHelper.measureText(t, {}) < this.w) t += 'Щ';
|
||||||
|
this.parsed.maxWordLength = t.length - 1;
|
||||||
this.drawHelper.backgroundColor = this.backgroundColor;
|
this.parsed.measureText = this.drawHelper.measureText.bind(this.drawHelper);
|
||||||
this.drawHelper.statusBarColor = this.statusBarColor;
|
}
|
||||||
this.drawHelper.fontName = this.fontName;
|
|
||||||
this.drawHelper.fontShift = this.fontShift;
|
|
||||||
this.drawHelper.measureText = this.measureText;
|
|
||||||
this.drawHelper.measureTextFont = this.measureTextFont;
|
|
||||||
|
|
||||||
|
//statusBar
|
||||||
this.$refs.statusBar.style.left = '0px';
|
this.$refs.statusBar.style.left = '0px';
|
||||||
this.$refs.statusBar.style.top = (this.statusBarTop ? 1 : this.realHeight - this.statusBarHeight) + 'px';
|
this.$refs.statusBar.style.top = (this.statusBarTop ? 1 : this.realHeight - this.statusBarHeight) + 'px';
|
||||||
|
|
||||||
|
this.statusBarColor = this.hex2rgba(this.textColor || '#000000', this.statusBarColorAlpha);
|
||||||
this.statusBarClickable = this.drawHelper.statusBarClickable(this.statusBarTop, this.statusBarHeight);
|
this.statusBarClickable = this.drawHelper.statusBarClickable(this.statusBarTop, this.statusBarHeight);
|
||||||
|
|
||||||
//scrolling page
|
//scrolling page
|
||||||
@@ -200,16 +242,6 @@ class TextPage extends Vue {
|
|||||||
page2.style.left = this.indentLR + 'px';
|
page2.style.left = this.indentLR + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
measureText(text, style) {// eslint-disable-line no-unused-vars
|
|
||||||
this.context.font = this.fontByStyle(style);
|
|
||||||
return this.context.measureText(text).width;
|
|
||||||
}
|
|
||||||
|
|
||||||
measureTextFont(text, font) {// eslint-disable-line no-unused-vars
|
|
||||||
this.context.font = font;
|
|
||||||
return this.context.measureText(text).width;
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkLoadedFonts() {
|
async checkLoadedFonts() {
|
||||||
let loaded = await Promise.all(this.fontList.map(font => document.fonts.check(font)));
|
let loaded = await Promise.all(this.fontList.map(font => document.fonts.check(font)));
|
||||||
if (loaded.some(r => !r)) {
|
if (loaded.some(r => !r)) {
|
||||||
@@ -279,18 +311,12 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
this.draw();
|
this.draw();
|
||||||
|
|
||||||
// шрифты хрен знает когда подгружаются, поэтому
|
// шрифты хрен знает когда подгружаются в div, поэтому
|
||||||
const parsed = this.parsed;
|
const parsed = this.parsed;
|
||||||
if (!parsed.force) {
|
await sleep(5000);
|
||||||
let i = 0;
|
if (this.parsed === parsed) {
|
||||||
parsed.force = true;
|
parsed.force = true;
|
||||||
while (i < 10) {
|
this.draw();
|
||||||
await sleep(1000);
|
|
||||||
if (this.parsed != parsed)
|
|
||||||
break;
|
|
||||||
this.draw();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
parsed.force = false;
|
parsed.force = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +341,6 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
this.linesUp = null;
|
this.linesUp = null;
|
||||||
this.linesDown = null;
|
this.linesDown = null;
|
||||||
this.searching = false;
|
|
||||||
|
|
||||||
this.statusBarMessage = '';
|
this.statusBarMessage = '';
|
||||||
|
|
||||||
@@ -367,7 +392,10 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLayout() {
|
updateLayout() {
|
||||||
if (this.toggleLayout) {
|
if (this.inAnimation) {
|
||||||
|
this.$refs.scrollBox1.style.visibility = 'visible';
|
||||||
|
this.$refs.scrollBox2.style.visibility = 'visible';
|
||||||
|
} else if (this.toggleLayout) {
|
||||||
this.$refs.scrollBox1.style.visibility = 'visible';
|
this.$refs.scrollBox1.style.visibility = 'visible';
|
||||||
this.$refs.scrollBox2.style.visibility = 'hidden';
|
this.$refs.scrollBox2.style.visibility = 'hidden';
|
||||||
} else {
|
} else {
|
||||||
@@ -399,34 +427,42 @@ class TextPage extends Vue {
|
|||||||
return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px ${this.fontName}`;
|
return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px ${this.fontName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
fontByStyle(style) {
|
onPage1TransitionEnd() {
|
||||||
return `${style.italic ? 'italic' : this.fontStyle} ${style.bold ? 'bold' : this.fontWeight} ${this.fontSize}px ${this.fontName}`;
|
if (this.resolveTransition1Finish)
|
||||||
|
this.resolveTransition1Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
onScrollingTransitionEnd() {
|
onPage2TransitionEnd() {
|
||||||
if (this.resolveTransitionFinish)
|
if (this.resolveTransition2Finish)
|
||||||
this.resolveTransitionFinish();
|
this.resolveTransition2Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
startSearch(needle) {
|
startSearch(needle) {
|
||||||
this.needle = '';
|
this.drawHelper.needle = needle;
|
||||||
const words = needle.split(' ');
|
this.drawHelper.searching = true;
|
||||||
for (const word of words) {
|
|
||||||
if (word != '') {
|
|
||||||
this.needle = word;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.searching = true;
|
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
stopSearch() {
|
stopSearch() {
|
||||||
this.searching = false;
|
this.drawHelper.searching = false;
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateWaitingFunc(waitingHandlerName, stopPropertyName) {
|
||||||
|
const func = (timeout) => {
|
||||||
|
return new Promise(async(resolve) => {
|
||||||
|
this[waitingHandlerName] = resolve;
|
||||||
|
let wait = (timeout + 201)/100;
|
||||||
|
while (wait > 0 && !this[stopPropertyName]) {
|
||||||
|
wait--;
|
||||||
|
await sleep(100);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
async startTextScrolling() {
|
async startTextScrolling() {
|
||||||
if (this.doingScrolling || !this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1 ||
|
if (this.doingScrolling || !this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1 ||
|
||||||
this.linesDown.length <= this.pageLineCount) {
|
this.linesDown.length <= this.pageLineCount) {
|
||||||
@@ -434,20 +470,13 @@ class TextPage extends Vue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ждем анимацию
|
||||||
|
while (this.inAnimation) await sleep(10);
|
||||||
|
|
||||||
this.stopScrolling = false;
|
this.stopScrolling = false;
|
||||||
this.doingScrolling = true;
|
this.doingScrolling = true;
|
||||||
|
|
||||||
const transitionFinish = (timeout) => {
|
const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling');
|
||||||
return new Promise(async(resolve) => {
|
|
||||||
this.resolveTransitionFinish = resolve;
|
|
||||||
let wait = timeout/100;
|
|
||||||
while (wait > 0 && !this.stopScrolling) {
|
|
||||||
wait--;
|
|
||||||
await sleep(100);
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!this.toggleLayout)
|
if (!this.toggleLayout)
|
||||||
this.page1 = this.page2;
|
this.page1 = this.page2;
|
||||||
@@ -456,7 +485,9 @@ class TextPage extends Vue {
|
|||||||
await sleep(50);
|
await sleep(50);
|
||||||
|
|
||||||
this.cachedPos = -1;
|
this.cachedPos = -1;
|
||||||
const page = this.$refs.scrollingPage;
|
this.draw();
|
||||||
|
|
||||||
|
const page = this.$refs.scrollingPage1;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (!this.stopScrolling) {
|
while (!this.stopScrolling) {
|
||||||
page.style.transition = `${this.scrollingDelay}ms ${this.scrollingType}`;
|
page.style.transition = `${this.scrollingDelay}ms ${this.scrollingType}`;
|
||||||
@@ -468,21 +499,22 @@ class TextPage extends Vue {
|
|||||||
this.stopScrolling = true;
|
this.stopScrolling = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await transitionFinish(this.scrollingDelay + 201);
|
await transitionFinish(this.scrollingDelay);
|
||||||
page.style.transition = '';
|
page.style.transition = '';
|
||||||
page.style.transform = 'none';
|
page.style.transform = 'none';
|
||||||
page.offsetHeight;
|
page.offsetHeight;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
this.resolveTransitionFinish = null;
|
this.resolveTransition1Finish = null;
|
||||||
this.doingScrolling = false;
|
this.doingScrolling = false;
|
||||||
this.$emit('stop-scrolling');
|
this.$emit('stop-scrolling');
|
||||||
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
async stopTextScrolling() {
|
async stopTextScrolling() {
|
||||||
this.stopScrolling = true;
|
this.stopScrolling = true;
|
||||||
|
|
||||||
const page = this.$refs.scrollingPage;
|
const page = this.$refs.scrollingPage1;
|
||||||
page.style.transition = '';
|
page.style.transition = '';
|
||||||
page.style.transform = 'none';
|
page.style.transform = 'none';
|
||||||
page.offsetHeight;
|
page.offsetHeight;
|
||||||
@@ -491,7 +523,10 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
|
//scrolling
|
||||||
if (this.doingScrolling) {
|
if (this.doingScrolling) {
|
||||||
|
this.currentAnimation = '';
|
||||||
|
|
||||||
if (this.cachedPos == this.bookPos) {
|
if (this.cachedPos == this.bookPos) {
|
||||||
this.linesDown = this.linesCached.linesDown;
|
this.linesDown = this.linesCached.linesDown;
|
||||||
this.linesUp = this.linesCached.linesUp;
|
this.linesUp = this.linesCached.linesUp;
|
||||||
@@ -500,7 +535,7 @@ class TextPage extends Vue {
|
|||||||
const lines = this.getLines(this.bookPos);
|
const lines = this.getLines(this.bookPos);
|
||||||
this.linesDown = lines.linesDown;
|
this.linesDown = lines.linesDown;
|
||||||
this.linesUp = lines.linesUp;
|
this.linesUp = lines.linesUp;
|
||||||
this.page1 = this.drawPage(lines.linesDown);
|
this.page1 = this.drawHelper.drawPage(lines.linesDown, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//caching next
|
//caching next
|
||||||
@@ -510,7 +545,7 @@ class TextPage extends Vue {
|
|||||||
if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
|
if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
|
||||||
this.cachedPos = this.linesDown[1].begin;
|
this.cachedPos = this.linesDown[1].begin;
|
||||||
this.linesCached = this.getLines(this.cachedPos);
|
this.linesCached = this.getLines(this.cachedPos);
|
||||||
this.pageCached = this.drawPage(this.linesCached.linesDown);
|
this.pageCached = this.drawHelper.drawPage(this.linesCached.linesDown, true);
|
||||||
}
|
}
|
||||||
this.cachedPageTimer = null;
|
this.cachedPageTimer = null;
|
||||||
}, 20);
|
}, 20);
|
||||||
@@ -519,6 +554,7 @@ class TextPage extends Vue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check
|
||||||
if (this.w < minLayoutWidth) {
|
if (this.w < minLayoutWidth) {
|
||||||
this.page1 = null;
|
this.page1 = null;
|
||||||
this.page2 = null;
|
this.page2 = null;
|
||||||
@@ -527,49 +563,97 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
|
if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
|
||||||
this.doEnd();
|
this.doEnd(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fast draw prepared
|
||||||
if (this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
if (!this.pageChangeAnimation && this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
||||||
this.toggleLayout = !this.toggleLayout;
|
this.toggleLayout = !this.toggleLayout;
|
||||||
this.linesDown = this.linesDownNext;
|
this.linesDown = this.linesDownNext;
|
||||||
this.linesUp = this.linesUpNext;
|
this.linesUp = this.linesUpNext;
|
||||||
this.doPageTransition();
|
} else {//normal debounced draw
|
||||||
} else {
|
|
||||||
const lines = this.getLines(this.bookPos);
|
const lines = this.getLines(this.bookPos);
|
||||||
this.linesDown = lines.linesDown;
|
this.linesDown = lines.linesDown;
|
||||||
this.linesUp = lines.linesUp;
|
this.linesUp = lines.linesUp;
|
||||||
|
|
||||||
/*if (this.toggleLayout)
|
|
||||||
this.page1 = this.drawPage(lines.linesDown);
|
|
||||||
else
|
|
||||||
this.page2 = this.drawPage(lines.linesDown);*/
|
|
||||||
|
|
||||||
this.debouncedUpdatePage(lines.linesDown);
|
this.debouncedUpdatePage(lines.linesDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pagePrepared = false;
|
this.pagePrepared = false;
|
||||||
this.debouncedPrepareNextPage();
|
if (!this.pageChangeAnimation)
|
||||||
|
this.debouncedPrepareNextPage();
|
||||||
this.debouncedDrawStatusBar();
|
this.debouncedDrawStatusBar();
|
||||||
|
|
||||||
if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount)
|
if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount) {
|
||||||
this.doEnd();
|
this.doEnd(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doPageTransition() {
|
onPage1AnimationEnd() {
|
||||||
if (this.currentTransition) {
|
if (this.resolveAnimation1Finish)
|
||||||
//this.currentTransition
|
this.resolveAnimation1Finish();
|
||||||
//this.pageChangeTransitionSpeed
|
}
|
||||||
//this.pageChangeDirectionDown
|
|
||||||
|
|
||||||
//curr to next transition
|
|
||||||
//пока заглушка
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentTransition = '';
|
onPage2AnimationEnd() {
|
||||||
this.pageChangeDirectionDown = false;//true только если PgDown
|
if (this.resolveAnimation2Finish)
|
||||||
|
this.resolveAnimation2Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
async doPageAnimation() {
|
||||||
|
if (this.currentAnimation && !this.inAnimation) {
|
||||||
|
this.inAnimation = true;
|
||||||
|
|
||||||
|
const animation1Finish = this.generateWaitingFunc('resolveAnimation1Finish', 'stopAnimation');
|
||||||
|
const animation2Finish = this.generateWaitingFunc('resolveAnimation2Finish', 'stopAnimation');
|
||||||
|
const transition1Finish = this.generateWaitingFunc('resolveTransition1Finish', 'stopAnimation');
|
||||||
|
//const transition2Finish = this.generateWaitingFunc('resolveTransition2Finish', 'stopAnimation');
|
||||||
|
|
||||||
|
const duration = Math.round(3000*(1 - this.pageChangeAnimationSpeed/100));
|
||||||
|
let page1 = this.$refs.scrollingPage1;
|
||||||
|
let page2 = this.$refs.scrollingPage2;
|
||||||
|
|
||||||
|
switch (this.currentAnimation) {
|
||||||
|
case 'thaw':
|
||||||
|
await this.drawHelper.doPageAnimationThaw(page1, page2,
|
||||||
|
duration, this.pageChangeDirectionDown, animation1Finish);
|
||||||
|
break;
|
||||||
|
case 'blink':
|
||||||
|
await this.drawHelper.doPageAnimationBlink(page1, page2,
|
||||||
|
duration, this.pageChangeDirectionDown, animation1Finish, animation2Finish);
|
||||||
|
break;
|
||||||
|
case 'rightShift':
|
||||||
|
await this.drawHelper.doPageAnimationRightShift(page1, page2,
|
||||||
|
duration, this.pageChangeDirectionDown, transition1Finish);
|
||||||
|
break;
|
||||||
|
case 'downShift':
|
||||||
|
await this.drawHelper.doPageAnimationDownShift(page1, page2,
|
||||||
|
duration, this.pageChangeDirectionDown, transition1Finish);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resolveAnimation1Finish = null;
|
||||||
|
this.resolveAnimation2Finish = null;
|
||||||
|
this.resolveTransition1Finish = null;
|
||||||
|
this.resolveTransition2Finish = null;
|
||||||
|
|
||||||
|
page1.style.animation = '';
|
||||||
|
page2.style.animation = '';
|
||||||
|
|
||||||
|
page1.style.transition = '';
|
||||||
|
page1.style.transform = 'none';
|
||||||
|
page1.offsetHeight;
|
||||||
|
|
||||||
|
page2.style.transition = '';
|
||||||
|
page2.style.transform = 'none';
|
||||||
|
page2.offsetHeight;
|
||||||
|
|
||||||
|
this.currentAnimation = '';
|
||||||
|
this.pageChangeDirectionDown = false;//true только если PgDown
|
||||||
|
|
||||||
|
this.inAnimation = false;
|
||||||
|
this.stopAnimation = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getLines(bookPos) {
|
getLines(bookPos) {
|
||||||
@@ -582,110 +666,6 @@ class TextPage extends Vue {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
drawPage(lines) {
|
|
||||||
if (!this.lastBook || this.pageLineCount < 1 || !this.book || !lines || !this.parsed.textLength)
|
|
||||||
return '';
|
|
||||||
|
|
||||||
const spaceWidth = this.measureText(' ', {});
|
|
||||||
|
|
||||||
let out = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
|
|
||||||
` color: ${this.textColor}">`;
|
|
||||||
|
|
||||||
let len = lines.length;
|
|
||||||
len = (len > this.pageLineCount + 1 ? this.pageLineCount + 1 : len);
|
|
||||||
|
|
||||||
let y = this.fontSize*this.textShift;
|
|
||||||
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
const line = lines[i];
|
|
||||||
/* line:
|
|
||||||
{
|
|
||||||
begin: Number,
|
|
||||||
end: Number,
|
|
||||||
first: Boolean,
|
|
||||||
last: Boolean,
|
|
||||||
parts: array of {
|
|
||||||
style: {bold: Boolean, italic: Boolean, center: Boolean}
|
|
||||||
text: String,
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
let indent = line.first ? this.p : 0;
|
|
||||||
|
|
||||||
let lineText = '';
|
|
||||||
let center = false;
|
|
||||||
let centerStyle = {};
|
|
||||||
for (const part of line.parts) {
|
|
||||||
lineText += part.text;
|
|
||||||
center = center || part.style.center;
|
|
||||||
if (part.style.center)
|
|
||||||
centerStyle = part.style;
|
|
||||||
}
|
|
||||||
|
|
||||||
let filled = false;
|
|
||||||
// если выравнивание по ширине включено
|
|
||||||
if (this.textAlignJustify && !line.last && !center) {
|
|
||||||
const words = lineText.split(' ');
|
|
||||||
|
|
||||||
if (words.length > 1) {
|
|
||||||
const spaceCount = words.length - 1;
|
|
||||||
|
|
||||||
const space = (this.w - line.width + spaceWidth*spaceCount)/spaceCount;
|
|
||||||
|
|
||||||
let x = indent;
|
|
||||||
for (const part of line.parts) {
|
|
||||||
const font = this.fontByStyle(part.style);
|
|
||||||
let partWords = part.text.split(' ');
|
|
||||||
|
|
||||||
for (let j = 0; j < partWords.length; j++) {
|
|
||||||
let f = font;
|
|
||||||
let style = part.style;
|
|
||||||
let word = partWords[j];
|
|
||||||
if (i == 0 && this.searching && word.toLowerCase().indexOf(this.needle) >= 0) {
|
|
||||||
style = Object.assign({}, part.style, {bold: true});
|
|
||||||
f = this.fontByStyle(style);
|
|
||||||
}
|
|
||||||
out += this.drawHelper.fillText(word, x, y, f);
|
|
||||||
x += this.measureText(word, style) + (j < partWords.length - 1 ? space : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// просто выводим текст
|
|
||||||
if (!filled) {
|
|
||||||
let x = indent;
|
|
||||||
x = (center ? (this.w - this.measureText(lineText, centerStyle))/2 : x);
|
|
||||||
for (const part of line.parts) {
|
|
||||||
let font = this.fontByStyle(part.style);
|
|
||||||
|
|
||||||
if (i == 0 && this.searching) {//для поиска, разбивка по словам
|
|
||||||
let partWords = part.text.split(' ');
|
|
||||||
for (let j = 0; j < partWords.length; j++) {
|
|
||||||
let f = font;
|
|
||||||
let style = part.style;
|
|
||||||
let word = partWords[j];
|
|
||||||
if (word.toLowerCase().indexOf(this.needle) >= 0) {
|
|
||||||
style = Object.assign({}, part.style, {bold: true});
|
|
||||||
f = this.fontByStyle(style);
|
|
||||||
}
|
|
||||||
out += this.drawHelper.fillText(word, x, y, f);
|
|
||||||
x += this.measureText(word, style) + (j < partWords.length - 1 ? spaceWidth : 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out += this.drawHelper.fillText(part.text, x, y, font);
|
|
||||||
x += this.measureText(part.text, part.style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
y += this.lineHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
out += '</div>';
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawStatusBar(message) {
|
drawStatusBar(message) {
|
||||||
if (this.w < minLayoutWidth) {
|
if (this.w < minLayoutWidth) {
|
||||||
this.statusBar = null;
|
this.statusBar = null;
|
||||||
@@ -782,9 +762,9 @@ class TextPage extends Vue {
|
|||||||
this.linesUpNext = lines.linesUp;
|
this.linesUpNext = lines.linesUp;
|
||||||
|
|
||||||
if (this.toggleLayout)
|
if (this.toggleLayout)
|
||||||
this.page2 = this.drawPage(lines.linesDown);//наоборот
|
this.page2 = this.drawHelper.drawPage(lines.linesDown);//наоборот
|
||||||
else
|
else
|
||||||
this.page1 = this.drawPage(lines.linesDown);
|
this.page1 = this.drawHelper.drawPage(lines.linesDown);
|
||||||
|
|
||||||
this.pagePrepared = true;
|
this.pagePrepared = true;
|
||||||
}
|
}
|
||||||
@@ -808,7 +788,7 @@ class TextPage extends Vue {
|
|||||||
if (this.keepLastToFirst)
|
if (this.keepLastToFirst)
|
||||||
i--;
|
i--;
|
||||||
if (i >= 0 && this.linesDown.length >= 2*i) {
|
if (i >= 0 && this.linesDown.length >= 2*i) {
|
||||||
this.currentTransition = this.pageChangeTransition;
|
this.currentAnimation = this.pageChangeAnimation;
|
||||||
this.pageChangeDirectionDown = true;
|
this.pageChangeDirectionDown = true;
|
||||||
this.bookPos = this.linesDown[i].begin;
|
this.bookPos = this.linesDown[i].begin;
|
||||||
} else
|
} else
|
||||||
@@ -823,7 +803,7 @@ class TextPage extends Vue {
|
|||||||
i--;
|
i--;
|
||||||
i = (i > this.linesUp.length - 1 ? this.linesUp.length - 1 : i);
|
i = (i > this.linesUp.length - 1 ? this.linesUp.length - 1 : i);
|
||||||
if (i >= 0 && this.linesUp.length > i) {
|
if (i >= 0 && this.linesUp.length > i) {
|
||||||
this.currentTransition = this.pageChangeTransition;
|
this.currentAnimation = this.pageChangeAnimation;
|
||||||
this.pageChangeDirectionDown = false;
|
this.pageChangeDirectionDown = false;
|
||||||
this.bookPos = this.linesUp[i].begin;
|
this.bookPos = this.linesUp[i].begin;
|
||||||
}
|
}
|
||||||
@@ -831,10 +811,12 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doHome() {
|
doHome() {
|
||||||
|
this.currentAnimation = this.pageChangeAnimation;
|
||||||
|
this.pageChangeDirectionDown = false;
|
||||||
this.bookPos = 0;
|
this.bookPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
doEnd() {
|
doEnd(noAni) {
|
||||||
if (this.parsed.para.length && this.pageLineCount > 0) {
|
if (this.parsed.para.length && this.pageLineCount > 0) {
|
||||||
let i = this.parsed.para.length - 1;
|
let i = this.parsed.para.length - 1;
|
||||||
let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
|
let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
|
||||||
@@ -842,6 +824,9 @@ class TextPage extends Vue {
|
|||||||
if (lines) {
|
if (lines) {
|
||||||
i = this.pageLineCount - 1;
|
i = this.pageLineCount - 1;
|
||||||
i = (i > lines.length - 1 ? lines.length - 1 : i);
|
i = (i > lines.length - 1 ? lines.length - 1 : i);
|
||||||
|
if (!noAni)
|
||||||
|
this.currentAnimation = this.pageChangeAnimation;
|
||||||
|
this.pageChangeDirectionDown = true;
|
||||||
this.bookPos = lines[i].begin;
|
this.bookPos = lines[i].begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -945,6 +930,7 @@ class TextPage extends Vue {
|
|||||||
this.$emit('full-screen-toogle');
|
this.$emit('full-screen-toogle');
|
||||||
break;
|
break;
|
||||||
case 'Tab':
|
case 'Tab':
|
||||||
|
case 'KeyQ':
|
||||||
this.doToolBarToggle();
|
this.doToolBarToggle();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -1162,4 +1148,13 @@ class TextPage extends Vue {
|
|||||||
background: url("images/paper9.jpg");
|
background: url("images/paper9.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes page1-animation-thaw {
|
||||||
|
0% { opacity: 0; }
|
||||||
|
100% { opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes page2-animation-thaw {
|
||||||
|
0% { opacity: 1; }
|
||||||
|
100% { opacity: 0; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import he from 'he';
|
|||||||
import sax from '../../../../server/core/BookConverter/sax';
|
import sax from '../../../../server/core/BookConverter/sax';
|
||||||
import {sleep} from '../../../share/utils';
|
import {sleep} from '../../../share/utils';
|
||||||
|
|
||||||
|
const maxImageLineCount = 100;
|
||||||
|
|
||||||
export default class BookParser {
|
export default class BookParser {
|
||||||
constructor() {
|
constructor() {
|
||||||
// defaults
|
// defaults
|
||||||
@@ -37,6 +39,10 @@ export default class BookParser {
|
|||||||
let center = false;
|
let center = false;
|
||||||
let bold = false;
|
let bold = false;
|
||||||
let italic = false;
|
let italic = false;
|
||||||
|
this.binary = {};
|
||||||
|
let binaryId = '';
|
||||||
|
let binaryType = '';
|
||||||
|
let dimPromises = [];
|
||||||
|
|
||||||
let paraIndex = -1;
|
let paraIndex = -1;
|
||||||
let paraOffset = 0;
|
let paraOffset = 0;
|
||||||
@@ -45,16 +51,42 @@ export default class BookParser {
|
|||||||
index: Number,
|
index: Number,
|
||||||
offset: Number, //сумма всех length до этого параграфа
|
offset: Number, //сумма всех length до этого параграфа
|
||||||
length: Number, //длина text без тегов
|
length: Number, //длина text без тегов
|
||||||
text: String //текст параграфа (или title или epigraph и т.д) с вложенными тегами
|
text: String, //текст параграфа с вложенными тегами
|
||||||
|
cut: Boolean, //параграф - кандидат на сокрытие (cutEmptyParagraphs)
|
||||||
|
addIndex: Number, //индекс добавляемого пустого параграфа (addEmptyParagraphs)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const newParagraph = (text, len) => {
|
const getImageDimensions = (binaryId, binaryType, data) => {
|
||||||
|
return new Promise (async(resolve, reject) => {
|
||||||
|
const i = new Image();
|
||||||
|
let resolved = false;
|
||||||
|
i.onload = () => {
|
||||||
|
resolved = true;
|
||||||
|
this.binary[binaryId] = {
|
||||||
|
w: i.width,
|
||||||
|
h: i.height,
|
||||||
|
type: binaryType,
|
||||||
|
data
|
||||||
|
};
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
i.src = `data:${binaryType};base64,${data}`;
|
||||||
|
await sleep(30*1000);
|
||||||
|
if (!resolved)
|
||||||
|
reject('Не удалось получить размер изображения');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const newParagraph = (text, len, addIndex) => {
|
||||||
paraIndex++;
|
paraIndex++;
|
||||||
let p = {
|
let p = {
|
||||||
index: paraIndex,
|
index: paraIndex,
|
||||||
offset: paraOffset,
|
offset: paraOffset,
|
||||||
length: len,
|
length: len,
|
||||||
text: text,
|
text: text,
|
||||||
|
cut: (!addIndex && (len == 1 && text[0] == ' ')),
|
||||||
|
addIndex: (addIndex ? addIndex : 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
para[paraIndex] = p;
|
para[paraIndex] = p;
|
||||||
@@ -63,88 +95,123 @@ export default class BookParser {
|
|||||||
|
|
||||||
const growParagraph = (text, len) => {
|
const growParagraph = (text, len) => {
|
||||||
if (paraIndex < 0) {
|
if (paraIndex < 0) {
|
||||||
newParagraph(text, len);
|
newParagraph(' ', 1);
|
||||||
|
growParagraph(text, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let p = para[paraIndex];
|
let p = para[paraIndex];
|
||||||
if (p) {
|
//добавление пустых (addEmptyParagraphs) параграфов
|
||||||
|
if (p.length == 1 && p.text[0] == ' ' && len > 0) {
|
||||||
|
paraIndex--;
|
||||||
paraOffset -= p.length;
|
paraOffset -= p.length;
|
||||||
if (p.length == 1 && p.text[0] == ' ' && len > 0) {
|
for (let i = 0; i < 2; i++) {
|
||||||
p.length = 0;
|
newParagraph(' ', 1, i + 1);
|
||||||
p.text = p.text.substr(1);
|
|
||||||
}
|
}
|
||||||
p.length += len;
|
|
||||||
p.text += text;
|
paraIndex++;
|
||||||
} else {
|
p.index = paraIndex;
|
||||||
p = {
|
p.offset = paraOffset;
|
||||||
index: paraIndex,
|
para[paraIndex] = p;
|
||||||
offset: paraOffset,
|
paraOffset += p.length;
|
||||||
length: len,
|
|
||||||
text: text
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paraOffset -= p.length;
|
||||||
|
//параграф оказался непустой
|
||||||
|
if (p.length == 1 && p.text[0] == ' ' && len > 0) {
|
||||||
|
p.length = 0;
|
||||||
|
p.text = p.text.substr(1);
|
||||||
|
p.cut = (len == 1 && text[0] == ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
p.length += len;
|
||||||
|
p.text += text;
|
||||||
|
|
||||||
para[paraIndex] = p;
|
para[paraIndex] = p;
|
||||||
paraOffset += p.length;
|
paraOffset += p.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onStartNode = (elemName) => {// eslint-disable-line no-unused-vars
|
const onStartNode = (elemName, tail) => {// eslint-disable-line no-unused-vars
|
||||||
if (elemName == '?xml')
|
if (elemName == '?xml')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tag = elemName;
|
tag = elemName;
|
||||||
path += '/' + elemName;
|
path += '/' + elemName;
|
||||||
|
|
||||||
if ((tag == 'p' || tag == 'empty-line' || tag == 'v') && path.indexOf('/fictionbook/body/section') == 0) {
|
if (tag == 'binary') {
|
||||||
newParagraph(' ', 1);
|
let attrs = sax.getAttrsSync(tail);
|
||||||
|
binaryType = (attrs['content-type'].value ? attrs['content-type'].value : '');
|
||||||
|
if (binaryType == 'image/jpeg' || binaryType == 'image/png')
|
||||||
|
binaryId = (attrs.id.value ? attrs.id.value : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'emphasis' || tag == 'strong') {
|
if (tag == 'image') {
|
||||||
growParagraph(`<${tag}>`, 0);
|
let attrs = sax.getAttrsSync(tail);
|
||||||
|
if (attrs.href.value)
|
||||||
|
newParagraph(`<image href="${attrs.href.value}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'title') {
|
if (path.indexOf('/fictionbook/body') == 0) {
|
||||||
newParagraph(' ', 1);
|
if (tag == 'title') {
|
||||||
bold = true;
|
newParagraph(' ', 1);
|
||||||
center = true;
|
bold = true;
|
||||||
}
|
center = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (tag == 'subtitle') {
|
if (tag == 'emphasis' || tag == 'strong') {
|
||||||
newParagraph(' ', 1);
|
growParagraph(`<${tag}>`, 0);
|
||||||
bold = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tag == 'epigraph') {
|
if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) {
|
||||||
italic = true;
|
newParagraph(' ', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'stanza') {
|
if (tag == 'subtitle') {
|
||||||
newParagraph(' ', 1);
|
newParagraph(' ', 1);
|
||||||
|
bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == 'epigraph') {
|
||||||
|
italic = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == 'poem') {
|
||||||
|
newParagraph(' ', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == 'text-author') {
|
||||||
|
newParagraph(' <s> <s> <s> ', 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEndNode = (elemName) => {// eslint-disable-line no-unused-vars
|
const onEndNode = (elemName) => {// eslint-disable-line no-unused-vars
|
||||||
if (tag == elemName) {
|
if (tag == elemName) {
|
||||||
if (tag == 'emphasis' || tag == 'strong') {
|
if (tag == 'binary') {
|
||||||
growParagraph(`</${tag}>`, 0);
|
binaryId = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('/fictionbook/body') == 0) {
|
||||||
|
if (tag == 'title') {
|
||||||
|
bold = false;
|
||||||
|
center = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (tag == 'title') {
|
if (tag == 'emphasis' || tag == 'strong') {
|
||||||
bold = false;
|
growParagraph(`</${tag}>`, 0);
|
||||||
center = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tag == 'subtitle') {
|
if (tag == 'subtitle') {
|
||||||
bold = false;
|
bold = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'epigraph') {
|
if (tag == 'epigraph') {
|
||||||
italic = false;
|
italic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'stanza') {
|
if (tag == 'stanza') {
|
||||||
newParagraph(' ', 1);
|
newParagraph(' ', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = path.substr(0, path.length - tag.length - 1);
|
path = path.substr(0, path.length - tag.length - 1);
|
||||||
@@ -206,12 +273,12 @@ export default class BookParser {
|
|||||||
let tOpen = (center ? '<center>' : '');
|
let tOpen = (center ? '<center>' : '');
|
||||||
tOpen += (bold ? '<strong>' : '');
|
tOpen += (bold ? '<strong>' : '');
|
||||||
tOpen += (italic ? '<emphasis>' : '');
|
tOpen += (italic ? '<emphasis>' : '');
|
||||||
let tClose = (center ? '</center>' : '');
|
let tClose = (italic ? '</emphasis>' : '');
|
||||||
tClose += (bold ? '</strong>' : '');
|
tClose += (bold ? '</strong>' : '');
|
||||||
tClose += (italic ? '</emphasis>' : '');
|
tClose += (center ? '</center>' : '');
|
||||||
|
|
||||||
if (path.indexOf('/fictionbook/body/title') == 0) {
|
if (path.indexOf('/fictionbook/body/title') == 0) {
|
||||||
newParagraph(`${tOpen}${text}${tClose}`, text.length, true);
|
growParagraph(`${tOpen}${text}${tClose}`, text.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.indexOf('/fictionbook/body/section') == 0) {
|
if (path.indexOf('/fictionbook/body/section') == 0) {
|
||||||
@@ -223,6 +290,10 @@ export default class BookParser {
|
|||||||
growParagraph(`${tOpen}${text}${tClose}`, text.length);
|
growParagraph(`${tOpen}${text}${tClose}`, text.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (binaryId) {
|
||||||
|
dimPromises.push(getImageDimensions(binaryId, binaryType, text));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onProgress = async(prog) => {
|
const onProgress = async(prog) => {
|
||||||
@@ -234,6 +305,14 @@ export default class BookParser {
|
|||||||
onStartNode, onEndNode, onTextNode, onProgress
|
onStartNode, onEndNode, onTextNode, onProgress
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (dimPromises.length) {
|
||||||
|
try {
|
||||||
|
await Promise.all(dimPromises);
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.fb2 = fb2;
|
this.fb2 = fb2;
|
||||||
this.para = para;
|
this.para = para;
|
||||||
|
|
||||||
@@ -270,18 +349,26 @@ export default class BookParser {
|
|||||||
splitToStyle(s) {
|
splitToStyle(s) {
|
||||||
let result = [];/*array of {
|
let result = [];/*array of {
|
||||||
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
||||||
|
image: Boolean,
|
||||||
|
imageId: String,
|
||||||
text: String,
|
text: String,
|
||||||
}*/
|
}*/
|
||||||
let style = {};
|
let style = {};
|
||||||
|
let image = {};
|
||||||
|
|
||||||
|
/*let attrs = sax.getAttrsSync(tail);
|
||||||
|
if (attrs.href.value)
|
||||||
|
newParagraph(' '.repeat(maxImageLineCount) + `<image href="${attrs.href.value}" />`, maxImageLineCount);
|
||||||
|
*/
|
||||||
const onTextNode = async(text) => {// eslint-disable-line no-unused-vars
|
const onTextNode = async(text) => {// eslint-disable-line no-unused-vars
|
||||||
result.push({
|
result.push({
|
||||||
style: Object.assign({}, style),
|
style: Object.assign({}, style),
|
||||||
text: text
|
image,
|
||||||
|
text
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onStartNode = async(elemName) => {// eslint-disable-line no-unused-vars
|
const onStartNode = async(elemName, tail) => {// eslint-disable-line no-unused-vars
|
||||||
switch (elemName) {
|
switch (elemName) {
|
||||||
case 'strong':
|
case 'strong':
|
||||||
style.bold = true;
|
style.bold = true;
|
||||||
@@ -292,6 +379,9 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = true;
|
style.center = true;
|
||||||
break;
|
break;
|
||||||
|
case 'image':
|
||||||
|
image = {};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -306,6 +396,9 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = false;
|
style.center = false;
|
||||||
break;
|
break;
|
||||||
|
case 'image':
|
||||||
|
image = {};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -313,7 +406,6 @@ export default class BookParser {
|
|||||||
onStartNode, onEndNode, onTextNode
|
onStartNode, onEndNode, onTextNode
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//длинные слова (или белиберду без пробелов) тоже разобьем
|
//длинные слова (или белиберду без пробелов) тоже разобьем
|
||||||
const maxWordLength = this.maxWordLength;
|
const maxWordLength = this.maxWordLength;
|
||||||
const parts = result;
|
const parts = result;
|
||||||
@@ -328,7 +420,7 @@ export default class BookParser {
|
|||||||
|
|
||||||
if (i - spaceIndex >= maxWordLength && i < p.text.length - 1 &&
|
if (i - spaceIndex >= maxWordLength && i < p.text.length - 1 &&
|
||||||
this.measureText(p.text.substr(spaceIndex + 1, i - spaceIndex), p.style) >= this.w - this.p) {
|
this.measureText(p.text.substr(spaceIndex + 1, i - spaceIndex), p.style) >= this.w - this.p) {
|
||||||
result.push({style: p.style, text: p.text.substr(0, i + 1)});
|
result.push({style: p.style, image: p.image, text: p.text.substr(0, i + 1)});
|
||||||
p = {style: p.style, text: p.text.substr(i + 1)};
|
p = {style: p.style, text: p.text.substr(i + 1)};
|
||||||
spaceIndex = -1;
|
spaceIndex = -1;
|
||||||
i = -1;
|
i = -1;
|
||||||
@@ -400,7 +492,9 @@ export default class BookParser {
|
|||||||
para.parsed.p === this.p &&
|
para.parsed.p === this.p &&
|
||||||
para.parsed.wordWrap === this.wordWrap &&
|
para.parsed.wordWrap === this.wordWrap &&
|
||||||
para.parsed.maxWordLength === this.maxWordLength &&
|
para.parsed.maxWordLength === this.maxWordLength &&
|
||||||
para.parsed.font === this.font
|
para.parsed.font === this.font &&
|
||||||
|
para.parsed.cutEmptyParagraphs === this.cutEmptyParagraphs &&
|
||||||
|
para.parsed.addEmptyParagraphs === this.addEmptyParagraphs
|
||||||
)
|
)
|
||||||
return para.parsed;
|
return para.parsed;
|
||||||
|
|
||||||
@@ -410,6 +504,12 @@ export default class BookParser {
|
|||||||
wordWrap: this.wordWrap,
|
wordWrap: this.wordWrap,
|
||||||
maxWordLength: this.maxWordLength,
|
maxWordLength: this.maxWordLength,
|
||||||
font: this.font,
|
font: this.font,
|
||||||
|
cutEmptyParagraphs: this.cutEmptyParagraphs,
|
||||||
|
addEmptyParagraphs: this.addEmptyParagraphs,
|
||||||
|
visible: !(
|
||||||
|
(this.cutEmptyParagraphs && para.cut) ||
|
||||||
|
(para.addIndex > this.addEmptyParagraphs)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -582,16 +682,19 @@ export default class BookParser {
|
|||||||
let paraIndex = this.findParaIndex(bookPos);
|
let paraIndex = this.findParaIndex(bookPos);
|
||||||
|
|
||||||
if (paraIndex === undefined)
|
if (paraIndex === undefined)
|
||||||
return result;
|
return null;
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
let parsed = this.parsePara(paraIndex);
|
let parsed = this.parsePara(paraIndex);
|
||||||
let i = this.findLineIndex(bookPos, parsed.lines);
|
let i = this.findLineIndex(bookPos, parsed.lines);
|
||||||
if (i === undefined)
|
if (i === undefined)
|
||||||
return result;
|
return null;
|
||||||
|
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
result.push(parsed.lines[i]);
|
if (parsed.visible) {
|
||||||
|
result.push(parsed.lines[i]);
|
||||||
|
n--;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i >= parsed.lines.length) {
|
if (i >= parsed.lines.length) {
|
||||||
@@ -599,21 +702,22 @@ export default class BookParser {
|
|||||||
if (paraIndex < this.para.length)
|
if (paraIndex < this.para.length)
|
||||||
parsed = this.parsePara(paraIndex);
|
parsed = this.parsePara(paraIndex);
|
||||||
else
|
else
|
||||||
return result;
|
break;
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n--;
|
|
||||||
}
|
}
|
||||||
} else if (n < 0) {
|
} else if (n < 0) {
|
||||||
n = -n;
|
n = -n;
|
||||||
let parsed = this.parsePara(paraIndex);
|
let parsed = this.parsePara(paraIndex);
|
||||||
let i = this.findLineIndex(bookPos, parsed.lines);
|
let i = this.findLineIndex(bookPos, parsed.lines);
|
||||||
if (i === undefined)
|
if (i === undefined)
|
||||||
return result;
|
return null;
|
||||||
|
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
result.push(parsed.lines[i]);
|
if (parsed.visible) {
|
||||||
|
result.push(parsed.lines[i]);
|
||||||
|
n--;
|
||||||
|
}
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
@@ -621,16 +725,15 @@ export default class BookParser {
|
|||||||
if (paraIndex >= 0)
|
if (paraIndex >= 0)
|
||||||
parsed = this.parsePara(paraIndex);
|
parsed = this.parsePara(paraIndex);
|
||||||
else
|
else
|
||||||
return result;
|
break;
|
||||||
i = parsed.lines.length - 1;
|
i = parsed.lines.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
n--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.length)
|
if (!result.length)
|
||||||
result = null;
|
result = null;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,8 @@ class BookManager {
|
|||||||
async init() {
|
async init() {
|
||||||
this.books = {};
|
this.books = {};
|
||||||
this.recent = {};
|
this.recent = {};
|
||||||
this.recentChanged = true;
|
this.recentChanged1 = true;
|
||||||
|
this.recentChanged2 = true;
|
||||||
|
|
||||||
let len = await bmMetaStore.length();
|
let len = await bmMetaStore.length();
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
@@ -169,7 +170,8 @@ class BookManager {
|
|||||||
await bmRecentStore.setItem(result.key, result);
|
await bmRecentStore.setItem(result.key, result);
|
||||||
await this.cleanRecentBooks();
|
await this.cleanRecentBooks();
|
||||||
|
|
||||||
this.recentChanged = true;
|
this.recentChanged1 = true;
|
||||||
|
this.recentChanged2 = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,14 +187,15 @@ class BookManager {
|
|||||||
|
|
||||||
await bmRecentStore.removeItem(value.key);
|
await bmRecentStore.removeItem(value.key);
|
||||||
delete this.recent[value.key];
|
delete this.recent[value.key];
|
||||||
this.recentChanged = true;
|
this.recentChanged1 = true;
|
||||||
|
this.recentChanged2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async cleanRecentBooks() {
|
async cleanRecentBooks() {
|
||||||
if (!this.recent)
|
if (!this.recent)
|
||||||
await this.init();
|
await this.init();
|
||||||
|
|
||||||
if (Object.keys(this.recent).length > 100) {
|
if (Object.keys(this.recent).length > 1000) {
|
||||||
let min = Date.now();
|
let min = Date.now();
|
||||||
let found = null;
|
let found = null;
|
||||||
for (let key in this.recent) {
|
for (let key in this.recent) {
|
||||||
@@ -211,7 +214,7 @@ class BookManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mostRecentBook() {
|
mostRecentBook() {
|
||||||
if (!this.recentChanged && this.mostRecentCached) {
|
if (!this.recentChanged1 && this.mostRecentCached) {
|
||||||
return this.mostRecentCached;
|
return this.mostRecentCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,10 +228,25 @@ class BookManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mostRecentCached = result;
|
this.mostRecentCached = result;
|
||||||
this.recentChanged = false;
|
this.recentChanged1 = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSortedRecent() {
|
||||||
|
if (!this.recentChanged2 && this.sortedRecentCached) {
|
||||||
|
return this.sortedRecentCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = Object.values(this.recent);
|
||||||
|
|
||||||
|
result.sort((a, b) => b.touchTime - a.touchTime);
|
||||||
|
|
||||||
|
this.sortedRecentCached = result;
|
||||||
|
this.recentChanged2 = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new BookManager();
|
export default new BookManager();
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<meta name="description" content="браузерная онлайн-читалка книг из интернета и библиотека">
|
||||||
|
<meta name="keywords" content="библиотека,онлайн,читалка,книги,читать,браузер,интернет">
|
||||||
<title></title>
|
<title></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const fonts = [
|
|||||||
{name: 'Arimo', fontVertShift: 0},
|
{name: 'Arimo', fontVertShift: 0},
|
||||||
{name: 'Avrile', fontVertShift: -10},
|
{name: 'Avrile', fontVertShift: -10},
|
||||||
{name: 'OpenSans', fontVertShift: -5},
|
{name: 'OpenSans', fontVertShift: -5},
|
||||||
{name: 'Roboto', fontVertShift: 10},
|
{name: 'Roboto', fontVertShift: 0},
|
||||||
{name: 'Rubik', fontVertShift: 0},
|
{name: 'Rubik', fontVertShift: 0},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -152,13 +152,18 @@ const settingDefaults = {
|
|||||||
scrollingDelay: 3000,// замедление, ms
|
scrollingDelay: 3000,// замедление, ms
|
||||||
scrollingType: 'ease-in-out', //linear, ease, ease-in, ease-out, ease-in-out
|
scrollingType: 'ease-in-out', //linear, ease, ease-in, ease-out, ease-in-out
|
||||||
|
|
||||||
pageChangeTransition: '',// '' - нет, downShift, rightShift, thaw - протаивание, blink - мерцание
|
pageChangeAnimation: 'blink',// '' - нет, downShift, rightShift, thaw - протаивание, blink - мерцание
|
||||||
pageChangeTransitionSpeed: 50, //0-100%
|
pageChangeAnimationSpeed: 80, //0-100%
|
||||||
|
|
||||||
allowUrlParamBookPos: false,
|
allowUrlParamBookPos: false,
|
||||||
lazyParseEnabled: false,
|
lazyParseEnabled: false,
|
||||||
copyFullText: false,
|
copyFullText: false,
|
||||||
showClickMapPage: true,
|
showClickMapPage: true,
|
||||||
|
clickControl: true,
|
||||||
|
cutEmptyParagraphs: false,
|
||||||
|
addEmptyParagraphs: 0,
|
||||||
|
blinkCachedLoad: true,
|
||||||
|
|
||||||
fontShifts: {},
|
fontShifts: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
6
docs/omnireader/old/.htaccess
Normal file
6
docs/omnireader/old/.htaccess
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#RewriteEngine On
|
||||||
|
#RewriteCond %{HTTP_HOST} ^www.bookpauk.ru$ [NC]
|
||||||
|
#RewriteRule ^(.*)$ http://bookpauk.ru/$1 [R=301,L]
|
||||||
|
|
||||||
|
Options None
|
||||||
|
Options +ExecCGI
|
||||||
BIN
docs/omnireader/old/apple-touch-icon-precomposed.png
Normal file
BIN
docs/omnireader/old/apple-touch-icon-precomposed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
docs/omnireader/old/apple-touch-icon.png
Normal file
BIN
docs/omnireader/old/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
2
docs/omnireader/old/config/config.js
Normal file
2
docs/omnireader/old/config/config.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
siteroot = 'http://old.omnireader.ru/';
|
||||||
|
doRedirect = '';
|
||||||
5
docs/omnireader/old/config/config.php
Normal file
5
docs/omnireader/old/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
$siteroot = 'http://old.omnireader.ru/';
|
||||||
|
$use_gzip = false;
|
||||||
|
$tmp_dir = '/tmp';
|
||||||
|
?>
|
||||||
447
docs/omnireader/old/f.php
Normal file
447
docs/omnireader/old/f.php
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
<?php
|
||||||
|
date_default_timezone_set('Europe/Moscow');
|
||||||
|
|
||||||
|
require_once 'config/config.php';
|
||||||
|
require_once 'parser.php';
|
||||||
|
|
||||||
|
define('LOWERCASE',3);
|
||||||
|
define('UPPERCASE',1);
|
||||||
|
|
||||||
|
function getParam($param, $defaultValue = '') {
|
||||||
|
$paramValue = (isset($_REQUEST[$param]) ? $_REQUEST[$param] : $defaultValue);
|
||||||
|
return $paramValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEncoding($str, $check_utf = FALSE) {
|
||||||
|
if (!$check_utf) {
|
||||||
|
$result = getEncoding(mb_convert_encoding($str, 'cp1251', 'UTF-8'), TRUE);
|
||||||
|
if ($result == 'w')
|
||||||
|
return 'u';
|
||||||
|
}
|
||||||
|
|
||||||
|
$charsets = Array(
|
||||||
|
'k' => 0,
|
||||||
|
'w' => 0,
|
||||||
|
'd' => 0,
|
||||||
|
'i' => 0,
|
||||||
|
'm' => 0
|
||||||
|
);
|
||||||
|
|
||||||
|
$length = strlen($str);
|
||||||
|
$block_size = ($length > 5*3000) ? 3000 : $length;
|
||||||
|
$counter = 0;
|
||||||
|
for ( $i = 0; $i < $length; $i++ ) {
|
||||||
|
$char = ord($str[$i]);
|
||||||
|
|
||||||
|
//non-russian characters
|
||||||
|
if ($char < 128 || $char > 256)
|
||||||
|
continue;
|
||||||
|
//CP866
|
||||||
|
if (($char > 159 && $char < 176) || ($char > 223 && $char < 242)) $charsets['d']+=LOWERCASE;
|
||||||
|
if (($char > 127 && $char < 160)) $charsets['d']+=UPPERCASE;
|
||||||
|
|
||||||
|
//KOI8-R
|
||||||
|
if (($char > 191 && $char < 223)) $charsets['k']+=LOWERCASE;
|
||||||
|
if (($char > 222 && $char < 256)) $charsets['k']+=UPPERCASE;
|
||||||
|
|
||||||
|
//WIN-1251
|
||||||
|
if ($char > 223 && $char < 256) $charsets['w']+=LOWERCASE;
|
||||||
|
if ($char > 191 && $char < 224) $charsets['w']+=UPPERCASE;
|
||||||
|
|
||||||
|
//MAC
|
||||||
|
if ($char > 221 && $char < 255) $charsets['m']+=LOWERCASE;
|
||||||
|
if ($char > 127 && $char < 160) $charsets['m']+=UPPERCASE;
|
||||||
|
|
||||||
|
//ISO-8859-5
|
||||||
|
if ($char > 207 && $char < 240) $charsets['i']+=LOWERCASE;
|
||||||
|
if ($char > 175 && $char < 208) $charsets['i']+=UPPERCASE;
|
||||||
|
|
||||||
|
$counter++;
|
||||||
|
if ($counter > $block_size) {
|
||||||
|
$counter = 0;
|
||||||
|
$i += (int)($length/2 - 2*$block_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($charsets);
|
||||||
|
if (preg_match('//u', $str))
|
||||||
|
return 'u';
|
||||||
|
else
|
||||||
|
return key($charsets);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTag($tagName, $book) {
|
||||||
|
$from_tag = '<' . $tagName . '>';
|
||||||
|
$to_tag = '</' . $tagName . '>';
|
||||||
|
$from = strpos($book, $from_tag);
|
||||||
|
$to = strpos($book, $to_tag);
|
||||||
|
if ($from === FALSE || $to === FALSE)
|
||||||
|
return '';
|
||||||
|
$from += strlen($from_tag);
|
||||||
|
return trim(substr($book, $from, $to - $from));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMetaInfoAndFilter($book, &$meta_info) {
|
||||||
|
$meta_info['author'] = '';
|
||||||
|
$meta_info['title'] = getTag('title', $book);
|
||||||
|
|
||||||
|
$out = $book;
|
||||||
|
|
||||||
|
//fb2 ??? ---------------------
|
||||||
|
if (strpos($meta_info['title'], '<p>') !== FALSE) {
|
||||||
|
$s = str_replace('</p>', '', $meta_info['title']);
|
||||||
|
$a = explode('<p>', $s);
|
||||||
|
$meta_info['author'] = parseHtml($a[1], TRUE);
|
||||||
|
$meta_info['title'] = parseHtml($a[2], TRUE);
|
||||||
|
if ($meta_info['title'] === NULL || $meta_info['title'] === '') {
|
||||||
|
$s = parseHtml($s, TRUE);
|
||||||
|
$meta_info['author'] = '';
|
||||||
|
$meta_info['title'] = $s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//samlib ----------------------
|
||||||
|
$samlib_start_sign = '<!----------- Ñîáñòâåííî ïðîèçâåäåíèå --------------->';
|
||||||
|
$samlib_book_idx = strpos($book, $samlib_start_sign);
|
||||||
|
if ($samlib_book_idx !== FALSE) {
|
||||||
|
$samlib_author = getTag('h3', $book);
|
||||||
|
$meta_info['author'] = substr($samlib_author, 0, strpos($samlib_author, ': <small>'));
|
||||||
|
$meta_info['title'] = getTag('h2', $book);;
|
||||||
|
$samlib_book_idx += strlen($samlib_start_sign);
|
||||||
|
$samlib_book_end_idx = strpos($book, '<!---- Áëîê îïèñàíèÿ ïðîèçâåäåíèÿ (ñëåâà âíèçó) ----------------------->');
|
||||||
|
$samlib_book_end_idx = ($samlib_book_end_idx === FALSE ? strlen($book) : $samlib_book_end_idx);
|
||||||
|
$out = '<dd>' . $meta_info['author'] . '<dd>' . $meta_info['title'] . '<empty-line/>' .
|
||||||
|
substr($book, $samlib_book_idx, $samlib_book_end_idx - $samlib_book_idx);
|
||||||
|
$out = preg_replace("/<dd>  [;]*\s*[\r\n]/", '<empty-line/>', $out);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterTextAndGzip($meta_info, $txtin) {
|
||||||
|
global $use_gzip;
|
||||||
|
|
||||||
|
if (strpos($txtin, '<P>') === FALSE) {
|
||||||
|
$len = strlen($txtin);
|
||||||
|
$counts = array();
|
||||||
|
|
||||||
|
$flag = 0;
|
||||||
|
$c = 0;
|
||||||
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
if ($txtin[$i] == chr(10) || $i == 0) {
|
||||||
|
$counts[$c]++;
|
||||||
|
if ($c > 0)
|
||||||
|
$counts[0]++;
|
||||||
|
$c = 0;
|
||||||
|
$flag = 1;
|
||||||
|
} else
|
||||||
|
if ($txtin[$i] != ' ')
|
||||||
|
$flag = 0;
|
||||||
|
else
|
||||||
|
if ($flag)
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($counts);
|
||||||
|
$key = 0;
|
||||||
|
if (count($counts) > 1) {
|
||||||
|
next($counts);
|
||||||
|
$key = key($counts);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$txtout .= print_r($counts, TRUE);
|
||||||
|
//$txtout .= $key;
|
||||||
|
|
||||||
|
$txtout = '';
|
||||||
|
$flag = 0;
|
||||||
|
$c = 0;
|
||||||
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
if ($txtin[$i] == chr(10) || $i == 0) {
|
||||||
|
$c = 0;
|
||||||
|
$flag = 1;
|
||||||
|
} else
|
||||||
|
if ($txtin[$i] != ' ') {
|
||||||
|
if ($c >= $key && $flag)
|
||||||
|
$txtout .= '<p>';
|
||||||
|
$flag = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ($flag)
|
||||||
|
$c++;
|
||||||
|
$txtout .= $txtin[$i];
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
$txtout = $txtin;
|
||||||
|
|
||||||
|
$txtout = 'no_file' . '|' . $meta_info['author'] . '|' . $meta_info['title'] .
|
||||||
|
'<<<bpr5A432688AB0467AA396E5A144830248Abpr>>>' . $txtout;
|
||||||
|
|
||||||
|
$supportsGzip = strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false;
|
||||||
|
if ($use_gzip && $supportsGzip && getParam('meta') == '' && getParam('curl') == '') {
|
||||||
|
$txtout = gzencode($txtout, 9);
|
||||||
|
header('Content-Encoding: gzip');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $txtout;
|
||||||
|
}
|
||||||
|
|
||||||
|
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
||||||
|
{
|
||||||
|
if (!(error_reporting() & $errno)) {
|
||||||
|
// Ýòîò êîä îøèáêè íå âêëþ÷åí â error_reporting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($errno == 8 /*|| $errno == 2*/)
|
||||||
|
return;
|
||||||
|
//throw new Exception("[$errno]: ($errstr) at $errfile line $errline");
|
||||||
|
throw new Exception("$errstr");
|
||||||
|
|
||||||
|
// Íå çàïóñêàåì âíóòðåííèé îáðàáîò÷èê îøèáîê PHP
|
||||||
|
return TRUE; // ñþäà õîäà íåò, íî ïóñòü áóäåò êàê øàáëîí
|
||||||
|
}
|
||||||
|
|
||||||
|
function unzip($filein) {
|
||||||
|
$zip = new ZipArchive;
|
||||||
|
$result = '';
|
||||||
|
if ($zip->open($filein) === TRUE) {
|
||||||
|
$filename = '';
|
||||||
|
$max_size = -1;
|
||||||
|
for($i = 0; $i < $zip->numFiles; $i++) {
|
||||||
|
$stat = $zip->statIndex($i);
|
||||||
|
$size = $stat['size'];
|
||||||
|
if ($size > $max_size) {
|
||||||
|
$max_size = $size;
|
||||||
|
$filename = $zip->getNameIndex($i);
|
||||||
|
$fp = $zip->getStream($filename);
|
||||||
|
if (!$fp)
|
||||||
|
throw new Exception("zip->getStream failed");
|
||||||
|
$result = stream_get_contents($fp);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
} else
|
||||||
|
throw new Exception("zip->open failed");
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_guid($namespace = '') {
|
||||||
|
$uid = md5(uniqid("", true));
|
||||||
|
$data = $namespace;
|
||||||
|
$data .= $_SERVER['REQUEST_TIME'];
|
||||||
|
$data .= $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
$data .= $_SERVER['LOCAL_ADDR'];
|
||||||
|
$data .= $_SERVER['LOCAL_PORT'];
|
||||||
|
$data .= $_SERVER['REMOTE_ADDR'];
|
||||||
|
$data .= $_SERVER['REMOTE_PORT'];
|
||||||
|
$hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function microtime_float()
|
||||||
|
{
|
||||||
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
|
return ((float)$usec + (float)$sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
function curlExec(/* Array */$curlOptions='', /* Array */$curlHeaders='', /* Array */$postFields='')
|
||||||
|
{
|
||||||
|
$newUrl = '';
|
||||||
|
$maxRedirection = 10;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ($maxRedirection<1) die('Error: reached the limit of redirections');
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
if (!empty($curlOptions)) curl_setopt_array($ch, $curlOptions);
|
||||||
|
if (!empty($curlHeaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeaders);
|
||||||
|
if (!empty($postFields))
|
||||||
|
{
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($newUrl)) curl_setopt($ch, CURLOPT_URL, $newUrl); // redirect needed
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||||
|
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
// Then, after your curl_exec call:
|
||||||
|
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||||
|
$header = substr($response, 0, $header_size);
|
||||||
|
$curlResult = substr($response, $header_size);
|
||||||
|
|
||||||
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$info = curl_getinfo($ch);
|
||||||
|
if (getParam('curl') != '') {;
|
||||||
|
throw new Exception("<br>" . str_replace("[", "<br>[", print_r($info, TRUE)) . "<br>$header<br>END");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code == 301 || $code == 302 || $code == 303 || $code == 307)
|
||||||
|
{
|
||||||
|
if (array_key_exists('redirect_url', $info) && !empty($info['redirect_url'])) {
|
||||||
|
$newUrl = trim($info['redirect_url']);
|
||||||
|
} else {
|
||||||
|
preg_match('/Location:(.*?)\n/', $header, $matches);
|
||||||
|
$newUrl = trim(array_pop($matches));
|
||||||
|
}
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
$maxRedirection--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else // no more redirection
|
||||||
|
{
|
||||||
|
if ($curlResult === FALSE || $info['http_code'] != 200) {
|
||||||
|
$curlResult = "ERROR ". $info['http_code'];
|
||||||
|
if (curl_error($ch))
|
||||||
|
$curlResult .= "<br>". curl_error($ch);
|
||||||
|
throw new Exception($curlResult);
|
||||||
|
} else {
|
||||||
|
$code = 0; //OK
|
||||||
|
curl_close($ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while($code);
|
||||||
|
return $curlResult;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
set_error_handler("myErrorHandler");
|
||||||
|
// set_time_limit(300);
|
||||||
|
|
||||||
|
$url = getParam('url');
|
||||||
|
try {
|
||||||
|
$body = '';
|
||||||
|
if ($url == '')
|
||||||
|
throw new Exception("íå çàäàí àäðåñ êíèãè");
|
||||||
|
|
||||||
|
$meta_info = array();
|
||||||
|
$time_start = $time = microtime_float();
|
||||||
|
|
||||||
|
$pid = create_guid();
|
||||||
|
$dir = 'txt/';
|
||||||
|
$encoding = getParam('encoding');
|
||||||
|
|
||||||
|
if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0)
|
||||||
|
$url = 'http://' . $url;
|
||||||
|
$url = str_replace('"', '', $url);
|
||||||
|
$url = str_replace('\'', '', $url);
|
||||||
|
$url = str_replace(']', '%5D', str_replace('[', '%5B', $url));
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
CURLOPT_RETURNTRANSFER => TRUE,
|
||||||
|
CURLOPT_TIMEOUT => 300,
|
||||||
|
CURLOPT_URL => $url,
|
||||||
|
CURLOPT_BUFFERSIZE => 1024*128,
|
||||||
|
CURLOPT_NOPROGRESS => FALSE,
|
||||||
|
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6",
|
||||||
|
CURLOPT_PROGRESSFUNCTION => function(
|
||||||
|
$DownloadSize, $Downloaded, $UploadSize, $Uploaded
|
||||||
|
) {
|
||||||
|
// If $Downloaded exceeds, returning non-0 breaks the connection!
|
||||||
|
return ($Downloaded > (50 * 1024 * 1024)) ? 1 : 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$out = curlExec($options);
|
||||||
|
|
||||||
|
$meta_info['time_curl'] = microtime_float() - $time;
|
||||||
|
$time = microtime_float();
|
||||||
|
|
||||||
|
//zip
|
||||||
|
if ($out[0] == chr(0x50) && $out[1] == chr(0x4B) && $out[2] == chr(0x03) && $out[3] == chr(0x04)) {
|
||||||
|
$zipped_file = $tmp_dir . "/{$pid}-temp.zip";
|
||||||
|
file_put_contents($zipped_file, $out);
|
||||||
|
$out = unzip($zipped_file);
|
||||||
|
if (file_exists($zipped_file)) unlink($zipped_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//pdf
|
||||||
|
/* if ($out[0] == chr(0x25) && $out[1] == chr(0x50) && $out[2] == chr(0x44) && $out[3] == chr(0x46)) {
|
||||||
|
$a = new PDF2Text();
|
||||||
|
$a->reset();
|
||||||
|
$a->decodePDF($out);
|
||||||
|
$out = $a->output();
|
||||||
|
file_put_contents('/tmp/1', $out);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$meta_info['time_unzip'] = microtime_float() - $time;
|
||||||
|
$time = microtime_float();
|
||||||
|
|
||||||
|
//decoding and parsing
|
||||||
|
if ($out !== FALSE) {
|
||||||
|
if ($encoding == '')
|
||||||
|
$encoding = getEncoding($out);
|
||||||
|
|
||||||
|
switch ($encoding) {
|
||||||
|
case 'k':
|
||||||
|
$out = mb_convert_encoding($out, 'cp1251', 'KOI8-R');
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
$out = mb_convert_encoding($out, 'cp1251', 'cp866');
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
$out = mb_convert_encoding($out, 'cp1251', 'ISO-8859-5');
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
$out = mb_convert_encoding($out, 'cp1251', 'MACINTOSH');
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
$out = mb_convert_encoding($out, 'cp1251', 'UTF-8');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//$out = $encoding . '===' . $out;
|
||||||
|
|
||||||
|
//file_put_contents('/tmp/bpr1', $out);
|
||||||
|
$meta_info['time_decodepage'] = microtime_float() - $time;
|
||||||
|
$time = microtime_float();
|
||||||
|
|
||||||
|
$out = getMetaInfoAndFilter($out, $meta_info);
|
||||||
|
|
||||||
|
$meta_info['time_metainfo'] = microtime_float() - $time;
|
||||||
|
$time = microtime_float();
|
||||||
|
|
||||||
|
$out = parseHtml($out);
|
||||||
|
|
||||||
|
$meta_info['time_parsehtml'] = microtime_float() - $time;
|
||||||
|
$time = microtime_float();
|
||||||
|
|
||||||
|
$out = filterTextAndGzip($meta_info, $out);
|
||||||
|
|
||||||
|
$meta_info['time_filter_gzip'] = microtime_float() - $time;
|
||||||
|
$meta_info['time_total'] = microtime_float() - $time_start;
|
||||||
|
|
||||||
|
$meta = getParam('meta');
|
||||||
|
if ($meta != '') {
|
||||||
|
$info = '';
|
||||||
|
foreach ($meta_info as $key => $value) {
|
||||||
|
if (strpos($key, 'time') !== FALSE)
|
||||||
|
$info .= sprintf("%06.3f", $value) . " $key <br>";
|
||||||
|
else
|
||||||
|
$info .= "$key: $value<br>";
|
||||||
|
}
|
||||||
|
throw new Exception("<br>" . $info);
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: text/plain; charset=windows-1251');
|
||||||
|
echo $out;
|
||||||
|
//file_put_contents('/tmp/bpr2', $out);
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
throw new Exception("îøèáêà çàãðóçêè ôàéëà. Ïîïðîáóéòå åùå ðàç.");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
header('Content-Type: text/html; charset=windows-1251');
|
||||||
|
$err = $e->getMessage();
|
||||||
|
if (strpos($err, 'ERROR 404') !== FALSE)
|
||||||
|
$err = 'ñòðàíèöà íå íàéäåíà';
|
||||||
|
$body = "Îøèáêà çàãðóçêè êíèãè: " . ($url == '' ? '' : "($url) ") . $err;
|
||||||
|
}
|
||||||
|
echo $body;
|
||||||
|
}
|
||||||
|
?>
|
||||||
BIN
docs/omnireader/old/favicon.ico
Normal file
BIN
docs/omnireader/old/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 227 B |
279
docs/omnireader/old/index.html
Normal file
279
docs/omnireader/old/index.html
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||||
|
<meta http-equiv="Content-Language" content="ru">
|
||||||
|
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
|
||||||
|
<meta name="description" content="áðàóçåðíàÿ îíëàéí-÷èòàëêà êíèã èç èíòåðíåòà">
|
||||||
|
<meta name="keywords" content="îíëàéí,÷èòàëêà,êíèãè,÷èòàòü,áðàóçåð,èíòåðíåò">
|
||||||
|
<title>Omni Reader - áðàóçåðíàÿ îíëàéí-÷èòàëêà</title>
|
||||||
|
<link rel="icon" type="image/gif" href="js/bpricon.gif">
|
||||||
|
<link rel="shortcut icon" type="image/gif" href="js/bpricon.gif">
|
||||||
|
<link rel="stylesheet" type="text/css" media="screen" href="js/stylex.css">
|
||||||
|
<script src="config/config.js" type="text/javascript"></script>
|
||||||
|
<script src="js/bpr318.js" type="text/javascript"></script>
|
||||||
|
<meta name="yandex-verification" content="be58752dfe93d304" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body onload="onLoa();">
|
||||||
|
|
||||||
|
<div style="display: none;" id="loading">
|
||||||
|
<img style="float:left;padding: 0; margin: 0" src="js/load.gif"></img>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<noscript>
|
||||||
|
<div class="over">JavaScript disabled
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<hr id="fhr">
|
||||||
|
|
||||||
|
<div id="win">
|
||||||
|
<div id="header" class="header">
|
||||||
|
</div>
|
||||||
|
<!-- MAIN DIV -->
|
||||||
|
<div id="main">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="podk" id="comm">
|
||||||
|
<div style="background-color: rgb(34, 34, 0); color: rgb(235, 226, 201);" class="menuCross" id="mcross" onclick="menu();return false;">x
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div style="text-decoration: underline; text-align: center"><span>ÌÅÍÞ</span></div>
|
||||||
|
<div class="melem">
|
||||||
|
<br>
|
||||||
|
<a href="/?#" onclick="goTo();return false;">Íà ñòðàíèöó: </a>
|
||||||
|
<b onmousedown="gpa=1;pageGoto(1);" onmouseup="gpa=0;" onmouseout="gpa=0;"><</b>
|
||||||
|
<input value="1" style="color: rgb(34, 34, 0);" id="pageGoto" size="3" maxlength="4" type="text" onkeydown="if (event.keyCode == 13) {goTo();return false;}">
|
||||||
|
<b onmousedown="gpa=1;pageGoto(0);" onmouseup="gpa=0;" onmouseout="gpa=0;">></b>
|
||||||
|
|
||||||
|
<a href="/?#" onclick="goTo();return false;">Ok</a>
|
||||||
|
<br>
|
||||||
|
<a href="/?#" onclick="return statusPanel();">Ïàíåëü ñòàòóñà(px): </a>
|
||||||
|
<input style="color: rgb(34, 34, 0);" id="id_sp_size" size="3" maxlength="3" type="text" onkeydown="if (event.keyCode == 13) return statusPanel();">
|
||||||
|
<a href="/?#" onclick="return statusPanel();">Ok</a>
|
||||||
|
<br>
|
||||||
|
<a href="/?#" onclick="return statusPanel();">Ñêðîëëèíã(ms): </a>
|
||||||
|
<input style="color: rgb(34, 34, 0);" id="id_sc_int" size="3" maxlength="3" type="text" onkeydown="if (event.keyCode == 13) return scrollInterval();">
|
||||||
|
<a href="/?#" onclick="return scrollInterval();">Ok</a>
|
||||||
|
<br>
|
||||||
|
<label>Ïîëîñà ïðîêðóòêè<input id="id_scroll" type="checkbox" onclick="return showScroll()"></label>
|
||||||
|
<br>
|
||||||
|
<label>Óïðàâëåíèå êëèêîì<input id="id_by_click" type="checkbox" onclick="return byClick()"></label>
|
||||||
|
<br><br>
|
||||||
|
<a href="/?#Íàñòðîèòü öâåò è øðèôò" onclick="colorMenu();return false;">Íàñòðîèòü öâåò è øðèôò</a>
|
||||||
|
<br>
|
||||||
|
<a href="/?#Ñïðàâêà" onclick="legend(1);return false;">Ñïðàâêà</a>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="top: 172px; left: 423px" id="colorSelect">
|
||||||
|
<div style="background-color: rgb(34, 34, 0); color: rgb(235, 226, 201);" class="colorCross" id="cross" onclick="colorClose(); return false;">x
|
||||||
|
</div>
|
||||||
|
<div class="colorImage" onclick="colorSet(); return false;">
|
||||||
|
</div>
|
||||||
|
<div style="border-color: rgb(136, 132, 100);" class="colorMenu">
|
||||||
|
<div style="position:absolute;top:180px;left:0px;">
|
||||||
|
<div onclick="colorFontTemp=1; setSelectedFontItem(); return false;" onmouseover="this.style.backgroundColor='#0FA';" onmouseout="this.style.background='none';">
|
||||||
|
<span id="fontItemText"> Òåêñò</span>
|
||||||
|
</div>
|
||||||
|
<input onchange="colorChange(1,this.value);" id="fcolor" size="8" maxlength="7" type="text" onkeydown="if (event.keyCode == 13) {colorChange(1,this.value);return false;}">
|
||||||
|
<br>
|
||||||
|
<div onclick="colorFontTemp=0; setSelectedFontItem(); return false;" onmouseover="this.style.backgroundColor='#0FA';" onmouseout="this.style.background='none';">
|
||||||
|
<span id="fontItemBack"> Ôîí</span>
|
||||||
|
</div>
|
||||||
|
<input onchange="colorChange(2,this.value);" id="bcolor" size="8" maxlength="7" type="text" onkeydown="if (event.keyCode == 13) {colorChange(2,this.value);return false;}">
|
||||||
|
<br>
|
||||||
|
<div>
|
||||||
|
Ðàçìåð
|
||||||
|
</div>
|
||||||
|
<input onchange="colorChange(3,this.value);" id="fsize" size="8" maxlength="3" type="text" onkeydown="if (event.keyCode == 13) {colorChange(3,this.value);return false;}">
|
||||||
|
<br>
|
||||||
|
<div>
|
||||||
|
Øðèôò
|
||||||
|
</div>
|
||||||
|
<select id="ffamily" onchange="gdb('ffamily2').value='';colorChange(4,this.value);">
|
||||||
|
<option>Trebuchet Ms</option>
|
||||||
|
<option>Serif</option>
|
||||||
|
<option>Arial</option>
|
||||||
|
<option>Times New Roman</option>
|
||||||
|
<option>Sans-Serif</option>
|
||||||
|
<option>Tahoma</option>
|
||||||
|
<option>Verdana</option>
|
||||||
|
<option>Lucida Sans Unicode</option>
|
||||||
|
</select>
|
||||||
|
<br>
|
||||||
|
<div>
|
||||||
|
Ñâîé
|
||||||
|
</div>
|
||||||
|
<input onchange="colorChange(4,this.value);" id="ffamily2" size="8" maxlength="70" type="text" onkeydown="if (event.keyCode == 13) {colorChange(4,this.value);return false;}">
|
||||||
|
</div>
|
||||||
|
<div class="colorExample" style="cursor: pointer; height: 24px; bottom: 0px; background-color: rgb(204, 238, 255); border-top: 2px solid rgb(136, 132, 100); line-height: 26px; border-color: rgb(136, 132, 100);" onmouseover="this.style.backgroundColor='#CFC';" onmouseout="this.style.backgroundColor='#CEF';" onclick="colorSubmit();">
|
||||||
|
OK
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="clrdiv" class="colorExample" style="top: 78px; border-bottom: 2px solid rgb(136, 132, 100); color: rgb(34, 34, 0); background-color: rgb(235, 226, 201); border-color: rgb(136, 132, 100);overflow: hidden;">
|
||||||
|
Ïðèìåð.
|
||||||
|
</div>
|
||||||
|
<div id="clrdiv2" class="colorExample" style="top: 0px; font-size: 21px; color: rgb(34, 34, 0); background-color: rgb(235, 226, 201);overflow: hidden;">
|
||||||
|
Ðåçóëüòàò.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="dop" style="display:none">
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<br><h4><strong>Omni Reader - áðàóçåðíàÿ îíëàéí-÷èòàëêà.</strong></h4>
|
||||||
|
<br>Äîáðî ïîæàëîâàòü!
|
||||||
|
<br><br><br>
|
||||||
|
<div class="addr">
|
||||||
|
<div align="left" style="text-indent: 0">Àäðåñ êíèãè (URL):
|
||||||
|
</div>
|
||||||
|
<input class="book" id="book" style="width:70%" type="text" onkeydown="if (event.keyCode == 13) gdb('btnOk').click()">
|
||||||
|
<input class="book" id="btnOk" value="ÎÊ" onclick="location.href=siteroot + '?url=' + gdb('book').value;" type="button">
|
||||||
|
<div align="left" style="text-indent: 0;font-size: 12px;line-height:16px">
|
||||||
|
<b><a href="http://samlib.ru/comment/b/bookpauk/bookpauk_reader" target="_blank">Êîììåíòèðîâàòü</a></b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="id_add"></div>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<br><br><strong>Âîçìîæíîñòè ÷èòàëêè:</strong>
|
||||||
|
<p>- çàãðóçêà ëþáîé ñòðàíèöû èíòåðíåòà
|
||||||
|
<p>- ïîäêëþ÷åíèå ê èíòåðíåòó íå îáÿçàòåëüíî äëÿ ÷òåíèÿ êíèãè ïîñëå åå çàãðóçêè
|
||||||
|
<p>- âîçìîæíîñòü èçìåíèòü öâåò ôîíà, òåêñòà, ðàçìåð è òèï øðèôòà, ðàçìåð ïàíåëè ñòàòóñà
|
||||||
|
<p>- çàïîìèíàíèå òåêóùåé ïîçèöèè è íàñòðîåê â áðàóçåðå
|
||||||
|
<p>- ïåðåõîä íà çàäàííóþ ñòðàíèöó
|
||||||
|
<p>- ïëàâíûé ñêðîëëèíã òåêñòà
|
||||||
|
<p>- óïðàâëåíèå êëèêîì äëÿ ñåíñîðíûõ ýêðàíîâ
|
||||||
|
<p>- ðåãèñòðàöèÿ íå òðåáóåòñÿ
|
||||||
|
|
||||||
|
<br><br> êà÷åñòâå URL ìîæíî çàäàâàòü html-ñòðàíè÷êó ñ êíèãîé, ëèáî ïðÿìóþ ññûëêó íà ôàéë èç îíëàéí-áèáëèîòåêè (íàïðèìåð, ñêîïèðîâàâ àäðåñ ññûëêè èëè êíîïêè "ñêà÷àòü fb2").
|
||||||
|
Ïîääåðæèâàåìûå ôîðìàòû: <strong>html, txt, fb2, fb2.zip</strong>
|
||||||
|
|
||||||
|
<br><br>Âû ìîæåòå äîáàâèòü â ñâîé áðàóçåð çàêëàäêó, óêàçàâ â åå ñâîéñòâàõ âìåñòî àäðåñà ñëåäóþùèé êîä:
|
||||||
|
<br><p><strong>javascript:location.href='http://old.omnireader.ru/?url='+location.href;</strong>
|
||||||
|
<br>Òîãäà, íàæàâ íà ïîëó÷èâøóþñÿ êíîïêó íà ëþáîé ñòðàíèöå èíòåðíåòà, âû àâòîìàòè÷åñêè îòêðîåòå åå â Omni Reader.
|
||||||
|
|
||||||
|
<br><br>Äëÿ Chrome íà Android ìîæíî âûçûâàòü çàêëàäêó ïî åå èìåíè (èìÿ ñòîèò ñäåëàòü ïîïðîùå) â àäðåñíîé ñòðîêå áðàóçåðà, ïîñêîëüêó ñòàíäàðòíûé âûçîâ òàêîé çàêëàäêè íå ðàáîòàåò.
|
||||||
|
|
||||||
|
<br><br>Êîëè÷åñòâî è íóìåðàöèÿ ñòðàíèö â ÷èòàëêå çàâèñèò îò ðàçìåðà îêíà áðàóçåðà.
|
||||||
|
|
||||||
|
<br><br><strong>Ïîïóëÿðíûå ðåñóðñû ñ êíèãàìè è ýëåêòðîííûå áèáëèîòåêè:</strong>
|
||||||
|
<br><p><a href="http://samlib.ru" target="_blank">samlib.ru</a>
|
||||||
|
<br><p><a href="http://flibusta.is" target="_blank">flibusta.is</a>
|
||||||
|
<br><p><a href="http://fantasy-worlds.org" target="_blank">fantasy-worlds.org</a>
|
||||||
|
<br><p><a href="http://www.litmir.co" target="_blank">www.litmir.co</a>
|
||||||
|
<br><p><a href="http://lib.ru" target="_blank">lib.ru</a>
|
||||||
|
|
||||||
|
<br><br><strong>Ïðè íåîáõîäèìîñòè çàãðóçèòü ôàéë ñ ëîêàëüíîãî äèñêà â ÷èòàëêó</strong>, ìîæíî âîñïîëüçîâàòüñÿ îäíèì èç ôàéëîîáìåííûõ
|
||||||
|
ñåðâèñîâ. Ðåêîìåíäóåìûå ôàéëîîáìåííèêè:
|
||||||
|
<br><p><a href="http://fayloobmennik.cloud" target="_blank">fayloobmennik.cloud</a>
|
||||||
|
<br><p><a href="http://zaix.ru" target="_blank">zaix.ru</a>
|
||||||
|
|
||||||
|
<br><br>Ïîñëå çàãðóçêè ôàéëà íà îáìåííèê, ïðÿìóþ ññûëêó íà ôàéë íåîáõîäèìî ñêîïèðîâàòü â ïîëå "Àäðåñ êíèãè" (ñì. âûøå).
|
||||||
|
|
||||||
|
<br><br><strong>Èçâåñòíûå ïðîáëåìû:</strong>
|
||||||
|
<p>- ïðè èçìåíåíèè/ïðèìåíåíèè íàñòðîåê áûâàþò ñáîè èç-çà ìàñøòàáèðîâàíèÿ ñòðàíèöû. Ïîìîãàåò îáíîâëåíèå ñòðàíèöû â áðàóçåðå.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="leg" onclick="legend();">
|
||||||
|
<br>
|
||||||
|
<b>Óïðàâëåíèå:</b>
|
||||||
|
<p>M - ÌÅÍÞ
|
||||||
|
<p>PgUp, Left, Shift+Space, Backspace - ñòðàíèöó íàçàä
|
||||||
|
<p>PgDown, Right, Space, Enter - ñòðàíèöó âïåð¸ä
|
||||||
|
<p>Home - â íà÷àëî êíèãè
|
||||||
|
<p>End - â êîíåö êíèãè
|
||||||
|
<p>Up - ñòðî÷êó íàçàä
|
||||||
|
<p>Down - ñòðî÷êó âïåð¸ä
|
||||||
|
<p>A, Shift+A - èçìåíèòü ðàçìåð øðèôòà
|
||||||
|
<p>S - ïîêàçàòü/ñêðûòü ïîëîñó ïðîêðóòêè
|
||||||
|
<p>T - âêëþ÷èòü/îòêëþ÷èòü óïðàâëåíèå êëèêîì
|
||||||
|
<p>F, F11, ` (àïîñòðîô) - âêë./âûêë. ïîëíûé ýêðàí
|
||||||
|
<p>Z, Shift+Down - ïëàâíûé ñêðîëëèíã òåêñòà
|
||||||
|
<p>Shift+Left/Shift+Right - óâåëè÷èòü/óìåíüøèòü èíòåðâàë ñêðîëëèíãà
|
||||||
|
<p>R - ïðèíóäèòåëüíî îáíîâèòü êíèãó â îáõîä êýøà
|
||||||
|
|
||||||
|
<br><br><strong>Óïðàâëåíèå íà ñåíñîðíûõ ýêðàíàõ (êëèêîì):</strong>
|
||||||
|
<p>PgUp-------Up------PgUp
|
||||||
|
<p>PgDown---Menu---PgDown
|
||||||
|
<p>PgDown---Down---PgDown
|
||||||
|
|
||||||
|
<div id="top100">
|
||||||
|
<div id="id_add2"></div>
|
||||||
|
<br>
|
||||||
|
<!-- Yandex.Metrika informer --><a href="https://metrika.yandex.ru/stat/?id=31398038&from=informer"target="_blank" rel="nofollow"><img src="https://mc.yandex.ru/informer/31398038/3_1_FFFFFFFF_EFEFEFFF_0_pageviews"style="width:88px; height:31px; border:0;" alt="ßíäåêñ.Ìåòðèêà" title="ßíäåêñ.Ìåòðèêà: äàííûå çà ñåãîäíÿ (ïðîñìîòðû, âèçèòû è óíèêàëüíûå ïîñåòèòåëè)" onclick="try{Ya.Metrika.informer({i:this,id:31398038,lang:'ru'});return false}catch(e){}" /></a><!-- /Yandex.Metrika informer --> <!-- Yandex.Metrika counter --><script type="text/javascript"> (function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter31398038 = new Ya.Metrika({ id:31398038, clickmap:true, trackLinks:true, accurateTrackBounce:true }); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = "https://mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="https://mc.yandex.ru/watch/31398038" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer" class="footer">
|
||||||
|
<div id="id_lp" style="position: absolute; left: 0">
|
||||||
|
<div id="bmain" class="page">
|
||||||
|
<a href="/"><span title="Âåðíóòüñÿ íà ãëàâíóþ"> <<< </span></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div class="cpage" onclick="menu();return false;">
|
||||||
|
<span title="M - ïîêàçàòü/ñêðûòü ìåíþ">ÌÅÍÞ</span>
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div class="cpage" onclick="toggleFullScreen();return false;">
|
||||||
|
<span title="F, F11, ` (àïîñòðîô) - âêë./âûêë. ïîëíûé ýêðàí"><---></span>
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div class="cpage" onclick="incFont(1);return false;">
|
||||||
|
<span title="A - óâåëè÷èòü ðàçìåð øðèôòà">A+</span>
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div class="cpage" onclick="incFont(-1);return false;">
|
||||||
|
<span title="Shift+A - óìåíüøèòü ðàçìåð øðèôòà">A-</span>
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div class="cpage" onclick="return toggleScroll();">
|
||||||
|
<span title="Z, Shift+Down - âêë./âûêë. ïëàâíûé ñêðîëëèíã òåêñòà">$</span>
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
<div id="reload" class="cpage" onclick="return reloadBook();">
|
||||||
|
<span title="R - ïðèíóäèòåëüíî îáíîâèòü êíèãó â îáõîä êýøà">@</span>
|
||||||
|
</div>
|
||||||
|
<div class="page" style="width: 20px">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="orig" class="page">
|
||||||
|
<a id="orig_href" href="" target="_blank"> </a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="id_rp" style="position: absolute; right: 0">
|
||||||
|
<div id="pageCount" class="page">
|
||||||
|
<div onmousedown="pageMove(1);" onmouseout="pageMoveClear();" onmouseup="pageMoveClear();"><
|
||||||
|
</div>
|
||||||
|
<div onclick="pageMoveShow();" style="visibility:visible;">1/1
|
||||||
|
</div>
|
||||||
|
<div onmousedown="pageMove(0); " onmouseout="pageMoveClear();" onmouseup="pageMoveClear();"> >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pagePercent" class="page">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="tm" class="page">
|
||||||
|
</div>
|
||||||
|
<div class="page">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
1
docs/omnireader/old/info.txt
Normal file
1
docs/omnireader/old/info.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
omnireader.ru
|
||||||
1253
docs/omnireader/old/js/bpr318.js
Normal file
1253
docs/omnireader/old/js/bpr318.js
Normal file
File diff suppressed because it is too large
Load Diff
BIN
docs/omnireader/old/js/bpricon.gif
Normal file
BIN
docs/omnireader/old/js/bpricon.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 246 B |
BIN
docs/omnireader/old/js/colo58.png
Normal file
BIN
docs/omnireader/old/js/colo58.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 193 KiB |
BIN
docs/omnireader/old/js/load.gif
Normal file
BIN
docs/omnireader/old/js/load.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
438
docs/omnireader/old/js/stylex.css
Normal file
438
docs/omnireader/old/js/stylex.css
Normal file
@@ -0,0 +1,438 @@
|
|||||||
|
*
|
||||||
|
{
|
||||||
|
margin:0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
font: 21px/26px 'Comic Sans Ms', Fantasy;
|
||||||
|
color: #FFFFFF;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background-color: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
position:absolute;
|
||||||
|
left:1%;
|
||||||
|
width: 98%;
|
||||||
|
height: 1px;
|
||||||
|
bottom: 22px;
|
||||||
|
color:#000000;
|
||||||
|
border: none;
|
||||||
|
z-index:6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#win {
|
||||||
|
display:none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
width: 94.9%;
|
||||||
|
padding-left: 2.5%;
|
||||||
|
padding-right: 2.5%;
|
||||||
|
font: 21px/26px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
color: #220;
|
||||||
|
float:left;
|
||||||
|
position:relative;
|
||||||
|
top:0px;
|
||||||
|
text-align: justify;
|
||||||
|
overflow:hidden;
|
||||||
|
overflow-y:auto;
|
||||||
|
/*border:1px solid #000;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#main span
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
text-indent:7%;
|
||||||
|
clear:both;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main p
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
text-indent:7%;
|
||||||
|
clear:both;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main dd
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
text-indent:7%;
|
||||||
|
clear:both;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main div
|
||||||
|
{
|
||||||
|
text-indent:7%;
|
||||||
|
clear:both;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#main span p
|
||||||
|
{
|
||||||
|
text-indent:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main span div
|
||||||
|
{
|
||||||
|
text-indent:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#main img
|
||||||
|
{
|
||||||
|
border:0px;
|
||||||
|
vertical-align:top;float:left;
|
||||||
|
|
||||||
|
padding:0px;
|
||||||
|
line-height:0px;
|
||||||
|
font-size:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.podk
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
border:3px solid #220;
|
||||||
|
display:none;
|
||||||
|
z-index:9;
|
||||||
|
height:280px;
|
||||||
|
width:264px;
|
||||||
|
font: bold 16px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.podk span
|
||||||
|
{
|
||||||
|
text-align:center;
|
||||||
|
font: 21px/21px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.melem {
|
||||||
|
padding-left: 20px;
|
||||||
|
line-height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.melem label {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.melem label input {
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
border:0;
|
||||||
|
left: 10px;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.melem input
|
||||||
|
{
|
||||||
|
background-color:transparent;
|
||||||
|
border:0px solid #fff;
|
||||||
|
font: bold 14px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
text-align:center;
|
||||||
|
height: 18px;
|
||||||
|
border:1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.melem b
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.over
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
color:#500;
|
||||||
|
background-color:black;
|
||||||
|
text-align:center;
|
||||||
|
vertical-align:middle;
|
||||||
|
width:100%;
|
||||||
|
height:10050px;
|
||||||
|
position:absolute;
|
||||||
|
right:0px;
|
||||||
|
bottom:0px;
|
||||||
|
z-index:15;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#loading
|
||||||
|
{
|
||||||
|
background-color:black;
|
||||||
|
font: 40px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
align:center;
|
||||||
|
color:#FFFFFF;
|
||||||
|
position:absolute;
|
||||||
|
left:48%;
|
||||||
|
bottom:50%;
|
||||||
|
z-index:16;
|
||||||
|
}
|
||||||
|
|
||||||
|
a
|
||||||
|
{
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
a:hover
|
||||||
|
{
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer div a:hover, div#comm div a:hover
|
||||||
|
{
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tl
|
||||||
|
{
|
||||||
|
width:14px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
#tr
|
||||||
|
{
|
||||||
|
width:14px;
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header
|
||||||
|
{
|
||||||
|
height: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
display: none;
|
||||||
|
font: 18px/21px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
width:100%;
|
||||||
|
height:22px;
|
||||||
|
position:absolute;
|
||||||
|
bottom:0px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page, .cpage
|
||||||
|
{
|
||||||
|
position:relative;
|
||||||
|
float: left;
|
||||||
|
vertical-align: bottom;
|
||||||
|
border: 0px solid yellow;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cpage
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tm
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#pageCount
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#pagePercent
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#bmain
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
div#pageCount div
|
||||||
|
{
|
||||||
|
overflow:hidden;
|
||||||
|
float:left;
|
||||||
|
cursor:pointer;
|
||||||
|
text-align:center;
|
||||||
|
visibility:hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.l
|
||||||
|
{
|
||||||
|
left:17px;
|
||||||
|
float:left;
|
||||||
|
margin-left:0;
|
||||||
|
}
|
||||||
|
.t
|
||||||
|
{
|
||||||
|
top:4px;
|
||||||
|
}
|
||||||
|
.b
|
||||||
|
{
|
||||||
|
bottom:4px;
|
||||||
|
}
|
||||||
|
.r
|
||||||
|
{
|
||||||
|
right:17px;
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
.a
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
line-height:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr {
|
||||||
|
width:80%;
|
||||||
|
margin-left: 21%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#book
|
||||||
|
{
|
||||||
|
border-right:0px solid #fff !important;
|
||||||
|
}
|
||||||
|
.book
|
||||||
|
{
|
||||||
|
background-color:transparent;
|
||||||
|
border:2px groove #000;
|
||||||
|
font: bold 16px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
height: 26px;
|
||||||
|
padding:0;
|
||||||
|
margin:0;
|
||||||
|
display:block;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
#btnOk
|
||||||
|
{
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#book:hover
|
||||||
|
{
|
||||||
|
border-left:2px ridge #000;
|
||||||
|
}
|
||||||
|
.book:hover
|
||||||
|
{
|
||||||
|
border:2px ridge #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#leg
|
||||||
|
{
|
||||||
|
font: bold 12px Verdana, Sans-Serif;
|
||||||
|
line-height:12px;
|
||||||
|
width:60%;
|
||||||
|
height:60%;
|
||||||
|
background-color:#fff;
|
||||||
|
color:#000;
|
||||||
|
border:4px double black;
|
||||||
|
padding:20px;
|
||||||
|
text-align: justify;
|
||||||
|
z-index:16;
|
||||||
|
position:absolute;
|
||||||
|
overflow:scroll;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
#leg b
|
||||||
|
{
|
||||||
|
color: #AA2222;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*êåëâ àüþìî÷ ôàåï÷ START*/
|
||||||
|
div#colorSelect
|
||||||
|
{
|
||||||
|
width:758px;
|
||||||
|
height:600px;
|
||||||
|
z-index:20;
|
||||||
|
display:none;
|
||||||
|
position:absolute;
|
||||||
|
color:#220;
|
||||||
|
}
|
||||||
|
div.colorImage
|
||||||
|
{
|
||||||
|
width:600px;
|
||||||
|
height:600px;
|
||||||
|
background:url(/js/colo58.png);
|
||||||
|
float:right;
|
||||||
|
cursor:crosshair;
|
||||||
|
}
|
||||||
|
div.colorMenu
|
||||||
|
{
|
||||||
|
overflow:hidden;
|
||||||
|
width:150px;
|
||||||
|
height:330px;
|
||||||
|
border: 3px solid #000;
|
||||||
|
position:relative;
|
||||||
|
background-color:white;
|
||||||
|
font: 20px/22px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
top:150px;
|
||||||
|
}
|
||||||
|
div.colorMenu div div
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
float:left;
|
||||||
|
width:76px;
|
||||||
|
}
|
||||||
|
div.colorMenu div input
|
||||||
|
{
|
||||||
|
float:right;
|
||||||
|
height:18px;
|
||||||
|
width:70px;
|
||||||
|
border: 1px solid #000;
|
||||||
|
margin:1px 0px;
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.colorMenu div select
|
||||||
|
{
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.colorExample
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
width:150px;
|
||||||
|
height:78px;
|
||||||
|
font: 21px/78px 'Trebuchet Ms', Sans-Serif;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
div.colorCross
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
top:143px;
|
||||||
|
left:147px;
|
||||||
|
width:14px;
|
||||||
|
height:14px;
|
||||||
|
z-index:21;
|
||||||
|
cursor:pointer;
|
||||||
|
line-height:7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.menuCross
|
||||||
|
{
|
||||||
|
font: 21px/26px 'Comic Sans Ms', Fantasy;
|
||||||
|
position:absolute;
|
||||||
|
top:-8px;
|
||||||
|
left: 258px;
|
||||||
|
width:14px;
|
||||||
|
height:14px;
|
||||||
|
z-index:21;
|
||||||
|
cursor:pointer;
|
||||||
|
line-height:7px;
|
||||||
|
}
|
||||||
|
/*êåëâ àüþìî÷ ôàåï÷ END*/
|
||||||
|
|
||||||
|
.test {
|
||||||
|
border: 1px solid #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#cbscroll {
|
||||||
|
padding-top: 3px;
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
96
docs/omnireader/old/parser.php
Normal file
96
docs/omnireader/old/parser.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function parseHtml($data, $remove_tags = FALSE) {
|
||||||
|
$substs = array(
|
||||||
|
//html
|
||||||
|
'TD' => chr(9),
|
||||||
|
'TH' => chr(9),
|
||||||
|
'TR' => chr(13) . chr(10) . '<P>',
|
||||||
|
'BR' => chr(13) . chr(10) . '<P>',
|
||||||
|
'BR/' => chr(13) . chr(10) . '<P>',
|
||||||
|
'DD' => chr(13) . chr(10) . '<P>',
|
||||||
|
'P' => chr(13) . chr(10) . '<P>',
|
||||||
|
'HR' => chr(13) . chr(10),
|
||||||
|
'LI' => chr(13) . chr(10),
|
||||||
|
'OL' => chr(13) . chr(10),
|
||||||
|
'/OL' => chr(13) . chr(10),
|
||||||
|
'TABLE' => chr(13) . chr(10),
|
||||||
|
'/TABLE' => chr(13) . chr(10),
|
||||||
|
'TITLE' => '<br> ',
|
||||||
|
'/TITLE' => '<br> ',
|
||||||
|
'UL' => chr(13) . chr(10) . ' ',
|
||||||
|
'/UL' => chr(13) . chr(10),
|
||||||
|
|
||||||
|
// fb2
|
||||||
|
'EMPTY-LINE/' => '<P> ',
|
||||||
|
'STANZA' => '<P> ',
|
||||||
|
'V' => '<P>',
|
||||||
|
'/POEM' => '<P> ',
|
||||||
|
'SUBTITLE' => '<br> <P>',
|
||||||
|
'/SUBTITLE' => '<br> ',
|
||||||
|
);
|
||||||
|
|
||||||
|
$inner_cut = array(
|
||||||
|
'HEAD' => 1,
|
||||||
|
'SCRIPT' => 1,
|
||||||
|
'STYLE' => 1,
|
||||||
|
//fb2
|
||||||
|
'BINARY' => 1,
|
||||||
|
'DESCRIPTION' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($remove_tags)
|
||||||
|
$substs = $inner_cut = array();
|
||||||
|
|
||||||
|
|
||||||
|
$data = str_replace(' ', ' ', $data);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$len = strlen($data);
|
||||||
|
$out = '';
|
||||||
|
$cut_counter = 0;
|
||||||
|
$cut_tag = '';
|
||||||
|
while ($i < $len) {
|
||||||
|
$left = strpos($data, '<', $i);
|
||||||
|
if ($left !== FALSE) {
|
||||||
|
$right = strpos($data, '>', $left + 1);
|
||||||
|
if ($right !== FALSE) {
|
||||||
|
$tag = trim(substr($data, $left + 1, $right - $left - 1));
|
||||||
|
$first_space = strpos($tag, ' ');
|
||||||
|
if ($first_space !== FALSE)
|
||||||
|
$tag = substr($tag, 0, $first_space);
|
||||||
|
$tag = strtoupper($tag);
|
||||||
|
|
||||||
|
if (!$cut_counter) {
|
||||||
|
$out .= substr($data, $i, $left - $i);
|
||||||
|
if (isset($substs[$tag]))
|
||||||
|
$out .= $substs[$tag];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($inner_cut[$tag]) && (!$cut_counter || $cut_tag == $tag))
|
||||||
|
{
|
||||||
|
if (!$cut_counter)
|
||||||
|
$cut_tag = $tag;
|
||||||
|
$cut_counter++;
|
||||||
|
}
|
||||||
|
if ($tag != '' && $tag[0] == '/' && $cut_tag == substr($tag, 1)) {
|
||||||
|
$cut_counter = ($cut_counter > 0) ? $cut_counter - 1 : 0;
|
||||||
|
if (!$cut_counter)
|
||||||
|
$cut_tag = '';
|
||||||
|
}
|
||||||
|
//$close_tag = substr($tag, 1);
|
||||||
|
//$out .= "<br>$cut_counter, $cut_tag == $close_tag";
|
||||||
|
|
||||||
|
$i = $right + 1;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($i < $len && !$cut_counter)
|
||||||
|
$out .= substr($data, $i, $len - $i);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
2
docs/omnireader/old/robots.txt
Normal file
2
docs/omnireader/old/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /?*url=
|
||||||
4
docs/omnireader/old/test.php
Normal file
4
docs/omnireader/old/test.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: text/html; charset=windows-1251');
|
||||||
|
echo getcwd();
|
||||||
|
?>
|
||||||
2
docs/omnireader/old/txt/.htaccess
Normal file
2
docs/omnireader/old/txt/.htaccess
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
AddType 'text/plain; charset=windows-1251' .txz .txt
|
||||||
|
AddEncoding gzip .txz
|
||||||
@@ -23,3 +23,26 @@ server {
|
|||||||
root /home/liberama/public;
|
root /home/liberama/public;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name old.omnireader.ru;
|
||||||
|
|
||||||
|
client_max_body_size 50m;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types *;
|
||||||
|
|
||||||
|
root /home/oldreader;
|
||||||
|
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Обработка php файлов с помощью fpm
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
include /etc/nginx/fastcgi.conf;
|
||||||
|
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,17 @@ mkdir /home/liberama
|
|||||||
chown www-data /home/liberama
|
chown www-data /home/liberama
|
||||||
chgrp www-data /home/liberama
|
chgrp www-data /home/liberama
|
||||||
|
|
||||||
|
### oldreader
|
||||||
|
# ubuntu 18
|
||||||
|
apt install php7.2 php7.2-curl php7.2-mbstring php7.2-fpm
|
||||||
|
service php7.2-fpm restart
|
||||||
|
|
||||||
|
mkdir /home/oldreader
|
||||||
|
chown www-data /home/oldreader
|
||||||
|
chgrp www-data /home/oldreader
|
||||||
|
sudo -u www-data cp -r ./old/* /home/oldreader
|
||||||
|
###
|
||||||
|
|
||||||
apt install nginx
|
apt install nginx
|
||||||
|
|
||||||
cp omnireader /etc/nginx/sites-available/omnireader
|
cp omnireader /etc/nginx/sites-available/omnireader
|
||||||
|
|||||||
80
package-lock.json
generated
80
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Liberama",
|
"name": "Liberama",
|
||||||
"version": "0.1.0",
|
"version": "0.3.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3095,6 +3095,30 @@
|
|||||||
"strip-dirs": "^2.0.0"
|
"strip-dirs": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"decompress-bzip2": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/decompress-bzip2/-/decompress-bzip2-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-0SVMlJ4F6vYol1QoawY/3Hz/AT8=",
|
||||||
|
"requires": {
|
||||||
|
"file-type": "^4.3.0",
|
||||||
|
"seek-bzip": "^1.0.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"file-type": {
|
||||||
|
"version": "4.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-type/-/file-type-4.4.0.tgz",
|
||||||
|
"integrity": "sha1-G2AOX8ofvcboDApwxxyNul95BsU="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"decompress-gz": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/decompress-gz/-/decompress-gz-0.0.1.tgz",
|
||||||
|
"integrity": "sha512-YMdCWdxHvPplsTbV1tvr2oFJOtAFNxqVMFnKWEmePBXl+LKG5z5bFrowzc12Jzd7O29nnzI/D1M95Asx0Qa1fg==",
|
||||||
|
"requires": {
|
||||||
|
"file-type": "^5.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"decompress-response": {
|
"decompress-response": {
|
||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
|
||||||
@@ -4477,7 +4501,8 @@
|
|||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@@ -4498,12 +4523,14 @@
|
|||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@@ -4518,17 +4545,20 @@
|
|||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@@ -4645,7 +4675,8 @@
|
|||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@@ -4657,6 +4688,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -4671,6 +4703,7 @@
|
|||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
@@ -4678,12 +4711,14 @@
|
|||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@@ -4702,6 +4737,7 @@
|
|||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@@ -4782,7 +4818,8 @@
|
|||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@@ -4794,6 +4831,7 @@
|
|||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@@ -4879,7 +4917,8 @@
|
|||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
@@ -4915,6 +4954,7 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
@@ -4934,6 +4974,7 @@
|
|||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
@@ -4977,12 +5018,14 @@
|
|||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -6501,9 +6544,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
@@ -6567,6 +6610,13 @@
|
|||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"minimist": {
|
||||||
|
"version": "0.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||||
|
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"move-concurrently": {
|
"move-concurrently": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Liberama",
|
"name": "Liberama",
|
||||||
"version": "0.1.3",
|
"version": "0.3.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
@@ -60,6 +60,8 @@
|
|||||||
"chardet": "^0.7.0",
|
"chardet": "^0.7.0",
|
||||||
"compression": "^1.7.3",
|
"compression": "^1.7.3",
|
||||||
"decompress": "^4.2.0",
|
"decompress": "^4.2.0",
|
||||||
|
"decompress-bzip2": "^4.0.0",
|
||||||
|
"decompress-gz": "0.0.1",
|
||||||
"detect-file-type": "^0.2.0",
|
"detect-file-type": "^0.2.0",
|
||||||
"element-ui": "^2.4.11",
|
"element-ui": "^2.4.11",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
@@ -70,6 +72,7 @@
|
|||||||
"iconv-lite": "^0.4.24",
|
"iconv-lite": "^0.4.24",
|
||||||
"localforage": "^1.7.3",
|
"localforage": "^1.7.3",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
|
"minimist": "^1.2.0",
|
||||||
"multer": "^1.4.1",
|
"multer": "^1.4.1",
|
||||||
"path-browserify": "^1.0.0",
|
"path-browserify": "^1.0.0",
|
||||||
"sql-template-strings": "^2.2.2",
|
"sql-template-strings": "^2.2.2",
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ module.exports = {
|
|||||||
dbFileName: 'db.sqlite',
|
dbFileName: 'db.sqlite',
|
||||||
loggingEnabled: true,
|
loggingEnabled: true,
|
||||||
|
|
||||||
|
maxUploadFileSize: 50*1024*1024,//50Мб
|
||||||
|
maxTempPublicDirSize: 512*1024*1024,//512Мб
|
||||||
|
maxUploadPublicDirSize: 200*1024*1024,//100Мб
|
||||||
|
|
||||||
servers: [
|
servers: [
|
||||||
{
|
{
|
||||||
serverName: '1',
|
serverName: '1',
|
||||||
@@ -24,12 +28,6 @@ module.exports = {
|
|||||||
ip: '0.0.0.0',
|
ip: '0.0.0.0',
|
||||||
port: '33080',
|
port: '33080',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
serverName: '2',
|
|
||||||
mode: 'omnireader',
|
|
||||||
ip: '0.0.0.0',
|
|
||||||
port: '33081',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
36
server/config/configSaver.js
Normal file
36
server/config/configSaver.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
const fs = require('fs-extra');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
const propsToSave = [
|
||||||
|
'maxUploadFileSize',
|
||||||
|
'maxTempPublicDirSize',
|
||||||
|
'maxUploadPublicDirSize',
|
||||||
|
|
||||||
|
'servers',
|
||||||
|
];
|
||||||
|
|
||||||
|
async function load(config, configFilename) {
|
||||||
|
if (!configFilename) {
|
||||||
|
configFilename = `${config.dataDir}/config.json`;
|
||||||
|
|
||||||
|
if (!await fs.pathExists(configFilename)) {
|
||||||
|
save(config);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await fs.readFile(configFilename, 'utf8');
|
||||||
|
Object.assign(config, JSON.parse(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save(config) {
|
||||||
|
const configFilename = `${config.dataDir}/config.json`;
|
||||||
|
const dataToSave = _.pick(config, propsToSave);
|
||||||
|
|
||||||
|
await fs.writeFile(configFilename, JSON.stringify(dataToSave, null, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
load,
|
||||||
|
save
|
||||||
|
};
|
||||||
@@ -19,12 +19,6 @@ module.exports = Object.assign({}, base, {
|
|||||||
ip: '0.0.0.0',
|
ip: '0.0.0.0',
|
||||||
port: '44080',
|
port: '44080',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
serverName: '2',
|
|
||||||
mode: 'omnireader',
|
|
||||||
ip: '0.0.0.0',
|
|
||||||
port: '44081',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class BookConverter {
|
|||||||
|
|
||||||
const parsedUrl = new URL(url);
|
const parsedUrl = new URL(url);
|
||||||
if (parsedUrl.hostname == 'samlib.ru' ||
|
if (parsedUrl.hostname == 'samlib.ru' ||
|
||||||
parsedUrl.hostname == 'budclub.ru') {
|
parsedUrl.hostname == 'budclub.ru' ||
|
||||||
|
parsedUrl.hostname == 'zhurnal.lib.ru') {
|
||||||
await fs.writeFile(outputFile, this.convertSamlib(data));
|
await fs.writeFile(outputFile, this.convertSamlib(data));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -42,7 +43,7 @@ class BookConverter {
|
|||||||
else {
|
else {
|
||||||
//может это чистый текст?
|
//может это чистый текст?
|
||||||
if (textUtils.checkIfText(data)) {
|
if (textUtils.checkIfText(data)) {
|
||||||
await fs.writeFile(outputFile, this.convertHtml(data));
|
await fs.writeFile(outputFile, this.convertHtml(data, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +53,16 @@ class BookConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decode(data) {
|
decode(data) {
|
||||||
const charsetAll = chardet.detectAll(data.slice(0, 20000));
|
let selected = textUtils.getEncoding(data);
|
||||||
|
|
||||||
let selected = 'ISO-8859-5';
|
|
||||||
for (const charset of charsetAll) {
|
|
||||||
if (charset.name.indexOf('ISO-8859') < 0) {
|
|
||||||
selected = charset.name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected == 'ISO-8859-5') {
|
if (selected == 'ISO-8859-5') {
|
||||||
selected = textUtils.getEncoding(data);
|
const charsetAll = chardet.detectAll(data.slice(0, 20000));
|
||||||
|
for (const charset of charsetAll) {
|
||||||
|
if (charset.name.indexOf('ISO-8859') < 0) {
|
||||||
|
selected = charset.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconv.decode(data, selected);
|
return iconv.decode(data, selected);
|
||||||
@@ -166,7 +165,7 @@ class BookConverter {
|
|||||||
titleInfo['book-title'] = title;
|
titleInfo['book-title'] = title;
|
||||||
|
|
||||||
//подозрение на чистый текст, надо разбить на параграфы
|
//подозрение на чистый текст, надо разбить на параграфы
|
||||||
if ((isText || pars.length < buf.length/2000) && spaceCounter.length) {
|
if (isText || pars.length < buf.length/2000) {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (let i = 0; i < spaceCounter.length; i++) {
|
for (let i = 0; i < spaceCounter.length; i++) {
|
||||||
total += (spaceCounter[i] ? spaceCounter[i] : 0);
|
total += (spaceCounter[i] ? spaceCounter[i] : 0);
|
||||||
@@ -175,41 +174,37 @@ class BookConverter {
|
|||||||
let i = spaceCounter.length - 1;
|
let i = spaceCounter.length - 1;
|
||||||
while (i > 0 && (!spaceCounter[i] || spaceCounter[i] < total)) i--;
|
while (i > 0 && (!spaceCounter[i] || spaceCounter[i] < total)) i--;
|
||||||
|
|
||||||
const parIndent = i;
|
const parIndent = (i > 0 ? i : 0);
|
||||||
if (parIndent > 0) {//нашли отступ параграфа
|
|
||||||
|
|
||||||
let newPars = [];
|
let newPars = [];
|
||||||
const newPar = () => {
|
const newPar = () => {
|
||||||
newPars.push({_n: 'p', _t: ''});
|
newPars.push({_n: 'p', _t: ''});
|
||||||
};
|
};
|
||||||
|
|
||||||
const growPar = (text) => {
|
const growPar = (text) => {
|
||||||
const l = newPars.length;
|
const l = newPars.length;
|
||||||
if (l) {
|
if (l) {
|
||||||
newPars[l - 1]._t += text;
|
newPars[l - 1]._t += text;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const par of pars) {
|
|
||||||
newPar();
|
|
||||||
|
|
||||||
const lines = par._t.split('\n');
|
|
||||||
for (const line of lines) {
|
|
||||||
const sp = line.split(' ');
|
|
||||||
let l = 0;
|
|
||||||
while (l < sp.length && sp[l].trim() == '') {
|
|
||||||
l++;
|
|
||||||
}
|
|
||||||
if (l >= parIndent)
|
|
||||||
newPar();
|
|
||||||
growPar(line.trim() + ' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body.section._a[0] = newPars;
|
|
||||||
} else {
|
|
||||||
body.section._a[0] = pars;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const par of pars) {
|
||||||
|
newPar();
|
||||||
|
|
||||||
|
const lines = par._t.split('\n');
|
||||||
|
for (const line of lines) {
|
||||||
|
const sp = line.split(' ');
|
||||||
|
let l = 0;
|
||||||
|
while (l < sp.length && sp[l].trim() == '') {
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
if (l >= parIndent)
|
||||||
|
newPar();
|
||||||
|
growPar(line.trim() + ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body.section._a[0] = newPars;
|
||||||
} else {
|
} else {
|
||||||
body.section._a[0] = pars;
|
body.section._a[0] = pars;
|
||||||
}
|
}
|
||||||
@@ -237,6 +232,8 @@ class BookConverter {
|
|||||||
let node = {_a: pars};
|
let node = {_a: pars};
|
||||||
|
|
||||||
let inPara = false;
|
let inPara = false;
|
||||||
|
let italic = false;
|
||||||
|
let bold = false;
|
||||||
|
|
||||||
const openTag = (name) => {
|
const openTag = (name) => {
|
||||||
if (name == 'p')
|
if (name == 'p')
|
||||||
@@ -249,8 +246,11 @@ class BookConverter {
|
|||||||
const closeTag = (name) => {
|
const closeTag = (name) => {
|
||||||
if (name == 'p')
|
if (name == 'p')
|
||||||
inPara = false;
|
inPara = false;
|
||||||
if (node._n == name && node._p) {
|
if (node._p) {
|
||||||
|
const exact = (node._n == name);
|
||||||
node = node._p;
|
node = node._p;
|
||||||
|
if (!exact)
|
||||||
|
closeTag(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -282,10 +282,10 @@ class BookConverter {
|
|||||||
openTag('p');
|
openTag('p');
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
openTag('emphasis');
|
italic = true;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
openTag('strong');
|
bold = true;
|
||||||
break;
|
break;
|
||||||
case 'div':
|
case 'div':
|
||||||
if (tail.indexOf('align="center"') >= 0) {
|
if (tail.indexOf('align="center"') >= 0) {
|
||||||
@@ -330,10 +330,10 @@ class BookConverter {
|
|||||||
closeTag('p');
|
closeTag('p');
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
closeTag('emphasis');
|
italic = false;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
closeTag('strong');
|
bold = false;
|
||||||
break;
|
break;
|
||||||
case 'div':
|
case 'div':
|
||||||
if (inSubtitle) {
|
if (inSubtitle) {
|
||||||
@@ -381,8 +381,13 @@ class BookConverter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tOpen = (bold ? '<strong>' : '');
|
||||||
|
tOpen += (italic ? '<emphasis>' : '');
|
||||||
|
let tClose = (italic ? '</emphasis>' : '');
|
||||||
|
tClose += (bold ? '</strong>' : '');
|
||||||
|
|
||||||
if (inText)
|
if (inText)
|
||||||
growParagraph(text);
|
growParagraph(`${tOpen}${text}${tClose}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
sax.parseSync(repSpaces(this.decode(data).toString()), {
|
sax.parseSync(repSpaces(this.decode(data).toString()), {
|
||||||
|
|||||||
@@ -276,7 +276,84 @@ async function parse(xstr, options) {
|
|||||||
await _onProgress(100);
|
await _onProgress(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAttrsSync(tail) {
|
||||||
|
let result = {};
|
||||||
|
let name = '';
|
||||||
|
let value = '';
|
||||||
|
let vOpen = '';
|
||||||
|
let inName = false;
|
||||||
|
let inValue = false;
|
||||||
|
let waitValue = false;
|
||||||
|
let waitEq = false;
|
||||||
|
|
||||||
|
const pushResult = () => {
|
||||||
|
if (name != '') {
|
||||||
|
let ns = '';
|
||||||
|
if (name.indexOf(':') >= 0) {
|
||||||
|
[ns, name] = name.split(':');
|
||||||
|
}
|
||||||
|
|
||||||
|
result[name] = {value, ns};
|
||||||
|
}
|
||||||
|
name = '';
|
||||||
|
value = '';
|
||||||
|
vOpen = '';
|
||||||
|
inName = false;
|
||||||
|
inValue = false;
|
||||||
|
waitValue = false;
|
||||||
|
waitEq = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
tail = tail.replace(/[\t\n\r]/g, ' ');
|
||||||
|
for (let i = 0; i < tail.length; i++) {
|
||||||
|
const c = tail.charAt(i);
|
||||||
|
if (c == ' ') {
|
||||||
|
if (inValue) {
|
||||||
|
if (vOpen == '"')
|
||||||
|
value += c;
|
||||||
|
else
|
||||||
|
pushResult();
|
||||||
|
} else if (inName) {
|
||||||
|
waitEq = true;
|
||||||
|
inName = false;
|
||||||
|
}
|
||||||
|
} else if (!inValue && c == '=') {
|
||||||
|
waitEq = false;
|
||||||
|
waitValue = true;
|
||||||
|
inName = false;
|
||||||
|
} else if (c == '"') {
|
||||||
|
if (inValue) {
|
||||||
|
pushResult();
|
||||||
|
} else if (waitValue) {
|
||||||
|
inValue = true;
|
||||||
|
vOpen = '"';
|
||||||
|
}
|
||||||
|
} else if (inValue) {
|
||||||
|
value += c;
|
||||||
|
} else if (inName) {
|
||||||
|
name += c;
|
||||||
|
} else if (waitEq) {
|
||||||
|
pushResult();
|
||||||
|
inName = true;
|
||||||
|
name = c;
|
||||||
|
} else if (waitValue) {
|
||||||
|
waitValue = false;
|
||||||
|
inValue = true;
|
||||||
|
vOpen = ' ';
|
||||||
|
value = c;
|
||||||
|
} else {
|
||||||
|
inName = true;
|
||||||
|
name = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name != '')
|
||||||
|
pushResult();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
parseSync,
|
parseSync,
|
||||||
|
getAttrsSync,
|
||||||
parse
|
parse
|
||||||
}
|
}
|
||||||
@@ -70,13 +70,22 @@ function getEncoding(buf) {
|
|||||||
|
|
||||||
function checkIfText(buf) {
|
function checkIfText(buf) {
|
||||||
let spaceCount = 0;
|
let spaceCount = 0;
|
||||||
|
let crCount = 0;
|
||||||
|
let lfCount = 0;
|
||||||
for (let i = 0; i < buf.length; i++) {
|
for (let i = 0; i < buf.length; i++) {
|
||||||
if (buf[i] == 32)
|
if (buf[i] == 32)
|
||||||
spaceCount++;
|
spaceCount++;
|
||||||
|
if (buf[i] == 13)
|
||||||
|
crCount++;
|
||||||
|
if (buf[i] == 10)
|
||||||
|
lfCount++;
|
||||||
}
|
}
|
||||||
const freq = spaceCount/(buf.length + 1);
|
|
||||||
|
|
||||||
return (freq > 0.1);
|
const spaceFreq = spaceCount/(buf.length + 1);
|
||||||
|
const crFreq = crCount/(buf.length + 1);
|
||||||
|
const lfFreq = lfCount/(buf.length + 1);
|
||||||
|
|
||||||
|
return (buf.length < 1000 || spaceFreq > 0.1 || crFreq > 0.03 || lfFreq > 0.03);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const path = require('path');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const decompress = require('decompress');
|
const decompress = require('decompress');
|
||||||
|
const decompressGz = require('decompress-gz');
|
||||||
|
const decompressBzip2 = require('decompress-bzip2');
|
||||||
|
|
||||||
const FileDetector = require('./FileDetector');
|
const FileDetector = require('./FileDetector');
|
||||||
|
|
||||||
class FileDecompressor {
|
class FileDecompressor {
|
||||||
@@ -13,11 +17,33 @@ class FileDecompressor {
|
|||||||
async decompressFile(filename, outputDir) {
|
async decompressFile(filename, outputDir) {
|
||||||
const fileType = await this.detector.detectFile(filename);
|
const fileType = await this.detector.detectFile(filename);
|
||||||
|
|
||||||
if (!fileType || !(fileType.ext == 'zip' || fileType.ext == 'bz2'))
|
if (!fileType || !(fileType.ext == 'zip' || fileType.ext == 'bz2' || fileType.ext == 'gz'))
|
||||||
return filename;
|
return filename;
|
||||||
|
|
||||||
const files = await decompress(filename, outputDir);
|
//дурной decompress, поэтому в 2 этапа
|
||||||
|
//этап 1
|
||||||
|
let files = [];
|
||||||
|
try {
|
||||||
|
files = await decompress(filename, outputDir);
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//этап 2
|
||||||
|
if (files.length == 0) {
|
||||||
|
try {
|
||||||
|
files = await decompress(filename, outputDir, {
|
||||||
|
inputFile: filename,
|
||||||
|
plugins: [
|
||||||
|
decompressGz(),
|
||||||
|
decompressBzip2({path: path.basename(filename)}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let result = filename;
|
let result = filename;
|
||||||
let max = 0;
|
let max = 0;
|
||||||
if (files.length) {
|
if (files.length) {
|
||||||
@@ -29,6 +55,9 @@ class FileDecompressor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//дурной decompress
|
||||||
|
if (result != filename)
|
||||||
|
await fs.chmod(result, 0o664);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ const FileDecompressor = require('./FileDecompressor');
|
|||||||
const BookConverter = require('./BookConverter');
|
const BookConverter = require('./BookConverter');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
|
|
||||||
const maxTempPublicDirSize = 512*1024*1024;//512Мб
|
|
||||||
const maxUploadDirSize = 200*1024*1024;//100Мб
|
|
||||||
let singleCleanExecute = false;
|
let singleCleanExecute = false;
|
||||||
|
|
||||||
class ReaderWorker {
|
class ReaderWorker {
|
||||||
@@ -27,8 +25,8 @@ class ReaderWorker {
|
|||||||
this.bookConverter = new BookConverter();
|
this.bookConverter = new BookConverter();
|
||||||
|
|
||||||
if (!singleCleanExecute) {
|
if (!singleCleanExecute) {
|
||||||
this.periodicCleanDir(this.config.tempPublicDir, maxTempPublicDirSize, 60*60*1000);//1 раз в час
|
this.periodicCleanDir(this.config.tempPublicDir, this.config.maxTempPublicDirSize, 60*60*1000);//1 раз в час
|
||||||
this.periodicCleanDir(this.config.uploadDir, maxUploadDirSize, 60*60*1000);//1 раз в час
|
this.periodicCleanDir(this.config.uploadDir, this.config.maxUploadPublicDirSize, 60*60*1000);//1 раз в час
|
||||||
singleCleanExecute = true;
|
singleCleanExecute = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
|
|
||||||
const {initLogger, getLog} = require('./core/getLogger');
|
const {initLogger, getLog} = require('./core/getLogger');
|
||||||
initLogger(config);
|
initLogger(config);
|
||||||
const log = getLog();
|
const log = getLog();
|
||||||
|
|
||||||
|
const configSaver = require('./config/configSaver');
|
||||||
|
const argv = require('minimist')(process.argv.slice(2));
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
@@ -23,15 +25,17 @@ async function init() {
|
|||||||
await fs.remove(appDir);
|
await fs.remove(appDir);
|
||||||
await fs.move(appNewDir, appDir);
|
await fs.move(appNewDir, appDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//загружаем конфиг из файла
|
||||||
|
await configSaver.load(config, argv.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const connPool = new SqliteConnectionPool(20, config);
|
|
||||||
|
|
||||||
log('Initializing');
|
log('Initializing');
|
||||||
await init();
|
await init();
|
||||||
|
|
||||||
log('Opening database');
|
log('Opening database');
|
||||||
|
const connPool = new SqliteConnectionPool(20, config);
|
||||||
await connPool.init();
|
await connPool.init();
|
||||||
|
|
||||||
//servers
|
//servers
|
||||||
@@ -42,7 +46,7 @@ async function main() {
|
|||||||
|
|
||||||
let devModule = undefined;
|
let devModule = undefined;
|
||||||
if (serverConfig.branch == 'development') {
|
if (serverConfig.branch == 'development') {
|
||||||
const devFileName = './dev.js'; //ignored by pkg -50Mb executable size
|
const devFileName = './dev.js'; //require ignored by pkg -50Mb executable size
|
||||||
devModule = require(devFileName);
|
devModule = require(devFileName);
|
||||||
devModule.webpackDevMiddleware(app);
|
devModule.webpackDevMiddleware(app);
|
||||||
}
|
}
|
||||||
@@ -80,4 +84,12 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
|
||||||
|
(async() => {
|
||||||
|
try {
|
||||||
|
await main();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -2,8 +2,6 @@ const c = require('./controllers');
|
|||||||
const utils = require('./core/utils');
|
const utils = require('./core/utils');
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
|
|
||||||
const maxUploadSize = 50*1024*1024;
|
|
||||||
|
|
||||||
function initRoutes(app, connPool, config) {
|
function initRoutes(app, connPool, config) {
|
||||||
const misc = new c.MiscController(connPool, config);
|
const misc = new c.MiscController(connPool, config);
|
||||||
const reader = new c.ReaderController(connPool, config);
|
const reader = new c.ReaderController(connPool, config);
|
||||||
@@ -22,7 +20,7 @@ function initRoutes(app, connPool, config) {
|
|||||||
cb(null, utils.randomHexString(30));
|
cb(null, utils.randomHexString(30));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const upload = multer({ storage, limits: {fileSize: maxUploadSize} });
|
const upload = multer({ storage, limits: {fileSize: config.maxUploadFileSize} });
|
||||||
|
|
||||||
//routes
|
//routes
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|||||||
Reference in New Issue
Block a user