baker icon indicating copy to clipboard operation
baker copied to clipboard

Native protocol for HPub books

Open folletto opened this issue 16 years ago • 22 comments

As an author I want to be able to link my book and refer to it uniquely As a user I want to open directly a book and a specific chapter by clicking on a link

This is another piece of the foundation for HPub, a way to hyperlink inside the book itself and allow to uniquely identify books.

The protocol could be: book://example.com/bookname.hpub/filename.html#marker

This would allow both the download of a book from: http://example.com/bookname.hpub

And the reference inside a specific part of the book.

Note that:

  • The identifier is the whole URI, so it's unique (book://example.com/bookname.hpub).
  • It's distributed, no need of a central authority, uses what's already in place for the web.
  • It identifies also a file type, so it's not limited to hpub
  • The resource is downloadable.
  • If DRM or authentication is required, it can be handled on different levels (server, client, payment).

folletto avatar Nov 07 '10 23:11 folletto

Thanks to Joseph Pearson for the link to this proposal by Keith Fahlgren: http://blog.threepress.org/2010/10/21/developing-an-epub-linking-spec/

Very similar concept, a discussion will be interesting, because I was more focused on using the internet protocols to identify and locate books, using the URL as both an unique identifiers and download path location. (Note also that if the path location goes down, the URI will still be a unique identifier for that book, exactly like the EPub link specification).

I still have to read in depth the proposal and the comments, but I think that we could start from that proposal and add the downloadable bit.

folletto avatar Nov 15 '10 23:11 folletto

I've started working on handling url opening in the framework.

The first version of the handler will recognize url like book://example.com/bookname.hpub and download the relative .hpub file.

Add parameters handling after that shouldn't be a problem :)

Xm4s avatar Nov 21 '10 01:11 Xm4s

I've commited the first step in url handling, the others will follow as soon as possible :)

Xm4s avatar Nov 21 '10 10:11 Xm4s

As already discussed offline, the other advantage of an URI like this would be that it allows for a openID like scheme for authenticating books contents.

bru avatar Nov 24 '10 23:11 bru

Question: any idea on how we could check if a book has been updated, without downloading it and checking the content?

folletto avatar Nov 26 '10 15:11 folletto

md5?

bru avatar Nov 26 '10 18:11 bru

That would require that the author is able to evaluate the md5 or that the server auto-evaluates it, a trouble in both cases. But it might be the only way, so... the main question is: where is it stored? ;)

folletto avatar Nov 26 '10 18:11 folletto

if we use a metadata file (xml-json), we could evaluate all versions and compare with the server so we can know what the latest version for download. After downloading the book_XXX.zip, when unzip it could override the metadata file with a new and updated that we have inside the zip.

segundoseis avatar Nov 27 '10 11:11 segundoseis

Uhm yes, but I'd like a way to avoid downloading the book for checking. You know, downloading a 35Mb photo book just to see that the version hasn't changed isn't really good. :D

folletto avatar Dec 02 '10 17:12 folletto

I think that I did not explained very well .. My English is not very good, sorry: (

  • Web server:

1 - Last updated version.json/xml file, with historical versions. (name / uri / date / version comments / ¿?) 2 - book_versionXXX.zip file

  • Mobile application (ipad / iphone)

In the directory, we have with the rest of html the toc.json/xml and within it a attribute with the current version number.

To upgrade, you only have to consult the archive version.json/xml from the server and check if there are a newer version than version attribute from toc.json/xml. If so, download the lastest zip. :)

segundoseis avatar Dec 02 '10 18:12 segundoseis

Let me see if I got it correctly. For this book book://example.com/bookname.hpub the server has:

  • http://example.com/bookname.hpub
  • http://example.com/bookname.json

The json file is then downloaded and the version is then matched with the version the mobile application has. If it has been updated, then it downloads the hpub file.

I'd add: the json file is just the same manifest file inside the hpub, so the server could automatically serve that (extracting it from the hpub) or without a specific server you just have to replace the json file (so, we don't have to make another configuration file).

Sounds good. :)

folletto avatar Dec 02 '10 18:12 folletto

I think it's better to have two files.

If we use the same toc.json to check versions, we should have a version history inside :( Other thing... if we have many pages / content in the same toc archive, the file may become heavy.

I think the toc only have to contain the current version.

On the server, we have a file (versions.json) that contains only a history of upgrades and allow me to check and download the latest version.

server: http://example.com/bookname_versionXXX.hpub (internally contains the toc.json with which we can check future upgrades)

http://example.com/versions_bookname.json (just to check for updates)

segundoseis avatar Dec 02 '10 19:12 segundoseis

At this moment of the discussion, toc.json and manifest.json are two different files, so there's no problem. :)

Consider also that since it's an identifier the book version shouldn't change, unless minor fixes, so I'm against having "http://example.com/bookname_versionXXX.hpub", because it means that updating the book will change the URI completely. :)

And of course, if the author publishes a new edition, it's going to have a whole different URL due to the - possible - structural changes (like "Second Edition" books).

A way to handle versions easily without breaking the URL is for me this one, where the first one always gets the latest version (similar to the Ruby Gems model):

  1. book://example.com/bookname.hpub
  2. http://example.com/bookname.hpub?version=4
  3. http://example.com/bookname.json?version=4

folletto avatar Dec 02 '10 19:12 folletto

I like your solution .. I thought that we could get the URI from the version.json, but is probably best to change it as you say. :)

segundoseis avatar Dec 02 '10 19:12 segundoseis

@folletto: that would require some sort of server logic. Which is ok, but wasn't explicitly declared so far. I think we should start form defining the minimum system requirements: in case the author doesn't have the knowledge or the means to put logic on his website, shall he be forbidden to publish books, or do we want to define a fallback protocol? In case of the latter, having the version in the filename for the book archive (the hpub file) probably offers more flexibility, as we could implement this flow:

  1. client checks http://example.com/bookname.json
  2. founds from the json that the latest version is XXX
  3. client decides whether to retrieve the book from http://example.com/bookname.XXX.hpub

In this scenario, the client never goes straight to the archive, but always checks the manifest file first.

OR, now that I think about it, we could re-use a well tested wheel here and do what software ftp services have been doing for ages: symlinking the book endpoint to the latest version: bookname.hpub -> bookname.XXX.hpub

obviously, if the user can afford to have logic on his distribution server, we can do more interesting stuff, still following the simple protocol described above, like honouring the "?version=XYZ" convention.

bru avatar Dec 03 '10 12:12 bru

I don't think that the usage for previous versions is so high to require creating an overly complex solution. However, we could also do that:

  • book://example.org/bookname.hpub # book identifier
  • http://example.org/bookname.json # retrieves the manifest of the latest version (and the version itself)
  • http://example.org/bookname.hpub # retrieves the latest version (as in the URI)
  • http://example.org/bookname.5.hpub # allows to retrieve a specific version

This solution is completely equivalent to the version based one, with the improvement that would work also on "non dedicated" servers (Apache) at the cost of a slightly semantic incorrectness (the version number inside the file name).

It probably also fits with segundoseis proposal above. :)

Could work. :)

folletto avatar Dec 03 '10 12:12 folletto

Btw, the "book identifier" could be also file-type agnostic:

  • book://example.org/bookname

So it's the reader then that checks the file it wants to use:

  • book://example.org/bookname.hpub
  • book://example.org/bookname.epub
  • book://example.org/bookname.zhook
  • book://example.org/bookname.txt

folletto avatar Dec 03 '10 12:12 folletto

The first implementation of the protocol landed on GitHub master.

Now Baker supports internal book:// URLs, downloading books.

So for example, if you create a link in your book like:

  • <a href="book://example.org/path/newbook">Open book</a>

It will download this file:

  • http://example.org/path/newbook.hpub

folletto avatar Jan 14 '11 00:01 folletto

Just committed support for addressing a specific page in the url, now:

  • book://example.org/path/newbook/chapter 10.html

will download http://example.org/path/newbook.hpub and open it at page "chapter 10.html" (if found, otherwise it starts from the first page)

It's the same for the url book://example.org/path/newbook.hpub/chapter 10.html

Xm4s avatar Feb 22 '11 09:02 Xm4s

Ok, it works. :) I'd say that this kind of support is a great first version of the protocol, so I close this issue. :)

folletto avatar Feb 28 '11 23:02 folletto