-
Notifications
You must be signed in to change notification settings - Fork 7
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 && ./run.sh
- When Lenny is
composed
, it creates 5 containers:-
api
The main application container that runsnginx
and a FastAPI app for doing all the Lenny stuff with Lenny items -
db
a postgres server that is used to store metadata about items in Lenny -
s3
a MinIO s3 server for storing the actual book files for an item -
readium
a service on:15080
that takes base64 encoded filepaths to books and generatesmanifest.json
for the book that can be used by Thorium Web -
reader
is a container that runs thethorium-web
as a stand-alone web application on:3000
When you start up Lenny, you have an option topreload
500+ 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/upload
to put them ins3
a. 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!