Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None of my epub files work with the epub.js reader... #78

Closed
billgoodyear opened this issue Dec 28, 2013 · 15 comments
Closed

None of my epub files work with the epub.js reader... #78

billgoodyear opened this issue Dec 28, 2013 · 15 comments

Comments

@billgoodyear
Copy link

I downloaded the epub.js package, and tested it on my server. It works great with the bundled moby-dick book.

I then changed the reference to Moby Dick to one of my own epub files that was uploaded by a customer. The epub file reads in Calibre, Nook etc, but not in epub.js.

I've tried both zipped and unzipped and gotten no result. It seems to pull out the title and author information and then just hangs - the first page never renders. And using the backwards and forwards buttons does nothing.

I'll be more than happy to email over a copy of one of the epub files that im using so that you can reproduce the problem.

Any help you can provide will be appreciated.

Regards, Bill.

@munners17
Copy link

What version of epub is the book you are trying to load? Epub3 is fully supported but other versions should work... Could you email a copy of your epub to the email listed on my github profile?

@billgoodyear
Copy link
Author

Hi Luis,

Try the attached epub.

They are nothing special. We have a self service epub upload service where publishers and authors can upload their epub files – so we get all sorts.

I was successful in using the attached epub file in Monocle and EFM – but I prefer epub . Js as a solution if we can make it work.

Best Wishes,

Bill Goodyear

From: Luis Aguilar <notifications@github.commailto:notifications@github.com>
Reply-To: "futurepress/epub.js" <reply@reply.github.commailto:reply@reply.github.com>
Date: Saturday, December 28, 2013 at 2:28 PM
To: "futurepress/epub.js" <epub.js@noreply.github.commailto:epub.js@noreply.github.com>
Cc: Bill Goodyear <bill@deepercalling.commailto:bill@deepercalling.com>
Subject: Re: [epub.js] None of my epub files work with the epub.js reader... (#78)

What version of epub is the book you are trying to load? Epub3 is fully supported but other versions should work... Could you email a copy of your epub to the email listed on my github profile?


Reply to this email directly or view it on GitHubhttps://github.com//issues/78#issuecomment-31303073.

@munners17
Copy link

Hi Bill,

I didn't receive the epub attachment. Could you please send it again directly to my email?

Thanks,
Luis

@billgoodyear
Copy link
Author

Sure, what email address do you want me to send to? Just let me know.

You can also download from the following links:

http://www.deepershopping.com/includes/epub.js-master/demo/pathways.epub

And also

http://www.deepershopping.com/imagelib/digital_products/000/000/000/161/epubsample/Sample_Pathways to the King eBook.epub

Hope that helps.

Best Wishes,

Bill.

From: Luis Aguilar <notifications@github.commailto:notifications@github.com>
Reply-To: "futurepress/epub.js" <reply@reply.github.commailto:reply@reply.github.com>
Date: Sunday, December 29, 2013 at 12:12 AM
To: "futurepress/epub.js" <epub.js@noreply.github.commailto:epub.js@noreply.github.com>
Cc: Bill Goodyear <bill@deepercalling.commailto:bill@deepercalling.com>
Subject: Re: [epub.js] None of my epub files work with the epub.js reader... (#78)

Hi Bill,

I didn't receive the epub attachment. Could you please send it again directly to my email?

Thanks,
Luis


Reply to this email directly or view it on GitHubhttps://github.com//issues/78#issuecomment-31311660.

@X-Ryl669
Copy link

X-Ryl669 commented Jan 6, 2014

Same for me.

The systems tries to fetch the epub file, succeed, then "fetches" strange URL like:
http://myserver/f070e74d-48f3-4e5d-92f2-0b07fd6f3299
Some works, one is failing (in fact it downloads as a file and stop any other processing)
The console outputs:

Resource interpreted as Document but transferred with MIME type application/octet-stream: "blob:http%3A//myserver/f070e74d-48f3-4e5d-92f2-0b07fd6f3299" (file: epub.js:2570)

The line is for the source file is:
this.iframe.src = url;

The above warning happens even if mime-types.js is included from zip.js library

@X-Ryl669
Copy link

X-Ryl669 commented Jan 6, 2014

In fact after a lot of debugging, I've solved it.
The issue is that some chapter holds relative links to the current chapter's file, not the table of content.
So this fails to find the links and then, the rendering.
The fix is to change EPUBJS.Renderer.replaceWithStored with this code:

EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callback) {
        var _oldUrls,
                _newUrls = {},
                _store = this.determineStore(),
                _cache = this.caches[query],
                _contentsPath = this.book.settings.contentsPath,
// Add this here to keep track
                _chapterPath = this.book.chapter.href,
                _manifest = this.book.manifest,
// Previous code resume here
                _attr = attr,
[...]

        this.replace(query, function(link, done){

                var src = link.getAttribute(_attr),
                        full = EPUBJS.core.resolveUrl(_contentsPath, src),
// Also resolve relative links
                        rel = EPUBJS.core.resolveUrl(_chapterPath, src),
// Previous code resume here
                        replaceUrl = function(url) {
                                link.setAttribute(_attr, url);
                                link.onload = function(){
                                        done(url, full);
                                };
                        };

// Check if full url is in the manifest
                var foundFull = false, foundRel = false;
                for (var entry in _manifest) {
                    if (_manifest[entry].href == full) { foundFull = true; break; }
                    if (_manifest[entry].href == rel) { foundRel = true; break; }
                }
                // The link is probably relative to the chapter
                if (!foundFull && foundRel) full = rel;
                if (!foundFull && !foundRel) {
                    console.error(src);
                    return;
                }
// Previous code resume here
               if(full in _oldUrls){
                        replaceUrl(_oldUrls[full]);
[...]

@billgoodyear
Copy link
Author

Awesome. Im going to try it tomorrow. I”ve been using Monocle and EFM as a backup and it works, but its not as nice as the epub.js solution in terms of its user interface. Epub.js has a much better user interface model.
Thanks for the update!!

From: X-Ryl669 [mailto:notifications@github.com]
Sent: Monday, January 06, 2014 4:33 PM
To: futurepress/epub.js
Cc: Bill Goodyear
Subject: Re: [epub.js] None of my epub files work with the epub.js reader... (#78)

In fact after a lot of debugging, I've solved it.
The issue is that some chapter holds relative links to the current chapter's file, not the table of content.
So this fails to find the links and then, the rendering.
The fix is to change EPUBJS.Renderer.replaceWithStored with this code:

……..

@X-Ryl669
Copy link

X-Ryl669 commented Jan 6, 2014

BTW, there's also this project which has a clean interface:
https://github.com/readium/readium-js-viewer
And, up to now, worked with all the EPub I've thrown at it.

@fchasen
Copy link
Contributor

fchasen commented Jan 7, 2014

Thanks @X-Ryl669 and @billgoodyear
I had never seen a epub with the opf file outside of contents folder before but adding the chapter path did the trick.

Added a URl parsing method to get the base for the chapter

EPUBJS.core.uri(url).base

and used that to resolve the urls.

This change got rolled in with a number of other changes, which should be merged by the end of the week.

Meanwhile - could you try this branch?
https://github.com/futurepress/epub.js/tree/reader-refactor

@fchasen
Copy link
Contributor

fchasen commented Jan 7, 2014

Changes have been merged to master, so you can pull to try them or download the latest release.

@X-Ryl669
Copy link

X-Ryl669 commented Jan 7, 2014

Alright, it's working.

@fchasen
Copy link
Contributor

fchasen commented Jan 9, 2014

Added a timeout fail safe in in v0.1.8 since "load" events seem very unreliable.

@fchasen fchasen closed this as completed Jan 9, 2014
@billgoodyear
Copy link
Author

Discovered a new bug. See the epub file as follows:

http://www.deepershopping.com/imagelib/digital_products/000/000/000/264/epubfile/DarkPoolBroken.epub

The problem is that in the CoverImage.xhtml file it refers to an image – the URL in the image is entity encoded so that the space character is converted to %20 – but the actual file name contains spaces not the %20. So in CoverImage.xhtml you will see "image/Dark%20Pool%203%203%20final.jpg” – but the filename in the zip file is "image/Dark Pool 3 3 final.jpg”

Currently the monocle browser locks up and does not render the text of the book when there is a broken image in this format.

The system needs a fallback in that if it detects there are entity encodings in the URL it tries to load it with the entities and without the entities.

To test I remove entity encodings from the CoverImage.xthml file and the epub file renders correctly. Adding the entity encodings back in and it barfs.

Thanks,

Bill Goodyear

From: X-Ryl669 [mailto:notifications@github.com]
Sent: Tuesday, January 07, 2014 3:52 AM
To: futurepress/epub.js
Cc: Bill Goodyear
Subject: Re: [epub.js] None of my epub files work with the epub.js reader... (#78)

Alright, it's working.


Reply to this email directly or view it on GitHubhttps://github.com//issues/78#issuecomment-31721525.

@fchasen
Copy link
Contributor

fchasen commented Jan 14, 2014

Great Bug report! Thanks for tracking that down.

Fixed in: https://github.com/futurepress/epub.js/releases/tag/v0.1.9

@X-Ryl669
Copy link

Another one that fails (the first page load, not the others)
http://www.sendspace.com/file/oy9cmq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants