Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f7cafb240 | ||
|
|
08fd0f15ff | ||
|
|
dbb1bfe587 | ||
|
|
fe4b7a5a85 | ||
|
|
d8df5d76e5 | ||
|
|
b65dcc5ade | ||
|
|
a5c387a19e | ||
|
|
07c38d9a9f | ||
|
|
20ac8a444b | ||
|
|
7b601c9c7f | ||
|
|
8d2f74daa4 | ||
|
|
01e82dca5f |
@@ -112,6 +112,7 @@ class RecentBooksPage extends Vue {
|
|||||||
pagination = {};
|
pagination = {};
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
this.firstInit = true;
|
||||||
this.pagination = {rowsPerPage: 0};
|
this.pagination = {rowsPerPage: 0};
|
||||||
|
|
||||||
this.columns = [
|
this.columns = [
|
||||||
@@ -167,26 +168,11 @@ class RecentBooksPage extends Vue {
|
|||||||
this.initing = true;
|
this.initing = true;
|
||||||
|
|
||||||
|
|
||||||
if (!bookManager.loaded) {
|
if (this.firstInit) {//для отзывчивости
|
||||||
await this.updateTableData(10);
|
await this.updateTableData(20);
|
||||||
//для отзывчивости
|
this.firstInit = false;
|
||||||
await utils.sleep(100);
|
|
||||||
let i = 0;
|
|
||||||
let j = 5;
|
|
||||||
while (i < 500 && !bookManager.loaded) {
|
|
||||||
if (i % j == 0) {
|
|
||||||
bookManager.sortedRecentCached = null;
|
|
||||||
await this.updateTableData(20);
|
|
||||||
j *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
await utils.sleep(100);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//для отзывчивости
|
|
||||||
await utils.sleep(100);
|
|
||||||
}
|
}
|
||||||
|
await utils.sleep(50);
|
||||||
await this.updateTableData();
|
await this.updateTableData();
|
||||||
this.initing = false;
|
this.initing = false;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -580,8 +580,8 @@ class ServerStorage extends Vue {
|
|||||||
let newRecent = {};
|
let newRecent = {};
|
||||||
if (!itemKey || (needSaveRecentPatch && Object.keys(newRecentPatch.data).length > 10)) {
|
if (!itemKey || (needSaveRecentPatch && Object.keys(newRecentPatch.data).length > 10)) {
|
||||||
//ждем весь bm.recent
|
//ждем весь bm.recent
|
||||||
while (!bookManager.loaded)
|
/*while (!bookManager.loaded)
|
||||||
await utils.sleep(100);
|
await utils.sleep(100);*/
|
||||||
|
|
||||||
newRecent = {rev: this.cachedRecent.rev + 1, data: _.cloneDeep(bm.recent)};
|
newRecent = {rev: this.cachedRecent.rev + 1, data: _.cloneDeep(bm.recent)};
|
||||||
newRecentPatch = {rev: this.cachedRecentPatch.rev + 1, data: {}};
|
newRecentPatch = {rev: this.cachedRecentPatch.rev + 1, data: {}};
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class BookManager {
|
|||||||
|
|
||||||
this.saveRecentItem = _.debounce(() => {
|
this.saveRecentItem = _.debounce(() => {
|
||||||
bmRecentStoreNew.setItem('recent-item', this.recentItem);
|
bmRecentStoreNew.setItem('recent-item', this.recentItem);
|
||||||
this.recentRev++;
|
this.recentRev = (this.recentRev < 1000 ? this.recentRev + 1 : 1);
|
||||||
bmRecentStoreNew.setItem('rev', this.recentRev);
|
bmRecentStoreNew.setItem('rev', this.recentRev);
|
||||||
}, 200, {maxWait: 300});
|
}, 200, {maxWait: 300});
|
||||||
|
|
||||||
@@ -64,6 +64,8 @@ class BookManager {
|
|||||||
|
|
||||||
await this.cleanRecentBooks();
|
await this.cleanRecentBooks();
|
||||||
|
|
||||||
|
if (this.recentRev > 10)
|
||||||
|
await bmRecentStoreOld.clear();
|
||||||
} else {//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет
|
} else {//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет
|
||||||
this.recentLast = await bmRecentStoreOld.getItem('recent-last');
|
this.recentLast = await bmRecentStoreOld.getItem('recent-last');
|
||||||
if (this.recentLast) {
|
if (this.recentLast) {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
sudo -H -u www-data /home/beta.liberama/liberama
|
sudo -H -u www-data bash -c "cd /var/www; /home/beta.liberama/liberama"
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ sudo chown www-data.www-data /home/liberama
|
|||||||
|
|
||||||
### external converter `calibre`, download from https://download.calibre-ebook.com/
|
### external converter `calibre`, download from https://download.calibre-ebook.com/
|
||||||
```
|
```
|
||||||
wget "https://download.calibre-ebook.com/3.39.1/calibre-3.39.1-x86_64.txz"
|
wget "https://download.calibre-ebook.com/5.5.0/calibre-5.5.0-x86_64.txz"
|
||||||
sudo -u www-data mkdir -p /home/liberama/data/calibre
|
sudo -u www-data mkdir -p /home/liberama/data/calibre
|
||||||
sudo -u www-data tar xvf calibre-3.39.1-x86_64.txz -C /home/liberama/data/calibre
|
sudo -u www-data tar xvf calibre-5.5.0-x86_64.txz -C /home/liberama/data/calibre
|
||||||
```
|
```
|
||||||
|
|
||||||
### external converters
|
### external converters
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if ! pgrep -x "liberama" > /dev/null ; then
|
if ! pgrep -x "liberama" > /dev/null ; then
|
||||||
sudo -H -u www-data /home/liberama/liberama
|
sudo -H -u www-data bash -c "cd /var/www; /home/liberama/liberama"
|
||||||
else
|
else
|
||||||
echo "Process 'liberama' already running"
|
echo "Process 'liberama' already running"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
sudo -H -u www-data /home/liberama/liberama &
|
sudo -H -u www-data bash -c "cd /var/www; /home/liberama/liberama" &
|
||||||
sudo service cron start
|
sudo service cron start
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class FileDetector {
|
|||||||
|
|
||||||
fromBuffer(buffer, callback) {
|
fromBuffer(buffer, callback) {
|
||||||
let result = null;
|
let result = null;
|
||||||
|
//console.log(buffer);
|
||||||
const invalidSignaturesList = this.validateSigantures();
|
const invalidSignaturesList = this.validateSigantures();
|
||||||
if (invalidSignaturesList.length) {
|
if (invalidSignaturesList.length) {
|
||||||
return callback(invalidSignaturesList);
|
return callback(invalidSignaturesList);
|
||||||
|
|||||||
@@ -676,7 +676,9 @@
|
|||||||
{ "type": "equal", "end": 19, "bytes": "3c3f786d6c2076657273696f6e3d22312e3022" },
|
{ "type": "equal", "end": 19, "bytes": "3c3f786d6c2076657273696f6e3d22312e3022" },
|
||||||
{ "type": "equal", "end": 22, "bytes": "efbbbf3c3f786d6c2076657273696f6e3d22312e3022" },
|
{ "type": "equal", "end": 22, "bytes": "efbbbf3c3f786d6c2076657273696f6e3d22312e3022" },
|
||||||
{ "type": "equal", "end": 19, "bytes": "3c3f786d6c2076657273696f6e3d27312e3027" },
|
{ "type": "equal", "end": 19, "bytes": "3c3f786d6c2076657273696f6e3d27312e3027" },
|
||||||
{ "type": "equal", "end": 22, "bytes": "efbbbf3c3f786d6c2076657273696f6e3d27312e3027" }
|
{ "type": "equal", "end": 22, "bytes": "efbbbf3c3f786d6c2076657273696f6e3d27312e3027" },
|
||||||
|
{ "type": "equal", "end": 40, "bytes": "fffe3c003f0078006d006c002000760065007200730069006f006e003d00220031002e0030002200" },
|
||||||
|
{ "type": "equal", "end": 40, "bytes": "fffe3c003f0078006d006c002000760065007200730069006f006e003d00270031002e0030002700" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ class ConvertBase {
|
|||||||
abort
|
abort
|
||||||
});
|
});
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
let error = result.code;
|
const error = `${result.code}|FORLOG|, exec: ${path}, args: ${args.join(' ')}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
||||||
if (this.config.branch == 'development')
|
|
||||||
error = `exec: ${path}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
|
||||||
throw new Error(`Внешний конвертер завершился с ошибкой: ${error}`);
|
throw new Error(`Внешний конвертер завершился с ошибкой: ${error}`);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const ConvertBase = require('./ConvertBase');
|
const ConvertBase = require('./ConvertBase');
|
||||||
const iconv = require('iconv-lite');
|
const iconv = require('iconv-lite');
|
||||||
|
const textUtils = require('./textUtils');
|
||||||
|
|
||||||
class ConvertFb2 extends ConvertBase {
|
class ConvertFb2 extends ConvertBase {
|
||||||
check(data, opts) {
|
check(data, opts) {
|
||||||
@@ -9,26 +10,46 @@ class ConvertFb2 extends ConvertBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(data, opts) {
|
async run(data, opts) {
|
||||||
if (!this.check(data, opts))
|
let newData = data;
|
||||||
|
|
||||||
|
//Корректируем кодировку, 16-битные кодировки должны стать utf-8
|
||||||
|
const encoding = textUtils.getEncoding(newData);
|
||||||
|
if (encoding.indexOf('UTF-16') == 0) {
|
||||||
|
newData = Buffer.from(iconv.decode(newData, encoding));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.check(newData, opts))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return this.checkEncoding(data);
|
return this.checkEncoding(newData);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEncoding(data) {
|
checkEncoding(data) {
|
||||||
let result = data;
|
let result = data;
|
||||||
|
|
||||||
const left = data.indexOf('<?xml version="1.0"');
|
let q = '"';
|
||||||
|
let left = data.indexOf('<?xml version="1.0"');
|
||||||
|
if (left < 0) {
|
||||||
|
left = data.indexOf('<?xml version=\'1.0\'');
|
||||||
|
q = '\'';
|
||||||
|
}
|
||||||
|
|
||||||
if (left >= 0) {
|
if (left >= 0) {
|
||||||
const right = data.indexOf('?>', left);
|
const right = data.indexOf('?>', left);
|
||||||
if (right >= 0) {
|
if (right >= 0) {
|
||||||
const head = data.slice(left, right + 2).toString();
|
const head = data.slice(left, right + 2).toString();
|
||||||
const m = head.match(/encoding="(.*?)"/);
|
const m = head.match(/encoding=['"](.*?)['"]/);
|
||||||
if (m) {
|
if (m) {
|
||||||
let encoding = m[1].toLowerCase();
|
let encoding = m[1].toLowerCase();
|
||||||
if (encoding != 'utf-8') {
|
if (encoding != 'utf-8') {
|
||||||
result = iconv.decode(data, encoding);
|
//encoding может не соответсвовать реальной кодировке файла, поэтому:
|
||||||
result = Buffer.from(result.toString().replace(m[0], 'encoding="utf-8"'));
|
let calcEncoding = textUtils.getEncoding(data);
|
||||||
|
if (calcEncoding.indexOf('ISO-8859') >= 0) {
|
||||||
|
calcEncoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = iconv.decode(data, calcEncoding);
|
||||||
|
result = Buffer.from(result.toString().replace(m[0], `encoding=${q}utf-8${q}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class ConvertHtml extends ConvertBase {
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
//если разброс не слишком большой, выделяем параграфы
|
//если разброс не слишком большой, выделяем параграфы
|
||||||
if (d < 10 && spaceCounter.length) {
|
if (d < 20 && spaceCounter.length) {
|
||||||
total /= 20;
|
total /= 20;
|
||||||
i = spaceCounter.length - 1;
|
i = spaceCounter.length - 1;
|
||||||
while (i > 0 && (!spaceCounter[i] || spaceCounter[i] < total)) i--;
|
while (i > 0 && (!spaceCounter[i] || spaceCounter[i] < total)) i--;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ConvertPdf extends ConvertHtml {
|
|||||||
|
|
||||||
//конвертируем в xml
|
//конвертируем в xml
|
||||||
let perc = 0;
|
let perc = 0;
|
||||||
await this.execConverter(this.pdfToHtmlPath, ['-c', '-s', '-xml', inputFiles.sourceFile, outFile], () => {
|
await this.execConverter(this.pdfToHtmlPath, ['-nodrm', '-c', '-s', '-xml', inputFiles.sourceFile, outFile], () => {
|
||||||
perc = (perc < 80 ? perc + 10 : 40);
|
perc = (perc < 80 ? perc + 10 : 40);
|
||||||
callback(perc);
|
callback(perc);
|
||||||
}, abort);
|
}, abort);
|
||||||
|
|||||||
@@ -171,10 +171,15 @@ class ReaderWorker {
|
|||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(LM_ERR, e.stack);
|
log(LM_ERR, e.stack);
|
||||||
|
let mes = e.message.split('|FORLOG|');
|
||||||
|
if (mes[1])
|
||||||
|
log(LM_ERR, mes[0] + mes[1]);
|
||||||
log(LM_ERR, `downloadedFilename: ${downloadedFilename}`);
|
log(LM_ERR, `downloadedFilename: ${downloadedFilename}`);
|
||||||
if (e.message == 'abort')
|
|
||||||
e.message = overLoadMes;
|
mes = mes[0];
|
||||||
wState.set({state: 'error', error: e.message});
|
if (mes == 'abort')
|
||||||
|
mes = overLoadMes;
|
||||||
|
wState.set({state: 'error', error: mes});
|
||||||
} finally {
|
} finally {
|
||||||
//clean
|
//clean
|
||||||
if (q)
|
if (q)
|
||||||
|
|||||||
Reference in New Issue
Block a user