readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
549 stars 186 forks source link

Save and track reading progress #726

Open rayssafs opened 4 years ago

rayssafs commented 4 years ago

Hello, I would like to know if there is a way to save and track the reading progress, without saving this information in local storage/ browser. For example, if the users use the reading channel in different devices, they should be able to start on the same page they stop the reading.

danielweck commented 4 years ago

The functionality you are describing is currently not implemented, but you can of course replace the LocalStorage code with an alternative method. There is currently no "extensibility" API to introduce such feature, so you would have to modify the existing code.

From the top of my head, I would suggest looking into the savePlace() function: https://github.com/readium/readium-js-viewer/blob/a9f48eb30da5ef5fea5c5261067caefa5517ec9b/src/js/EpubReader.js#L758-L791

...more specifically reader.bookmarkCurrentPage() and Settings.put() which you could use as a hook / extension point for your distributed / remote storage facility:

https://github.com/readium/readium-js-viewer/blob/a9f48eb30da5ef5fea5c5261067caefa5517ec9b/src/js/EpubReader.js#L760-L763

https://github.com/readium/readium-js-viewer/blob/4ab8dab28e7ae0a74f2b1716ea09d90f7cf399a4/src/js/storage/Settings.js#L23-L36

I hope this helps.