Lessons from writing the Ebook Library for the Kindle eReader

Chased-by-Penguins-Juggling-Queries-at-Angle

The first iteration PHP version of the eBook Library has been a life saver when it comes to displaying what I own in a very simple way and getting stuff onto the Kindle eReader. The limitation of the library app, server side sorting and very crude design have actually been an advantage when using it on the Kindle.

Kindle Experimental Browser

JavaScript on the Kindle experimental browser is limited to say the least. If you browse to the ES6 compatibility at https://kangax.github.io/compat-table/es6/ it shows that writing webapps in ES6 is a bit of a wishful thinking. The Kindle Voyage model is a bit better in this regard. ES5 is mostly available, but running an Angular App can prove problematic. The app doesn't initialise properly leaving you with an empty page. I tried coming down from Angular 4 to 2 to Angular 1.6, crossing my fingers every time and getting unsatisfactory results. The answer to the question: "Can I write an Angular app for the kindle?" is unfortunately: No. Don't do it..

Here's a good article stating what is available on the Kindle browser:
https://gomakethings.com/building-websites-that-work-on-an-e-ink-kindle/

Back to PHP and vanilla HTML?

What framework could I use to get some kind of a UI without rewriting everything it in pure CSS/JS?
jQuery Mobile!

jQuery Mobile is a bit of an old-school approach that works on old browsers. It provides us with a set of basic controls that can be used to build quite nice looking UIs without having to write them from scratch. It also gives us buttons, navbars, a few jQuery animations, a standard loader and single page routing capabilities with which you can create single page apps. It's not the fastest in the world, but it makes up for it with fancy flashes when changing pages. It utilises the HTML viewport using the full width of the app and is mainly built for smaller screens. You can see a prototype example I built for the newest iteration (v4) of the eBook Library.

ebook-library-jquery-mobile-prototype

There are two reasons I wanted to rewrite it in the first place:

  1. Letting go of having a separate PHP server running on a separate VM. Instead running it as a Node.JS app.
  2. Book Data was not always showing the right stuff. And most of the time, some Polish books didn't have cover thumbnails, which is quite annoying since a lot of them are falling into this category.

Work in progress improvements to the current setup:

  • Getting rid of sorting on the back end and put it into a front end JavaScript.
  • Handing file uploads to remove the FTP client out of the equation.
  • Storing the data in a local SQLite database to remove the constant calling of the Google Books API. Sometimes the list I got is missing some books ISBN numbers that were put in the request. Not sure why this is the case, but it varies with every refresh.