triannon 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +48 -40
- data/app/controllers/triannon/annotations_controller.rb +9 -8
- data/app/services/triannon/ldp_writer.rb +4 -0
- data/lib/triannon/graph.rb +4 -3
- data/lib/triannon/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfed3de76ceff6faec0e84730e6d0e66177c0e2c
|
4
|
+
data.tar.gz: 08d53c74dc0facd2974a95640101e971eadcf0df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0d4eb37e3692bdf5b25b94bf931fe581ed3653cc1d417a0e74aeedbf33f92c2cdd3ae4b548db8a4f03fe0c5b2d5fe025c7c094bf922e09c892bc40877b67f97
|
7
|
+
data.tar.gz: 0910a11f4e22e70d90a14538918a7f73f142d7adc6fb7cde4f1e3f50a4f1e39dc24c5caac307089d4620d54d0d7c0d7b13d393e1ca7c964b48e3116504b91172
|
data/README.md
CHANGED
@@ -12,9 +12,9 @@ Run tests:
|
|
12
12
|
$ rake
|
13
13
|
```
|
14
14
|
|
15
|
-
## Installation
|
15
|
+
## Installation into Rails app
|
16
16
|
|
17
|
-
Add this line to your gemfile
|
17
|
+
Add this line to your Rails app gemfile
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
gem 'triannon'
|
@@ -38,69 +38,68 @@ Edit the `config/triannon.yml` file:
|
|
38
38
|
* `solr_url:` Points to the baseurl of Solr instance configured for Triannon
|
39
39
|
* `triannon_base_url:` Used as the base url for all annotations hosted by your Triannon server. Identifiers from the LDP server will be appended to this base-url. Generally something like "https://your-triannon-rails-box/annotations", as "/annotations" is added to the path by the Triannon gem
|
40
40
|
|
41
|
-
Generate the root annotations container on
|
41
|
+
Generate the root annotations container on your LDP server
|
42
42
|
|
43
43
|
```console
|
44
44
|
$ rake triannon:create_root_container
|
45
45
|
```
|
46
46
|
|
47
|
-
|
47
|
+
## Client Interactions with Triannon
|
48
48
|
|
49
49
|
### Get a list of annos
|
50
50
|
NOTE: implementation of Annotation Lists is coming!
|
51
|
-
GET
|
52
|
-
GET
|
51
|
+
* `GET`: `http://(host)/`
|
52
|
+
* `GET`: `http://(host)/annotations`
|
53
53
|
|
54
54
|
### Get a particular anno
|
55
|
-
GET
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
`GET`: `http://(host)/annotations/(anno_id)`
|
56
|
+
|
57
|
+
* use HTTP `Accept` header with mime type to indicate desired format
|
58
|
+
* default: jsonld
|
59
|
+
* indicate desired context url in the HTTP Accept header thus:
|
60
|
+
* `Accept`: `application/ld+json; profile="http://www.w3.org/ns/oa-context-20130208.json"`
|
61
|
+
* `Accept`: `application/ld+json; profile="http://iiif.io/api/presentation/2/context.json"`
|
62
|
+
* also supports turtle, rdfxml, json, html
|
63
|
+
* indicated desired context url for jsonld as json in the HTTP Link header thus:
|
64
|
+
* `Accept`: `application/json`
|
65
|
+
* `Link`: `http://www.w3.org/ns/oa.json; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"`
|
66
|
+
* note that the "type" part is optional and refers to the type of the rel, which is the reference for all json-ld contexts.
|
67
|
+
* see https://github.com/sul-dlss/triannon/blob/master/app/controllers/triannon/annotations_controller.rb #show method for mime formats accepted
|
68
68
|
|
69
69
|
#### JSON-LD context
|
70
70
|
You can request IIIF or OA context for jsonld.
|
71
71
|
|
72
72
|
The correct way:
|
73
|
-
|
74
|
-
*
|
75
|
-
|
76
|
-
** Accept: application/ld+json; profile="http://iiif.io/api/presentation/2/context.json"
|
73
|
+
* use HTTP `Accept` header with mime type and context url:
|
74
|
+
* `Accept`: `application/ld+json; profile="http://www.w3.org/ns/oa-context-20130208.json"`
|
75
|
+
* `Accept`: `application/ld+json; profile="http://iiif.io/api/presentation/2/context.json"`
|
77
76
|
|
78
77
|
You can also use either of these methods (with the correct HTTP Accept header):
|
79
78
|
|
80
|
-
GET
|
81
|
-
GET
|
79
|
+
* `GET`: `http://(host)/annotations/iiif/(anno_id)`
|
80
|
+
* `GET`: `http://(host)/annotations/(anno_id)?jsonld_context=iiif`
|
82
81
|
|
83
|
-
GET
|
84
|
-
GET
|
82
|
+
* `GET`:` http://(host)/annotations/oa/(anno_id)`
|
83
|
+
* `GET`: `http://(host)/annotations/(anno_id)?jsonld_context=oa`
|
85
84
|
|
86
85
|
Note that OA (Open Annotation) is the default context if none is specified.
|
87
86
|
|
88
87
|
### Create an anno
|
89
|
-
POST
|
88
|
+
`POST`: `http://(host)/annotations`
|
90
89
|
* the body of the HTTP request should contain the annotation, as jsonld, turtle, or rdfxml
|
91
|
-
* the Content-Type header should be the mime type matching the body
|
90
|
+
* the `Content-Type` header should be the mime type matching the body
|
92
91
|
* the anno to be created should NOT already have an assigned @id
|
93
|
-
* to get a particular format back, use the HTTP Accept header
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
92
|
+
* to get a particular format back, use the HTTP `Accept` header
|
93
|
+
* to get a particular context for jsonld, do one of the following:
|
94
|
+
* `Accept`: `application/ld+json; profile="http://www.w3.org/ns/oa-context-20130208.json"`
|
95
|
+
* `Accept`: `application/ld+json; profile="http://iiif.io/api/presentation/2/context.json"`
|
96
|
+
* to get a particular jsonld context for jsonld as json, specify it in the HTTP Link header thus:
|
97
|
+
* `Accept`: `application/json`
|
98
|
+
* `Link`: `http://www.w3.org/ns/oa.json; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"`
|
99
|
+
* note that the "type" part is optional and refers to the type of the rel, which is the reference for all json-ld contexts.
|
101
100
|
|
102
101
|
### Delete an anno
|
103
|
-
DELETE
|
102
|
+
`DELETE`: `http://(host)/annotations/(anno_id)`
|
104
103
|
|
105
104
|
|
106
105
|
## Running the application in development
|
@@ -124,16 +123,25 @@ rake triannon:solr_jetty_setup
|
|
124
123
|
$ rake engine_cart:generate # (first run only)
|
125
124
|
```
|
126
125
|
|
127
|
-
|
126
|
+
#### Start jetty
|
128
127
|
```console
|
129
|
-
$
|
128
|
+
$ rake jetty:start
|
130
129
|
```
|
131
130
|
|
132
131
|
##### Generate root annotations container
|
133
132
|
```console
|
133
|
+
$ cd spec/internal
|
134
134
|
$ rake triannon:create_root_container
|
135
|
+
$ cd ../..
|
135
136
|
```
|
136
137
|
|
138
|
+
##### Configure spec/internal/config/triannon.yml as specified above
|
139
|
+
You might not need to change the file.
|
140
|
+
```console
|
141
|
+
$ vi spec/internal/config/triannon.yml
|
142
|
+
```
|
143
|
+
|
144
|
+
|
137
145
|
# Run the test app
|
138
146
|
```console
|
139
147
|
$ rake jetty:start
|
@@ -74,34 +74,35 @@ module Triannon
|
|
74
74
|
|
75
75
|
if @annotation.save
|
76
76
|
default_format_jsonld # NOTE: this must be here and not in before_filter or we get Missing template errors
|
77
|
+
flash[:notice] = "Annotation #{@annotation.id} was successfully created."
|
77
78
|
respond_to do |format|
|
78
79
|
format.jsonld {
|
79
80
|
context_url = context_url_from_link ? context_url_from_link : context_url_from_accept
|
80
81
|
if context_url && context_url == Triannon::JsonldContext::IIIF_CONTEXT_URL
|
81
|
-
render :json => @annotation.jsonld_iiif, status: 201, content_type: "application/ld+json"
|
82
|
+
render :json => @annotation.jsonld_iiif, status: 201, content_type: "application/ld+json"
|
82
83
|
else
|
83
|
-
render :json => @annotation.jsonld_oa, status: 201, content_type: "application/ld+json"
|
84
|
+
render :json => @annotation.jsonld_oa, status: 201, content_type: "application/ld+json"
|
84
85
|
end
|
85
86
|
}
|
86
87
|
format.ttl {
|
87
88
|
accept_return_type = mime_type_from_accept(["application/x-turtle", "text/turtle"])
|
88
|
-
render :body => @annotation.graph.to_ttl, status: 201,
|
89
|
+
render :body => @annotation.graph.to_ttl, status: 201, content_type: accept_return_type if accept_return_type }
|
89
90
|
format.rdfxml {
|
90
91
|
accept_return_type = mime_type_from_accept(["application/rdf+xml", "text/rdf+xml", "text/rdf"])
|
91
|
-
render :body => @annotation.graph.to_rdfxml, status: 201,
|
92
|
+
render :body => @annotation.graph.to_rdfxml, status: 201, content_type: accept_return_type if accept_return_type }
|
92
93
|
format.json {
|
93
94
|
accept_return_type = mime_type_from_accept(["application/json", "text/x-json", "application/jsonrequest"])
|
94
95
|
context_url = context_url_from_link ? context_url_from_link : context_url_from_accept
|
95
96
|
if context_url && context_url == Triannon::JsonldContext::IIIF_CONTEXT_URL
|
96
|
-
render :json => @annotation.jsonld_iiif, status: 201,
|
97
|
+
render :json => @annotation.jsonld_iiif, status: 201, content_type: accept_return_type if accept_return_type
|
97
98
|
else
|
98
|
-
render :json => @annotation.jsonld_oa, status: 201,
|
99
|
+
render :json => @annotation.jsonld_oa, status: 201, content_type: accept_return_type if accept_return_type
|
99
100
|
end
|
100
101
|
}
|
101
102
|
format.xml {
|
102
103
|
accept_return_type = mime_type_from_accept(["application/xml", "text/xml", "application/x-xml"])
|
103
|
-
render :body => @annotation.graph.to_rdfxml, status: 201,
|
104
|
-
format.html {
|
104
|
+
render :body => @annotation.graph.to_rdfxml, status: 201, content_type: accept_return_type if accept_return_type }
|
105
|
+
format.html { redirect_to @annotation }
|
105
106
|
end
|
106
107
|
else
|
107
108
|
render :new, status: 400
|
@@ -58,6 +58,10 @@ module Triannon
|
|
58
58
|
raise Triannon::ExternalReferenceError, "Incoming annotations may not have http://triannon.stanford.edu/ns/externalReference as a predicate."
|
59
59
|
end
|
60
60
|
|
61
|
+
if @anno.graph.id_as_url && @anno.graph.id_as_url.size > 0
|
62
|
+
raise Triannon::ExternalReferenceError, "Incoming new annotations may not have an existing id (yet)."
|
63
|
+
end
|
64
|
+
|
61
65
|
# TODO: special case if the Annotation object already has an id --
|
62
66
|
# see https://github.com/sul-dlss/triannon/issues/84
|
63
67
|
|
data/lib/triannon/graph.rb
CHANGED
@@ -94,12 +94,13 @@ module Triannon
|
|
94
94
|
|
95
95
|
# Canned Query methods ----------------------------------------------------------------
|
96
96
|
|
97
|
-
# @return [String] the id of this annotation as a url string
|
97
|
+
# @return [String] the id of this annotation as a url string, or nil if it is a Node
|
98
98
|
def id_as_url
|
99
99
|
solution = @graph.query self.class.anno_query
|
100
100
|
if solution && solution.size == 1
|
101
|
-
solution.first.s
|
102
|
-
|
101
|
+
rdf_resource = solution.first.s
|
102
|
+
rdf_resource.to_s if rdf_resource.is_a?(RDF::URI)
|
103
|
+
# TODO: raise exception if not a URI?
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
data/lib/triannon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triannon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-03-
|
13
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 4.2
|
21
|
+
version: '4.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 4.2
|
28
|
+
version: '4.2'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: linkeddata
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,16 +184,16 @@ dependencies:
|
|
184
184
|
name: engine_cart
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
-
- - "
|
187
|
+
- - ">="
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: '0
|
189
|
+
version: '0'
|
190
190
|
type: :development
|
191
191
|
prerelease: false
|
192
192
|
version_requirements: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- - "
|
194
|
+
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version: '0
|
196
|
+
version: '0'
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
198
|
name: jettywrapper
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|