Улучшил парсинг имени автора из fb2
This commit is contained in:
@@ -164,11 +164,21 @@ class HistoryPage extends Vue {
|
|||||||
else
|
else
|
||||||
title = '';
|
title = '';
|
||||||
|
|
||||||
let author = _.compact([
|
let author = '';
|
||||||
fb2.lastName,
|
if (fb2.author) {
|
||||||
fb2.firstName,
|
const authorNames = fb2.author.map(a => _.compact([
|
||||||
fb2.middleName
|
a.lastName,
|
||||||
]).join(' ');
|
a.firstName,
|
||||||
|
a.middleName
|
||||||
|
]).join(' '));
|
||||||
|
author = authorNames.join(', ');
|
||||||
|
} else {
|
||||||
|
author = _.compact([
|
||||||
|
fb2.lastName,
|
||||||
|
fb2.firstName,
|
||||||
|
fb2.middleName
|
||||||
|
]).join(' ');
|
||||||
|
}
|
||||||
author = (author ? author : (fb2.bookTitle ? fb2.bookTitle : book.url));
|
author = (author ? author : (fb2.bookTitle ? fb2.bookTitle : book.url));
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
|
|||||||
@@ -377,13 +377,17 @@ class TextPage extends Vue {
|
|||||||
this.meta = bookManager.metaOnly(this.book);
|
this.meta = bookManager.metaOnly(this.book);
|
||||||
this.fb2 = this.meta.fb2;
|
this.fb2 = this.meta.fb2;
|
||||||
|
|
||||||
const authorName = _.compact([
|
let authorNames = [];
|
||||||
this.fb2.lastName,
|
if (this.fb2.author) {
|
||||||
this.fb2.firstName,
|
authorNames = this.fb2.author.map(a => _.compact([
|
||||||
this.fb2.middleName
|
a.lastName,
|
||||||
]).join(' ');
|
a.firstName,
|
||||||
|
a.middleName
|
||||||
|
]).join(' '));
|
||||||
|
}
|
||||||
|
|
||||||
this.title = _.compact([
|
this.title = _.compact([
|
||||||
authorName,
|
authorNames.join(', '),
|
||||||
this.fb2.bookTitle
|
this.fb2.bookTitle
|
||||||
]).join(' - ');
|
]).join(' - ');
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,12 @@ export default class BookParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elemName == 'author' && path.indexOf('/fictionbook/description/title-info/author') == 0) {
|
||||||
|
if (!fb2.author)
|
||||||
|
fb2.author = [];
|
||||||
|
fb2.author.push({});
|
||||||
|
}
|
||||||
|
|
||||||
if (path.indexOf('/fictionbook/body') == 0) {
|
if (path.indexOf('/fictionbook/body') == 0) {
|
||||||
if (tag == 'body') {
|
if (tag == 'body') {
|
||||||
if (!isFirstBody)
|
if (!isFirstBody)
|
||||||
@@ -319,15 +325,19 @@ export default class BookParser {
|
|||||||
|
|
||||||
text = text.replace(/[\t\n\r\xa0]/g, ' ');
|
text = text.replace(/[\t\n\r\xa0]/g, ' ');
|
||||||
|
|
||||||
|
const authorLength = (fb2.author && fb2.author.length ? fb2.author.length : 0);
|
||||||
switch (path) {
|
switch (path) {
|
||||||
case '/fictionbook/description/title-info/author/first-name':
|
case '/fictionbook/description/title-info/author/first-name':
|
||||||
fb2.firstName = text;
|
if (authorLength)
|
||||||
|
fb2.author[authorLength - 1].firstName = text;
|
||||||
break;
|
break;
|
||||||
case '/fictionbook/description/title-info/author/middle-name':
|
case '/fictionbook/description/title-info/author/middle-name':
|
||||||
fb2.middleName = text;
|
if (authorLength)
|
||||||
|
fb2.author[authorLength - 1].middleName = text;
|
||||||
break;
|
break;
|
||||||
case '/fictionbook/description/title-info/author/last-name':
|
case '/fictionbook/description/title-info/author/last-name':
|
||||||
fb2.lastName = text;
|
if (authorLength)
|
||||||
|
fb2.author[authorLength - 1].lastName = text;
|
||||||
break;
|
break;
|
||||||
case '/fictionbook/description/title-info/genre':
|
case '/fictionbook/description/title-info/genre':
|
||||||
fb2.genre = text;
|
fb2.genre = text;
|
||||||
|
|||||||
Reference in New Issue
Block a user