This report is important because basis are now lined up and the process of building the application can start.

“LAST” TOUCH TO THE URI SCHEME

As the previous report said URI schemes are promising, now I can confirm that statement. The whole idea about URI schemes is pretty simple. By registering one I’m able to load epub.js library which renders the content of the .ePub eBook by loading local files such as html, css, images, etc. Using URI scheme I have successfully overcome the cross origin issue. A small problem which was described in the previous post was actually solved by defining the correct path of the eBook. A relative path to the unpacked eBook is given to epub.js, which builds the absolute path. It does that simply by getting current location of the document. Having this information all the relative links within the book are detected and replaced with the absolute path. This way the requests are made with the registered URI scheme. This should also be used for loading .epub file, as epub.js supports unpacking.

APPLICATION STRUCTURE

The overall look over the application structure will be explain, but further improvements and details will be given later on as this is still in the working state.

Application GNOME Books is going to have a WebKit view, subclass that loads epub.js. This class needs to expose “controller” object with the methods to control the interaction. The methods are used for loading an eBook file, controlling the reading mode (next page, previous page, pagination, etc). The WebKit view would then call JS functions to execute methods.

INTERACTION EPUB.JS <-> WEBKIT

To manage the interaction between epub.js and WebKit view I have started by asynchronously running a script in the context of the current page. To be able to run scripts WebKitWebSettings:enable-javascript has to be set to TRUE. As an example a method for loading .epub book is shown in the code below.

static void
load_book ()
{
  gchar* load_command = "var Book = ePub('/epub.js/reader/the-lifestone/', { width: 400, height: 600, spreads : false });";
  webkit_web_view_run_javascript (WEBKIT_WEB_VIEW(webView), load_command, NULL, NULL, NULL);
}

NEXT STEPS

  • Build the “controller” – used for the interaction with application
  • Application structure
Advertisements