satorumurmur / bibi

Bibi | EPUB Reader on your website.
https://bibi.epub.link
MIT License
833 stars 123 forks source link

Using Bibi with PyQt5 and QtWebEngine in local mode always fails #118

Open kevinhendricks opened 3 years ago

kevinhendricks commented 3 years ago

I am building aPyQt5 app that used QtWebEngine (chrome browser engine) in local mode to open a local url. I have explicitly allowed local mode access in QtWebEngine (think Qt's version of Electron)

But bibi.js seems to be preventing any local file url from being used even though the QtWebEngine code explicitly is set to allow it.

ERROR: file:///Users/kbhend/Desktop/BibiReader/bibi/resources/scripts/bibi.js:11: Bibi can't open books via URL on local mode

If I comment out that line it will get slightly further and then fail with:

ERROR: file:///Users/kbhend/Desktop/BibiReader/bibi/resources/scripts/bibi.js:11: Failed to open the book (Probably CORS Blocked)

So unlike, Readium, and FuturePress epubjs, Bibi will not allow you to pass in a file url to a local unpacked epub even through the entire browser engine is housed locally, has explicitly given access to local file urls, and the path is local and relative to the bidi/index.html.

Are their settings in default.js or someplace else in Bidi that I can use to override this behaviour so that a standalone local reader can be developed.

We are trying to develop a set of Sigil plugins to view the current contents of the epub being edited in Sigil via various browser based e-readers so that epub developers can see what works and what does not more easily.

Thanks for any pointers.

ps. Without passing the query ?book=ebook, Bibi will nicely fire up and ask us to drag an .epub file on it whereas we need to pass it a file url to an already unpacked epub that is under Sigil's plugin control.

kevinhendricks commented 3 years ago

If I rezip the unpacked epub, I can pass its url just fine via the query. The issue is only with local unpacked epubs. I started studying bibi_heart.js and it appears to allow remote unpacked epubs but not local. This appears to be an artificial restriction. It would be silly to have to zip up the unpacked epub currently being edited in Sigil just to hand it to Bibi to be unzipped immediately. Being able to load local unpacked epubs would seem to be a reasonably valuable ability when using Bibi with things like Electron or QtWebEngine to create a completely local reader app.