-
Notifications
You must be signed in to change notification settings - Fork 32
How does it work ?
This documentation will give a quick overview of how the reader works on specific topics.
First, we'll see what technologies are used. Then, we will see more details about specific topics:
The application is developped mainly with Ruby and CoffeeScript. Those are (some of) the technologies/librairies used:
- Mongodb: NoSQL database
- Monocle: browser-based ebook JavaScript library
- Resque: Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later
- Backbone: JavaScript library for building heavy applications
- Sprockets: Ruby library for compiling and serving web assets
- Sass and Compass: CSS extension and framework
- Haml
- Mustache
- Font-Awesome Icons
Depending on which part of the application you will want to work on, minimum knowledge on those techs could be useful.
Resque is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later. Teabook Open Reader uses Resque for long jobs such as:
- importing an ebook
- downloading an ebook
- converting an ebook
- ...
Resque also comes with a front-end for seeing what's up in queues. To access it, see http://<app>/resque/overview
.
The TeabookOpenReader reader uses 4 differents types of chained background jobs.
- Create
Ebook
objects from API datas - Save object
- Enqueue ebook to
DownloadEbookWorker
worker
- Download ebook to
/tmp/<ebook_id>.epub
- Change ebook status to
uploaded
- Enqueue ebook to
ExtractEpubWorker
worker
- Extract cover from ebook
- Extract metadatas from ebook (authors, publisher, language, description)
- Enqueue ebook to
EpubToHTMLWorker
worker
- Unzip ebook
- Copy files into
db/epub
- Change ebook status to
converted
Teabook Open Reader uses differents offline storage system, depending on usage and the used device.
Application Cache is used on all devices to store the minimal assets needed to display pages. Concerned files are listed in the Application Cache Manifest. This file is available at manifests/reader.appcache
.
For a better use of cache, the file isn't loaded on every pages of the application (but only when needed) via the Javascript object App.Misc.AppcacheLoader: it loads an iframe containing the file referencing the manifest. This file is available at manifests/loader
.
Assets are reloaded and cached again every times the manifest changes. The file contains some commented lines for this purpose:
- The
user
id, to allow different users to share the same browser without sharing the same ebook list - The
version
number, to expire the cache when some file content changes
Example:
CACHE MANIFEST
# Version 1340279920
# User 4fd8a24e93a71e22a1000002
CACHE:
/assets/application.js
/assets/application.css
/assets/reader.js
/assets/reader.css
/offline/ebook/epubs
/offline/ebook/epub
/assets/ajax-loader.gif
/uploads/ebook/epub/cover/4fe1d77f93a71e3024000001/reading_Bernard-Werber-Les-Fourmis.jpg
/uploads/ebook/epub/cover/4fe1d77f93a71e3024000001/library_Bernard-Werber-Les-Fourmis.jpg
/uploads/ebook/epub/cover/4fe1d77f93a71e3024000001/detail_Bernard-Werber-Les-Fourmis.jpg
FALLBACK:
/ebook/epub /offline/ebook/epub
/ebook/epubs /offline/ebook/epubs
NETWORK:
*
http://*
The CACHE
section contains every file that need to be cached for offline use:
- Javascript files
- CSS files
- Offline bookstore page
- Offline user page
- Ebook covers
Teabook Open Reader uses WebSQL — when the browser supports it — to store ebooks data. Default storage is 50Mo.
Following browsers support WebSQL:
- Google Chrome >= 4.0
- Safari Desktop >= 3.1
- iOS Safari >= 3.2
- Opera >= 10.5
- Opera Mobile >= 11.0
- Android Browser >= 2.1
IndexedDB is used as a fallback to WebSQL to store ebooks data. Default storage is 50Mo.
Following browsers support IndexedDB:
- Google Chrome >= 11.0 (but WebSQL is prefered)
- Firefox Desktop >= 4.0
- Firefox Mobile >= 6.0
- Internet Explorer >= 10.0