workhorsy / comic_book_reader

A browser based touch friendly comic book reader
GNU Affero General Public License v3.0
21 stars 7 forks source link

Embed API #118

Open btzr-io opened 6 years ago

btzr-io commented 6 years ago

Embed api to integrate on other websites and apps. @workhorsy See: https://github.com/lbryio/lbry-app/issues/1377

btzr-io commented 6 years ago

Something like this?

api/reader?source=url...

We could also pass default settings:

api/reader?source=url..&nightmode=true
workhorsy commented 6 years ago

This is a good idea. Then people could use it to post a link to a comic, or embed the reader in another web app. Cool.

btzr-io commented 6 years ago

@workhorsy I did some work on this, Here is the current usage:

Main url ( show / navigate to reader )

http://localhost:8080/#/reader

Load comic ( url / blob to archive file)

If no file is provided it should show the files component:

http://localhost:8080/#/reader?file={url}

Page number ( set initial page: default to 1 )

http://localhost:8080/#/reader?pg=1

workhorsy commented 6 years ago

Does it work with loading files? I tried

http://localhost:8080/#/reader?file=http://localhost:9999/example.cbr

and it does not load. It still loads the test images.

Is it hooked up to loading files from cbz yet?

btzr-io commented 6 years ago

@workhorsy do a git pull and try this:

http://localhost:8080/#/reader?file=https://raw.githubusercontent.com/workhorsy/uncompress.js/master/example_rar_5.rar

I tried to use the uncompress download example but isn't working :confused:

action: "error" , error: "Failed to open 'rar' archive."
btzr-io commented 6 years ago

Update: uncompress works in the main tread but not inside the web-worker

@workhorsy Any ideas? Let me know if you have time to look into this.

Post message (start uncompress)

https://github.com/btzr-io/comic_book_reader/blob/preact/src/routes/viewer/view.jsx#L42

The Worker

https://github.com/btzr-io/comic_book_reader/blob/preact/src/routes/viewer/lib/uncompress.worker.js

workhorsy commented 6 years ago

I'll see if I can figure it out. I might be able to squeeze in some time in the morning.

workhorsy commented 6 years ago

Looks like zip is working:

http://localhost:8080/#/reader?file=http://localhost:8080/test/example.cbz

but not rar:

http://localhost:8080/#/reader?file=http://localhost:8080/test/example.cbr
workhorsy commented 6 years ago

I think I've got it figured out. The problem is that the worker calls loadArchiveFormats(['rar', 'zip', 'tar']) to start loading the compression formats. But the view starts sending it messages before loadArchiveFormats is done. You need the worker to send a signal to the view when it is done with loadArchiveFormats.

workhorsy commented 6 years ago

Here is a PR to fix this. I should probably update the uncompress.js worker example to do this too. It looks like a usability bug. Now this should work

http://localhost:8080/#/reader?file=http://localhost:8080/test/example.cbr

https://github.com/btzr-io/comic_book_reader/pull/2

btzr-io commented 6 years ago

Great thanks!, I'll merge this ASAP.

btzr-io commented 6 years ago

Here is the live demo (at least now it's working): https://btzr-io.github.io/comic_book_reader/#/reader?file=https://raw.githubusercontent.com/workhorsy/uncompress.js/master/example_rar_5.rar