Compare commits

...

27 Commits
0.2.0 ... 0.3.1

Author SHA1 Message Date
Book Pauk
39b577e935 Merge branch 'release/0.3.1' 2019-02-18 16:10:43 +07:00
Book Pauk
91380d2aed Версия 0.3.1 2019-02-18 16:10:27 +07:00
Book Pauk
f995c24264 Добавлена старая читалка для страждущих 2019-02-18 16:08:39 +07:00
Book Pauk
c7db0ec643 Рефакторинг 2019-02-18 15:00:20 +07:00
Book Pauk
f9e000034f Merge tag '0.3.0' into develop
0.3.0
2019-02-17 20:16:23 +07:00
Book Pauk
8ddd2d6290 Merge branch 'release/0.3.0' 2019-02-17 20:16:11 +07:00
Book Pauk
f6c8666f06 Версия 0.3.0 2019-02-17 20:15:50 +07:00
Book Pauk
1bf173fcae Поправка бага 2019-02-17 20:10:25 +07:00
Book Pauk
696866f065 Merge branch 'feature/draw-page' into develop 2019-02-17 20:08:06 +07:00
Book Pauk
c82283c7f0 Поправка дефолтов 2019-02-17 20:04:28 +07:00
Book Pauk
0e62f25557 Переделки отображения needle при поиске 2019-02-17 20:02:18 +07:00
Book Pauk
e2c51f44bf Изменение drawPage - теперь не позиционирует каждое слово отдельно,
вместо этого используются возможности CSS
2019-02-17 19:35:32 +07:00
Book Pauk
d4768392a6 Мелкая поправка 2019-02-17 19:32:30 +07:00
Book Pauk
580744819d Поправил настройки по-умолчанию 2019-02-17 19:31:50 +07:00
Book Pauk
959794de10 Merge tag '0.2.2' into develop
0.2.2
2019-02-17 14:59:34 +07:00
Book Pauk
3a32c09feb Merge branch 'release/0.2.2' 2019-02-17 14:59:14 +07:00
Book Pauk
09bfce4590 Версия 0.2.2 2019-02-17 14:58:37 +07:00
Book Pauk
092697a4b2 Поправил бажок 2019-02-17 14:55:01 +07:00
Book Pauk
a36de9424e Улучшил распарсивание текста 2019-02-17 14:46:52 +07:00
Book Pauk
db4bc2afb2 Улучшена эвристика определения текста 2019-02-17 14:27:49 +07:00
Book Pauk
73bfc07082 Увеличил количество хранимых недавних до 1000 2019-02-17 13:57:12 +07:00
Book Pauk
b3cf88aac3 Поправил бажок 2019-02-17 13:33:49 +07:00
Book Pauk
69bcc61a01 Включаем yandex-метрику только на production 2019-02-17 13:30:08 +07:00
Book Pauk
bdc124052c Merge tag '0.2.1' into develop
0.2.1
2019-02-16 03:38:38 +07:00
Book Pauk
cfcee9eb99 Merge branch 'hotfix/0.2.1' 2019-02-16 03:38:24 +07:00
Book Pauk
e93c873c17 Поправил названия в списке 2019-02-16 03:37:51 +07:00
Book Pauk
2b1bb6a299 Merge tag '0.2.0' into develop
0.2.0
2019-02-16 03:20:51 +07:00
33 changed files with 2756 additions and 191 deletions

View File

@@ -6,7 +6,7 @@ const api = axios.create({
class Misc {
async loadConfig() {
const response = await api.post('/config', {params: ['name', 'version', 'mode', 'maxUploadFileSize']});
const response = await api.post('/config', {params: ['name', 'version', 'mode', 'maxUploadFileSize', 'branch']});
return response.data;
}
}

View File

@@ -210,7 +210,7 @@ class App extends Vue {
}
//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)};
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

View File

@@ -126,8 +126,10 @@ class HistoryPage extends Vue {
updateTableData() {
let result = [];
for (let bookKey in bookManager.recent) {
const book = bookManager.recent[bookKey];
const sorted = bookManager.getSortedRecent();
const len = (sorted.length < 100 ? sorted.length : 100);
for (let i = 0; i < len; i++) {
const book = sorted[i];
let d = new Date();
d.setTime(book.touchTime);
const t = formatDate(d).split(' ');

View File

@@ -201,7 +201,7 @@ class Reader extends Vue {
mounted() {
(async() => {
await bookManager.init(this.settings);
await bookManager.init();
await restoreOldSettings(this.settings, bookManager, this.commit);
if (this.$root.rootRoute == '/reader') {

View File

@@ -185,13 +185,13 @@
<el-checkbox v-model="wordWrap">Перенос по слогам</el-checkbox>
</el-form-item>
<el-form-item label="Обработка">
<el-checkbox v-model="cutEmptyParagraphs" @change="needReload">Убирать пустые параграфы</el-checkbox>
<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" @change="needReload"></el-input-number>
<el-input-number v-model="addEmptyParagraphs" :min="0" :max="2"></el-input-number>
</el-form-item>
</el-form>
@@ -221,8 +221,8 @@
<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="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>

View File

@@ -23,17 +23,17 @@ export default class DrawHelper {
if (!this.lastBook || this.pageLineCount < 1 || !this.book || !lines || !this.parsed.textLength)
return '';
const spaceWidth = this.measureText(' ', {});
const font = this.fontByStyle({});
const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
let out = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
` color: ${this.textColor}">`;
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);
let y = this.fontSize*this.textShift;
for (let i = 0; i < len; i++) {
const line = lines[i];
/* line:
@@ -47,77 +47,57 @@ export default class DrawHelper {
text: String,
}
}*/
let sel = new Set();
if (i == 0 && this.searching) {
let pureText = '';
for (const part of line.parts) {
pureText += part.text;
}
let indent = line.first ? this.p : 0;
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 centerStyle = {};
let j = 0;
for (const part of line.parts) {
lineText += part.text;
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;
if (part.style.center)
centerStyle = part.style;
}
let filled = false;
// если выравнивание по ширине включено
if (this.textAlignJustify && !line.last && !center) {
const words = lineText.split(' ');
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>`;
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.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.fillText(word, x, y, f);
x += this.measureText(word, style) + (j < partWords.length - 1 ? spaceWidth : 0);
}
} else {
out += this.fillText(part.text, x, y, font);
x += this.measureText(part.text, part.style);
}
}
}
y += this.lineHeight;
out += (i > 0 ? '<br>' : '') + lineText;
}
out += '</div>';

View File

@@ -1,6 +1,6 @@
<template>
<div ref="main" class="main">
<div class="layout back">
<div class="layout back" @wheel.prevent.stop="onMouseWheel">
<div v-html="background"></div>
<!-- img -->
</div>
@@ -210,6 +210,8 @@ class TextPage extends Vue {
this.parsed.w = this.w;// px, ширина текста
this.parsed.font = this.font;
this.parsed.wordWrap = this.wordWrap;
this.parsed.cutEmptyParagraphs = this.cutEmptyParagraphs;
this.parsed.addEmptyParagraphs = this.addEmptyParagraphs;
let t = '';
while (this.drawHelper.measureText(t, {}) < this.w) t += 'Щ';
this.parsed.maxWordLength = t.length - 1;
@@ -436,15 +438,7 @@ class TextPage extends Vue {
}
startSearch(needle) {
this.drawHelper.needle = '';
const words = needle.split(' ');
for (const word of words) {
if (word != '') {
this.drawHelper.needle = word;
break;
}
}
this.drawHelper.needle = needle;
this.drawHelper.searching = true;
this.draw();
}
@@ -569,7 +563,7 @@ class TextPage extends Vue {
}
if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
this.doEnd();
this.doEnd(true);
return;
}
@@ -591,7 +585,7 @@ class TextPage extends Vue {
this.debouncedDrawStatusBar();
if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount) {
this.doEnd();
this.doEnd(true);
return;
}
}
@@ -822,7 +816,7 @@ class TextPage extends Vue {
this.bookPos = 0;
}
doEnd() {
doEnd(noAni) {
if (this.parsed.para.length && this.pageLineCount > 0) {
let i = this.parsed.para.length - 1;
let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
@@ -830,7 +824,8 @@ class TextPage extends Vue {
if (lines) {
i = this.pageLineCount - 1;
i = (i > lines.length - 1 ? lines.length - 1 : i);
this.currentAnimation = this.pageChangeAnimation;
if (!noAni)
this.currentAnimation = this.pageChangeAnimation;
this.pageChangeDirectionDown = true;
this.bookPos = lines[i].begin;
}

View File

@@ -3,7 +3,7 @@ import sax from '../../../../server/core/BookConverter/sax';
import {sleep} from '../../../share/utils';
export default class BookParser {
constructor(settings) {
constructor() {
// defaults
this.p = 30;// px, отступ параграфа
this.w = 300;// px, ширина страницы
@@ -13,12 +13,6 @@ export default class BookParser {
this.measureText = (text, style) => {// eslint-disable-line no-unused-vars
return text.length*20;
};
//настройки
if (settings) {
this.cutEmptyParagraphs = settings.cutEmptyParagraphs;
this.addEmptyParagraphs = settings.addEmptyParagraphs;
}
}
async parse(data, callback) {
@@ -51,23 +45,20 @@ export default class BookParser {
index: Number,
offset: Number, //сумма всех length до этого параграфа
length: Number, //длина text без тегов
text: String //текст параграфа (или title или epigraph и т.д) с вложенными тегами
text: String, //текст параграфа с вложенными тегами
cut: Boolean, //параграф - кандидат на сокрытие (cutEmptyParagraphs)
addIndex: Number, //индекс добавляемого пустого параграфа (addEmptyParagraphs)
}
*/
const newParagraph = (text, len, noCut) => {
//схлопывание пустых параграфов
if (!noCut && this.cutEmptyParagraphs && paraIndex >= 0 && len == 1 && text[0] == ' ') {
let p = para[paraIndex];
if (p.length == 1 && p.text[0] == ' ')
return;
}
const newParagraph = (text, len, addIndex) => {
paraIndex++;
let p = {
index: paraIndex,
offset: paraOffset,
length: len,
text: text,
cut: (!addIndex && (len == 1 && text[0] == ' ')),
addIndex: (addIndex ? addIndex : 0),
};
para[paraIndex] = p;
@@ -82,33 +73,32 @@ export default class BookParser {
}
let p = para[paraIndex];
if (p) {
//добавление пустых параграфов
if (this.addEmptyParagraphs && p.length == 1 && p.text[0] == ' ' && len > 0) {
let i = this.addEmptyParagraphs;
while (i > 0) {
newParagraph(' ', 1, true);
i--;
}
p = para[paraIndex];
//добавление пустых (addEmptyParagraphs) параграфов
if (p.length == 1 && p.text[0] == ' ' && len > 0) {
paraIndex--;
paraOffset -= p.length;
for (let i = 0; i < 2; i++) {
newParagraph(' ', 1, i + 1);
}
paraOffset -= p.length;
if (p.length == 1 && p.text[0] == ' ' && len > 0) {
p.length = 0;
p.text = p.text.substr(1);
}
p.length += len;
p.text += text;
} else {
p = {
index: paraIndex,
offset: paraOffset,
length: len,
text: text
};
paraIndex++;
p.index = paraIndex;
p.offset = paraOffset;
para[paraIndex] = p;
paraOffset += p.length;
}
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;
paraOffset += p.length;
};
@@ -432,7 +422,9 @@ export default class BookParser {
para.parsed.p === this.p &&
para.parsed.wordWrap === this.wordWrap &&
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;
@@ -442,6 +434,12 @@ export default class BookParser {
wordWrap: this.wordWrap,
maxWordLength: this.maxWordLength,
font: this.font,
cutEmptyParagraphs: this.cutEmptyParagraphs,
addEmptyParagraphs: this.addEmptyParagraphs,
visible: !(
(this.cutEmptyParagraphs && para.cut) ||
(para.addIndex > this.addEmptyParagraphs)
)
};
@@ -614,16 +612,19 @@ export default class BookParser {
let paraIndex = this.findParaIndex(bookPos);
if (paraIndex === undefined)
return result;
return null;
if (n > 0) {
let parsed = this.parsePara(paraIndex);
let i = this.findLineIndex(bookPos, parsed.lines);
if (i === undefined)
return result;
return null;
while (n > 0) {
result.push(parsed.lines[i]);
if (parsed.visible) {
result.push(parsed.lines[i]);
n--;
}
i++;
if (i >= parsed.lines.length) {
@@ -631,21 +632,22 @@ export default class BookParser {
if (paraIndex < this.para.length)
parsed = this.parsePara(paraIndex);
else
return result;
break;
i = 0;
}
n--;
}
} else if (n < 0) {
n = -n;
let parsed = this.parsePara(paraIndex);
let i = this.findLineIndex(bookPos, parsed.lines);
if (i === undefined)
return result;
return null;
while (n > 0) {
result.push(parsed.lines[i]);
if (parsed.visible) {
result.push(parsed.lines[i]);
n--;
}
i--;
if (i < 0) {
@@ -653,16 +655,15 @@ export default class BookParser {
if (paraIndex >= 0)
parsed = this.parsePara(paraIndex);
else
return result;
break;
i = parsed.lines.length - 1;
}
n--;
}
}
if (!result.length)
result = null;
return result;
}
}

View File

@@ -18,11 +18,11 @@ const bmRecentStore = localForage.createInstance({
});
class BookManager {
async init(settings) {
this.settings = settings;
async init() {
this.books = {};
this.recent = {};
this.recentChanged = true;
this.recentChanged1 = true;
this.recentChanged2 = true;
let len = await bmMetaStore.length();
for (let i = 0; i < len; i++) {
@@ -131,7 +131,7 @@ class BookManager {
async parseBook(meta, data, callback) {
if (!this.books)
await this.init();
const parsed = new BookParser(this.settings);
const parsed = new BookParser();
const parsedMeta = await parsed.parse(data, callback);
const result = Object.assign({}, meta, parsedMeta, {
@@ -170,7 +170,8 @@ class BookManager {
await bmRecentStore.setItem(result.key, result);
await this.cleanRecentBooks();
this.recentChanged = true;
this.recentChanged1 = true;
this.recentChanged2 = true;
return result;
}
@@ -186,14 +187,15 @@ class BookManager {
await bmRecentStore.removeItem(value.key);
delete this.recent[value.key];
this.recentChanged = true;
this.recentChanged1 = true;
this.recentChanged2 = true;
}
async cleanRecentBooks() {
if (!this.recent)
await this.init();
if (Object.keys(this.recent).length > 100) {
if (Object.keys(this.recent).length > 1000) {
let min = Date.now();
let found = null;
for (let key in this.recent) {
@@ -212,7 +214,7 @@ class BookManager {
}
mostRecentBook() {
if (!this.recentChanged && this.mostRecentCached) {
if (!this.recentChanged1 && this.mostRecentCached) {
return this.mostRecentCached;
}
@@ -226,10 +228,25 @@ class BookManager {
}
}
this.mostRecentCached = result;
this.recentChanged = false;
this.recentChanged1 = false;
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();

View File

@@ -6,7 +6,7 @@ const fonts = [
{name: 'Arimo', fontVertShift: 0},
{name: 'Avrile', fontVertShift: -10},
{name: 'OpenSans', fontVertShift: -5},
{name: 'Roboto', fontVertShift: 10},
{name: 'Roboto', fontVertShift: 0},
{name: 'Rubik', fontVertShift: 0},
];

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,2 @@
siteroot = 'http://omnireader.ru:11080/';
doRedirect = '';

View File

@@ -0,0 +1,5 @@
<?php
$siteroot = 'http://omnireader.ru:11080/';
$use_gzip = false;
$tmp_dir = '/tmp';
?>

447
docs/omnireader/old/f.php Normal file
View 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>&nbsp;&nbsp[;]*\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;
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

View 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;">Íà ñòðàíèöó:&nbsp;</a>
<b onmousedown="gpa=1;pageGoto(1);" onmouseup="gpa=0;" onmouseout="gpa=0;">&lt;</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;">&gt;</b>
&nbsp;
<a href="/?#" onclick="goTo();return false;">Ok</a>
<br>
<a href="/?#" onclick="return statusPanel();">Ïàíåëü ñòàòóñà(px):&nbsp;</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):&nbsp;</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">&nbsp;Òåêñò</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">&nbsp;Ôîí</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>
&nbsp;Ðàçìåð
</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>
&nbsp;Øðèôò
</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>
&nbsp;Ñâîé
</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://omnireader.ru:11080/?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&amp;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="Âåðíóòüñÿ íà ãëàâíóþ">&nbsp;&nbsp;&nbsp;&lt;&lt;&lt;&nbsp;&nbsp;</span></a>
</div>
<div class="page">&nbsp;&nbsp;&nbsp;
</div>
<div class="cpage" onclick="menu();return false;">
<span title="M - ïîêàçàòü/ñêðûòü ìåíþ">ÌÅÍÞ</span>
</div>
<div class="page">&nbsp;&nbsp;&nbsp;
</div>
<div class="cpage" onclick="toggleFullScreen();return false;">
<span title="F, F11, ` (àïîñòðîô) - âêë./âûêë. ïîëíûé ýêðàí">&lt;---&gt;</span>
</div>
<div class="page">&nbsp;&nbsp;&nbsp;
</div>
<div class="cpage" onclick="incFont(1);return false;">
<span title="A - óâåëè÷èòü ðàçìåð øðèôòà">A+</span>
</div>
<div class="page">&nbsp;
</div>
<div class="cpage" onclick="incFont(-1);return false;">
<span title="Shift+A - óìåíüøèòü ðàçìåð øðèôòà">A-</span>
</div>
<div class="page">&nbsp;&nbsp;
</div>
<div class="cpage" onclick="return toggleScroll();">
<span title="Z, Shift+Down - âêë./âûêë. ïëàâíûé ñêðîëëèíã òåêñòà">$</span>
</div>
<div class="page">&nbsp;&nbsp;
</div>
<div id="reload" class="cpage" onclick="return reloadBook();">
<span title="R - ïðèíóäèòåëüíî îáíîâèòü êíèãó â îáõîä êýøà">@</span>
</div>
<div class="page" style="width: 20px">&nbsp;
</div>
</div>
<div id="orig" class="page">
<a id="orig_href" href="" target="_blank">&nbsp;</a>
</div>
<div id="id_rp" style="position: absolute; right: 0">
<div id="pageCount" class="page">
<div onmousedown="pageMove(1);" onmouseout="pageMoveClear();" onmouseup="pageMoveClear();">&lt;&nbsp;
</div>
<div onclick="pageMoveShow();" style="visibility:visible;">1/1
</div>
<div onmousedown="pageMove(0); " onmouseout="pageMoveClear();" onmouseup="pageMoveClear();">&nbsp;&gt;
</div>
</div>
<div id="pagePercent" class="page">
</div>
<div id="tm" class="page">
</div>
<div class="page">&nbsp;&nbsp;&nbsp;
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1 @@
omnireader.ru

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View 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;
}

View 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>&nbsp;',
'/TITLE' => '<br>&nbsp;',
'UL' => chr(13) . chr(10) . ' ',
'/UL' => chr(13) . chr(10),
// fb2
'EMPTY-LINE/' => '<P>&nbsp;',
'STANZA' => '<P>&nbsp;',
'V' => '<P>',
'/POEM' => '<P>&nbsp;',
'SUBTITLE' => '<br>&nbsp;<P>',
'/SUBTITLE' => '<br>&nbsp;',
);
$inner_cut = array(
'HEAD' => 1,
'SCRIPT' => 1,
'STYLE' => 1,
//fb2
'BINARY' => 1,
'DESCRIPTION' => 1,
);
if ($remove_tags)
$substs = $inner_cut = array();
$data = str_replace('&nbsp;', ' ', $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;
}
?>

View File

@@ -0,0 +1,2 @@
User-agent: *
Disallow: /?*url=

View File

@@ -0,0 +1,4 @@
<?php
header('Content-Type: text/html; charset=windows-1251');
echo getcwd();
?>

View File

@@ -0,0 +1,2 @@
AddType 'text/plain; charset=windows-1251' .txz .txt
AddEncoding gzip .txz

View File

@@ -23,3 +23,26 @@ server {
root /home/liberama/public;
}
}
server {
listen 11080;
server_name 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;
}
}

View File

@@ -4,6 +4,17 @@ mkdir /home/liberama
chown 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
cp omnireader /etc/nginx/sites-available/omnireader

View File

@@ -1,6 +1,6 @@
{
"name": "Liberama",
"version": "0.2.0",
"version": "0.3.1",
"engines": {
"node": ">=10.0.0"
},

View File

@@ -43,7 +43,7 @@ class BookConverter {
else {
//может это чистый текст?
if (textUtils.checkIfText(data)) {
await fs.writeFile(outputFile, this.convertHtml(data));
await fs.writeFile(outputFile, this.convertHtml(data, true));
return;
}
@@ -167,7 +167,7 @@ class BookConverter {
titleInfo['book-title'] = title;
//подозрение на чистый текст, надо разбить на параграфы
if ((isText || pars.length < buf.length/2000) && spaceCounter.length) {
if (isText || pars.length < buf.length/2000) {
let total = 0;
for (let i = 0; i < spaceCounter.length; i++) {
total += (spaceCounter[i] ? spaceCounter[i] : 0);
@@ -176,41 +176,37 @@ class BookConverter {
let i = spaceCounter.length - 1;
while (i > 0 && (!spaceCounter[i] || spaceCounter[i] < total)) i--;
const parIndent = i;
if (parIndent > 0) {//нашли отступ параграфа
const parIndent = (i > 0 ? i : 0);
let newPars = [];
const newPar = () => {
newPars.push({_n: 'p', _t: ''});
};
let newPars = [];
const newPar = () => {
newPars.push({_n: 'p', _t: ''});
};
const growPar = (text) => {
const l = newPars.length;
if (l) {
newPars[l - 1]._t += text;
}
const growPar = (text) => {
const l = newPars.length;
if (l) {
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 {
body.section._a[0] = pars;
}
@@ -288,11 +284,9 @@ class BookConverter {
openTag('p');
break;
case 'i':
openTag('emphasis');
italic = true;
break;
case 'b':
openTag('strong');
bold = true;
break;
case 'div':
@@ -338,11 +332,9 @@ class BookConverter {
closeTag('p');
break;
case 'i':
closeTag('emphasis');
italic = false;
break;
case 'b':
closeTag('strong');
bold = false;
break;
case 'div':

View File

@@ -70,13 +70,22 @@ function getEncoding(buf) {
function checkIfText(buf) {
let spaceCount = 0;
let crCount = 0;
let lfCount = 0;
for (let i = 0; i < buf.length; i++) {
if (buf[i] == 32)
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 (spaceFreq > 0.1 || crFreq > 0.03 || lfFreq > 0.03);
}
module.exports = {