Skip to content

Commit

Permalink
Updated coverUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
fchasen committed Dec 4, 2015
1 parent c13f698 commit af55831
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 13 deletions.
32 changes: 28 additions & 4 deletions dist/epub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/epub.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/epub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/epub.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion libs/mime/mime.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ function lookup(filename) {
return filename && mimeTypes[filename.split(".").pop().toLowerCase()] || defaultValue;
};

module.exports = lookup
module.exports = {
'lookup': lookup
}
17 changes: 16 additions & 1 deletion src/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Book.prototype.unpack = function(packageXml){
// MOVE TO RENDER
// book.globalLayoutProperties = book.parseLayoutProperties(book.package.metadata);

book.cover = book.url + book.package.coverPath;
book.cover = book.baseUrl + book.package.coverPath;
};

// Alias for book.spine.get
Expand Down Expand Up @@ -251,6 +251,21 @@ Book.prototype.isArchived = function(bookUrl){
return false;
};

//-- Returns the cover
Book.prototype.coverUrl = function(){
var retrieved = this.loaded.cover
.then(function(url) {
if(this.archive) {
return this.archive.createUrl(this.cover);
}else{
return this.cover;
}
}.bind(this));



return retrieved;
};
module.exports = Book;

//-- Enable binding events to book
Expand Down
11 changes: 9 additions & 2 deletions src/unarchive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ var request = require('./request');
var mime = require('../libs/mime/mime');

function Unarchive() {

this.checkRequirements();
this.urlCache = {};

}

Unarchive.prototype.checkRequirements = function(callback){
try {
if (typeof JSZip !== 'undefined') {
this.zip = new JSZip();
Expand All @@ -14,7 +21,7 @@ function Unarchive() {
} catch (e) {
console.error("JSZip lib not loaded");
}
}
};

Unarchive.prototype.open = function(zipUrl){
if (zipUrl instanceof ArrayBuffer) {
Expand Down Expand Up @@ -115,7 +122,7 @@ Unarchive.prototype.createUrl = function(url, mime){
return deferred.promise;
}

blob = this.getText(url);
blob = this.getBlob(url);

if (blob) {
tempUrl = _URL.createObjectURL(blob);
Expand Down

0 comments on commit af55831

Please sign in to comment.