ArchiveLabs / pragma.archivelab.org

An API for citing Wayback snapshots with OpenAnnotations
https://pragma.archivelab.org
GNU General Public License v3.0
22 stars 3 forks source link

Support Web Annotation #3

Open csarven opened 6 years ago

csarven commented 6 years ago

Currently OpenAnnotation is supported but we now have W3C Web Annotation recommendations. Can we bumb this a bit?

I've tested with https://dokie.li/ . See https://github.com/linkeddata/dokieli/commit/725a54882da5e5ea943a41d938ef36b4ed94e389 . Happy to experiment with Web Annotation.

mekarpeles commented 6 years ago

@csarven -- sure, technically any type of annotation can be POSTed to the server, so the json is fairly arbitrary (whether it's an OpenAnnotation or W3C Web Annotation).

Is the call of action to change the copy? Which in the code-base should change to support your use case?

e.g. renaming OpenAnnotation to WebAnnotation in: https://github.com/ArchiveLabs/pragma.archivelab.org/blob/master/pragma/api/pragmas.py https://github.com/ArchiveLabs/pragma.archivelab.org/blob/master/pragma/views/endpoints.py

csarven commented 6 years ago

In my implementation, I have a payload like this:

{
  "url":"http://csarven.ca/",
  "annotation":{
    "@context":"http://www.w3.org/ns/anno.jsonld",
    "@type":"Annotation",
    "motivation":"linking",
    "target":"http://csarven.ca/",
    "rights":"https://creativecommons.org/publicdomain/zero/1.0/",
    "creator":{
      "@id":"http://csarven.ca/#i",
      "http://schema.org/name":"Sarven Capadisli",
      "http://schema.org/image":"http://csarven.ca/media/images/sarven-capadisli.jpg",
      "http://schema.org/url":"http://csarven.ca/"
    }
  }
}

and that creates an annotation like https://pragma.archivelab.org/annotations/131 which pretty close to it:

{
  "annotation": {
    "@context": "http://www.w3.org/ns/anno.jsonld",
    "@type": "Annotation",
    "annotatedAt": "Thu Jul 27 10:20:00 2017",
    "creator": {
      "@id": "http://csarven.ca/#i",
      "http://schema.org/image": "http://csarven.ca/media/images/sarven-capadisli.jpg",
      "http://schema.org/name": "Sarven Capadisli",
      "http://schema.org/url": "http://csarven.ca/"
    },
    "hasTarget": {
      "hasSource": {
        "@id": "http://web.archive.org/web/20170727101959/http://csarven.ca/",
        "originalUrl": "http://csarven.ca/"
      }
    },
    "motivation": "linking",
    "rights": "https://creativecommons.org/publicdomain/zero/1.0/",
    "target": "http://csarven.ca/"
  },
  "canvas_id": null,
  "id": 132
}

For this to work out of the box for Web Annotation / JSON-LD consumption, the root object should be the contents of annotation. There is no particular need for annotation, canvas_id (pardon me as I don't know what this is for :)).

I think it should come out as:

{
  "@context": "http://www.w3.org/ns/anno.jsonld",
  "@id": "https://pragma.archivelab.org/annotations/132",
  "@type": "Annotation",
  "created": "2017-07-27T10:20:00Z",
  "creator": {
    "@id": "http://csarven.ca/#i",
    "http://schema.org/image": "http://csarven.ca/media/images/sarven-capadisli.jpg",
    "http://schema.org/name": "Sarven Capadisli",
    "http://schema.org/url": "http://csarven.ca/"
  },
  "target": "http://csarven.ca/",
  "body": "http://web.archive.org/web/20170727101959/http://csarven.ca/",
  "motivation": "linking",
  "rights": "https://creativecommons.org/publicdomain/zero/1.0/"
}

Web Annotation Protocol requires this header: Content-Type: application/ld+json;profile="http://www.w3.org/ns/anno.jsonld" but in my implementation, I sent application/json because that's what the server appears to require. The server should respond with that header for the annotation URL request.