mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
built latest
This commit is contained in:
parent
47df4dcd02
commit
edb7a38e59
2 changed files with 42 additions and 27 deletions
|
@ -21,7 +21,7 @@ EPUBJS.Book = function(bookPath, options){
|
||||||
height: false,
|
height: false,
|
||||||
spreads: true,
|
spreads: true,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
version: 1.1,
|
version: 1,
|
||||||
restore: true
|
restore: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ EPUBJS.Book.prototype.unpack = function(containerPath){
|
||||||
then(function(contents){
|
then(function(contents){
|
||||||
|
|
||||||
book.contents = contents;
|
book.contents = contents;
|
||||||
|
|
||||||
book.manifest = book.contents.manifest;
|
book.manifest = book.contents.manifest;
|
||||||
book.spine = book.contents.spine;
|
book.spine = book.contents.spine;
|
||||||
book.spineIndexByURL = book.contents.spineIndexByURL;
|
book.spineIndexByURL = book.contents.spineIndexByURL;
|
||||||
|
@ -897,6 +896,8 @@ EPUBJS.core.folder = function(url){
|
||||||
var slash = url.lastIndexOf('/'),
|
var slash = url.lastIndexOf('/'),
|
||||||
folder = url.slice(0, slash + 1);
|
folder = url.slice(0, slash + 1);
|
||||||
|
|
||||||
|
if(slash == -1) folder = '';
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1350,43 +1351,52 @@ EPUBJS.Parser.prototype.metadata = function(xml){
|
||||||
p = this;
|
p = this;
|
||||||
|
|
||||||
|
|
||||||
metadata.bookTitle = p.getElement(xml, 'title');
|
metadata.bookTitle = p.getElementText(xml, 'title');
|
||||||
metadata.creator = p.getElement(xml, 'creator');
|
metadata.creator = p.getElementText(xml, 'creator');
|
||||||
metadata.description = p.getElement(xml, 'description');
|
metadata.description = p.getElementText(xml, 'description');
|
||||||
|
|
||||||
metadata.pubdate = p.getElement(xml, 'date');
|
metadata.pubdate = p.getElementText(xml, 'date');
|
||||||
|
|
||||||
metadata.publisher = p.getElement(xml, 'publisher');
|
metadata.publisher = p.getElementText(xml, 'publisher');
|
||||||
|
|
||||||
metadata.identifier = p.getElement(xml, "identifier");
|
metadata.identifier = p.getElementText(xml, "identifier");
|
||||||
metadata.language = p.getElement(xml, "language");
|
metadata.language = p.getElementText(xml, "language");
|
||||||
metadata.rights = p.getElement(xml, "rights");
|
metadata.rights = p.getElementText(xml, "rights");
|
||||||
|
|
||||||
|
|
||||||
metadata.modified_date = p.querySelector(xml, "meta[property='dcterms:modified']");
|
metadata.modified_date = p.querySelectorText(xml, "meta[property='dcterms:modified']");
|
||||||
metadata.layout = p.querySelector(xml, "meta[property='rendition:orientation']");
|
metadata.layout = p.querySelectorText(xml, "meta[property='rendition:orientation']");
|
||||||
metadata.orientation = p.querySelector(xml, "meta[property='rendition:orientation']");
|
metadata.orientation = p.querySelectorText(xml, "meta[property='rendition:orientation']");
|
||||||
metadata.spread = p.querySelector(xml, "meta[property='rendition:spread']");
|
metadata.spread = p.querySelectorText(xml, "meta[property='rendition:spread']");
|
||||||
|
|
||||||
// metadata.page_prog_dir = packageXml.querySelector("spine").getAttribute("page-progression-direction");
|
// metadata.page_prog_dir = packageXml.querySelector("spine").getAttribute("page-progression-direction");
|
||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
EPUBJS.Parser.prototype.getElement = function(xml, tag){
|
EPUBJS.Parser.prototype.getElementText = function(xml, tag){
|
||||||
var find = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag),
|
var found = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag),
|
||||||
el;
|
el;
|
||||||
|
|
||||||
if(!find) return '';
|
if(!found || found.length == 0) return '';
|
||||||
|
|
||||||
el = find[0];
|
el = found[0];
|
||||||
|
|
||||||
|
if(el.childNodes.length){
|
||||||
|
return el.childNodes[0].nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
|
||||||
return el ? el.childNodes[0].nodeValue : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EPUBJS.Parser.prototype.querySelector = function(xml, q){
|
EPUBJS.Parser.prototype.querySelectorText = function(xml, q){
|
||||||
var el = xml.querySelector(q);
|
var el = xml.querySelector(q);
|
||||||
return el ? el.childNodes[0].nodeValue : '';
|
|
||||||
|
if(el && el.childNodes.length){
|
||||||
|
return el.childNodes[0].nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2010,6 +2020,11 @@ EPUBJS.Renderer.prototype.replaceUrlsInCss = function(base, text){
|
||||||
store = this.determineStore(),
|
store = this.determineStore(),
|
||||||
matches = text.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);
|
matches = text.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);
|
||||||
|
|
||||||
|
if(!matches){
|
||||||
|
promise.resolve(text);
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
matches.forEach(function(str){
|
matches.forEach(function(str){
|
||||||
var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, ''));
|
var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, ''));
|
||||||
replaced = store.getUrl(full).then(function(url){
|
replaced = store.getUrl(full).then(function(url){
|
||||||
|
|
4
demo/js/epub.min.js
vendored
4
demo/js/epub.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue