-
Notifications
You must be signed in to change notification settings - Fork 9
Home
I wanted to provide an update/overview about the current status of the Lenny Library-in-a-Box project as it's becoming pretty turn-key!
code: https://github.com/archivelabs/lenny
If you have docker and git then installation is pretty easy:
git clone [email protected]:ArchiveLabs/lenny.git && cd lenny && make all
- When Lenny is
composed, it creates 5 containers:-
apiThe main application container that runsnginxand a FastAPI app for doing all the Lenny stuff with Lenny items -
dba postgres server that is used to store metadata about items in Lenny -
s3a MinIO s3 server for storing the actual book files for an item -
readiuma service on:15080that takes base64 encoded filepaths to books and generatesmanifest.jsonfor the book that can be used by Thorium Web -
readeris a container that runs thethorium-webas a stand-alone web application on:3000When you start up Lenny, you have an option topreload500+ books...
-
docker exec -it lenny_api python scripts/load_open_books.py
- Asks http://OpenLibrary.org/search.json|OpenLibrary.org/search.json for info about every standardebook it knows
- The script loops over these records, downloads the corresponding epubs, and uses the Lenny
api's/uploadto put them ins3a. The book's path in s3 is the bucketbookshelf/+ the book'sopenlibrary_edition_id(as an int) + the filetype: i. e.g.32941311.epub
Now we want to read one of our books! To read one of these books, we will use Thorium Web (i.e. our reader service). But Thorium Web only knows how to speak in "manifests" which need to be generated: This is the sole job of readium.
Once our items are uploaded to, Lenny's readium service is preconfigured w/ s3 so out-of-the-box it can generate manifests for any of its book. To do so, you need to query readium to produce a manifest.json file for a specified base64 encoded version of a full s3 filepath:
- e.g.
<http://localhost:15080/{base64(filepath)}/manifest.json>where...- the book's full s3 filepath is
<s3://bookshelf/32941311.epub> - its
base64(filepath)can be computed using:-
echo -n "<s3://bookshelf/32941311.epub>" | base64 | tr '/+' '_-' | tr -d '='→czM6Ly9ib29rc2hlbGYvMzI5NDEzMTEuZXB1Yg◦ resulting in http://localhost:15080/czM6Ly9ib29rc2hlbGYvMzI5NDEzMTEuZXB1Yg/manifest.json Finally, you can navigate tohttp:localhost:3000/read?book={readium_manifest_url}to read the book :wash-your-hands:
-
- the book's full s3 filepath is
- e.g.
<http:localhost:3000/read?book=http://localhost:15080/czM6Ly9ib29rc2hlbGYvMzI5NDEzMTEuZXB1Yg/manifest.json>
And there you have it!