View Single Post
Old 07-13-2021, 03:16 PM   #1
avnermoshkovitz
Member
avnermoshkovitz began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jun 2021
Device: Any ereader for Android or iOS
Calibre in mobile

Hi,
I'm new to ebook world, and calibre, so excuse me for the beginner and naieve questions.

I have a html5+javascript+css code that I want to run in mobile (Android).
Typically this kind of code is run with:
  • an online webserver, or
  • an local webserver (e.g. if someone wants to work offline)


Using a local webserver is possible, but not straight-forward:
  • it is usually easier to run on a desktop compared to mobile.
  • it requires some basic knowledge, and interaction with the computer (my grandmother can't do it).

I recently discovered that the epub format supports html5+javascript+css which theoretically means (if I understand correctly) that the ebook/epub platform can be used to run typical web code without a web server.

So I wrapped my html5+javascript+css code into a file in epub format, and was pleasantly surprised that Calibre on desktop (Ubuntu 20.04) opened the ebook and "read" my code properly.
I'm placing "read" in quotation marks because this is not a typical book with mostly text, but some javascript that displays images.

Because I want to read the ebook in mobile, I followed the path to use the Calibre Content Server.
I started with Calibre Content Server on the desktop (by using e.g. http://localhost:8080),
and also tested with Calibre Content Server on mobile (by using e.g. http://192.168.1.75:8080)

According to the the documentation Calibre Content Server is expected to work similar to Calibre, but I did find that I had to make some adjustments.
Here are 2 examples:

Example1 - seeing a button icon image
I have a button with an icon.
In regular (non-ebook) web code, the icon image is fetched from the webserver via e.g. http://localhost/static/img1.png
But for the Calibre Content Server, I need to provide the image via data URI, which reduces the flexibility of the code.

Example2 - interaction with a button
When the ebook is viewed by Calibre, the button responds properly, i.e. clicking on a button opens a input file dialog.
This also works in Calibre Content Server on the desktop.
But when using Calibre Content Server on the mobile, the buttons do not respond.

I assume that the differences in behaviour are because Calibre Content Server uses the web browser (e.g. Chrome) and the lack of a webserver,
which adds restrictions such as:
  • cannot make a GET request (Calibre, or Calibre Content Server does not provide static assets, such as the button icon image?)
  • CORS requests (preventing from doing GET requests)
  • other security restrictions (which could be what causes the button interaction problems)

So I have a general question: is it possible to implement Calibre as a mobile app?
I'm sure this can be a big task. I looked at the calibre code and it's huge. I also see the span of the project in years, and the amount of ongoing activity (commits, releases, etc...)
My question is more about the technical limit.
I basically want to understand what are the limits of ebook/epub to execute html5+javascript+css offline, without many limitations (assuming that requests to external resources are eliminated).

Thank you
Avner
avnermoshkovitz is offline   Reply With Quote