readium / readium-js-viewer

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

Does the CFI and URL Always Need to be in the Querystring? #714

Closed coler-j closed 5 years ago

coler-j commented 5 years ago

This issue is a Question

Question: I am used to the world of Django where most URLs look well formed and not 'ugly'. The inclusion of the CFI in the address bar looks like a bunch of nonsense and is not 'pretty'. As well as the URL parameter of the ebook that is loaded.

Is there anyway to not add the parameters as querystring arguments? (If I have the ability to pass the URL via server side HTML rendering) ...

And why can't the CFI be kept in a cookie instead of the querystring?

Expected Behaviour

No expected behavior.

Observed behaviour

Readium-js-view adds the epub CFI in the address bar as a querystring

Steps to reproduce

  1. View a compress epub file in the readium-js-viewer
  2. View the address bar and it will have the CFI as a querystring, for example: https://someurl.com/reader/?...&goto=epubcfi(/6/16!/4/2%5Bintroduction%5D/2/1:0)

Product

danielweck commented 5 years ago

You are right, the web/cloud reader URLs are "heavy" (query params: epub to reference the publication, goto to reference a location within the publication, and optionally epubs to reference the originating content library / OPDS feed). The percent-encoded goto JSON + CFI syntax is indeed downright ugly.

On the plus side, users can copy/paste links from the address bar to exchange direct deep publication links.

For reference, here is the code where window.history.replaceState() is used to preserve the current goto CFI each time the user accesses a different location within the publication ("page turn", or table of content linking):

https://github.com/readium/readium-js-viewer/blob/521b8e8f30af24e34cdb46fd6808c6cb46542942/src/js/EpubReader.js#L765-L790

Also see this central piece of code where the URL query params are used to "transport" state for the library and reader views: https://github.com/readium/readium-js-viewer/blob/develop/src/js/ReadiumViewer.js