readium / r2-streamer-kotlin

BSD 3-Clause "New" or "Revised" License
17 stars 38 forks source link

Absolute URLs in manifest? #23

Closed johanpoirier closed 5 years ago

johanpoirier commented 6 years ago

When I open a book with the streamer, I got the manifest.json:

{
  "metadata": {
    "languages": [
      "fr"
    ],
    "publicationDate": "2013-10-24",
    "identifier": "9782864YYYXXX",
    "modified": "Fri Apr 17 15:42:42 GMT+02:00 2015",
    "title": "Some book",
    "rendition": {
      "layout": "Reflowable"
    },
    "rights": " ",
    "authors": [
      {
        "name": "Some author",
        "roles": [
          "aut"
        ]
      }
    ],
    "publishers": [
      {
        "name": "Some publisher"
      }
    ]
  },
  "links": [
    {
      "type": "application/webpub+json",
      "href": "http://localhost:48792/somebook.epub/manifest.json",
      "rel": [
        "self"
      ],
      "properties": "org.readium.r2.shared.Properties@88c372a"
    }
  ],
  "spine": [
    {
      "type": "application/xhtml+xml",
      "href": "/EPUB/Content/cover.xhtml",
      "properties": "org.readium.r2.shared.Properties@fe791b"
    },
    {
      "type": "application/xhtml+xml",
      "href": "/EPUB/Content/pb.xhtml",
      "properties": "org.readium.r2.shared.Properties@b21fab8"
    },
    {
      "type": "application/xhtml+xml",
      "href": "/EPUB/Content/9782864973072-0.xhtml",
      "properties": "org.readium.r2.shared.Properties@a2c0091"
    },
    {
      "type": "application/xhtml+xml",
      "href": "/EPUB/Content/9782864973072-1.xhtml",
      "properties": "org.readium.r2.shared.Properties@e0e9bf6"
    }
  ],
  "resources": [
    {
      "title": "nav",
      "type": "application/xhtml+xml",
      "href": "/EPUB/Navigation/nav.xhtml",
      "rel": [
        "contents"
      ],
      "properties": "org.readium.r2.shared.Properties@ab8f093"
    },
    {
      "title": "css",
      "type": "text/css",
      "href": "/EPUB/Style/style.css",
      "properties": "org.readium.r2.shared.Properties@ebd68d0"
    },
    {
      "title": "cover-image",
      "type": "image/jpeg",
      "href": "/EPUB/Image/cover.jpg",
      "rel": [
        "cover"
      ],
      "properties": "org.readium.r2.shared.Properties@d7530c9"
    },
    {
      "title": "image-0",
      "type": "image/jpeg",
      "href": "/EPUB/Image/9782864973072-0.jpg",
      "properties": "org.readium.r2.shared.Properties@43933ce"
    }
  ]
}

I have two questions about it:

HadrienGardeur commented 6 years ago

Why the href is absolute? in the example from Hadrien Gardeur, all the resources and spines have relative URLs (and it causes some issues in third-parties navigators).

I only see one href with an absolute URI in this example, the other ones are all using relative ones.

From a spec perspective, both are allowed but an absolute URI is usually preferred by clients to make their job easier.

Why do we have some sort of pointer in the properties attribute?

I don't know but this wouldn't validate against our schema.

There are also multiple other issues with that example:

johanpoirier commented 6 years ago

I only see one href with an absolute URI in this example, the other ones are all using relative ones.

Maybe I wasn't specific. href like /EPUB/Image/cover.jpg is resolved as http://localhost:48792/EPUB/Image/cover.jpg, which leads to a 404 on the streamer server.

And href like EPUB/Image/cover.jpg is resolved as http://localhost:48792/somebook.epub/EPUB/Image/cover.jpg, which is correct.

Why do we have some sort of pointer in the properties attribute?

I found a bug in the r2-shared-kotlin project.

There are also multiple other issues with that example

I can't see any tests on the project. Why? I thought that on fresh projects from Readium 2, tests were mandatory.

HadrienGardeur commented 6 years ago

It's worth pointing out that all current implementations based on the Swift/Kotlin streamers actually use the in-memory object rather than the JSON manifest.

That said, it's definitely part of the design philosophy of Readium-2 to support both, but this might explains why things are a little sparse/broken on the JSON side.

aferditamuriqi commented 5 years ago

This has been addressed and resolved, I'll move it to in review, to make sure to double check