triannon 0.4.1 → 0.4.2
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/app/models/triannon/annotation.rb +7 -25
- data/lib/triannon.rb +1 -0
- data/lib/triannon/jsonld_context.rb +21 -0
- data/lib/triannon/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5c63fec8ee04d1f247c4804a3227b6b3171bac
|
4
|
+
data.tar.gz: b56c06505be1f81eba22e490c139f526bface06a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a25814d29d28ed25b89b87f994afb2fb61ad308ad2079758d5e25c4ce4cf7c0378c0b53c89b9c60e04045c4febe9a362b1ab7d3a1a2b55b3b527ef3fa5c2c398
|
7
|
+
data.tar.gz: dd50677466ed2e149ef98db1d2591bf98fac050b9e6ac323763ff6e5a8d0385057b705e4fa63cec128d9b497c6570335c189246b92bface4d1497a59bd0c400b
|
@@ -69,17 +69,17 @@ module Triannon
|
|
69
69
|
|
70
70
|
# @return json-ld representation of graph with OpenAnnotation context as a url
|
71
71
|
def jsonld_oa
|
72
|
-
inline_context = graph.dump(:jsonld, :context =>
|
72
|
+
inline_context = graph.dump(:jsonld, :context => Triannon::JsonldContext::OA_CONTEXT_URL)
|
73
73
|
hash_from_json = JSON.parse(inline_context)
|
74
|
-
hash_from_json["@context"] =
|
74
|
+
hash_from_json["@context"] = Triannon::JsonldContext::OA_CONTEXT_URL
|
75
75
|
hash_from_json.to_json
|
76
76
|
end
|
77
77
|
|
78
78
|
# @return json-ld representation of graph with IIIF context as a url
|
79
79
|
def jsonld_iiif
|
80
|
-
inline_context = graph.dump(:jsonld, :context =>
|
80
|
+
inline_context = graph.dump(:jsonld, :context => Triannon::JsonldContext::IIIF_CONTEXT_URL)
|
81
81
|
hash_from_json = JSON.parse(inline_context)
|
82
|
-
hash_from_json["@context"] =
|
82
|
+
hash_from_json["@context"] = Triannon::JsonldContext::IIIF_CONTEXT_URL
|
83
83
|
hash_from_json.to_json
|
84
84
|
end
|
85
85
|
|
@@ -145,33 +145,15 @@ private
|
|
145
145
|
|
146
146
|
def json_ld
|
147
147
|
if data.match(/"@context"\s*\:\s*"http\:\/\/www\.w3\.org\/ns\/oa-context-20130208\.json"/)
|
148
|
-
data.sub!("\"http://www.w3.org/ns/oa-context-20130208.json\"",
|
148
|
+
data.sub!("\"http://www.w3.org/ns/oa-context-20130208.json\"", Triannon::JsonldContext.oa_context)
|
149
149
|
elsif data.match(/"@context"\s*\:\s*"http\:\/\/www\.w3\.org\/ns\/oa\.jsonld"/)
|
150
|
-
data.sub!("\"http://www.w3.org/ns/oa.jsonld\"",
|
150
|
+
data.sub!("\"http://www.w3.org/ns/oa.jsonld\"", Triannon::JsonldContext.oa_context)
|
151
151
|
elsif data.match(/"@context"\s*\:\s*"http\:\/\/iiif\.io\/api\/presentation\/2\/context\.json"/)
|
152
|
-
data.sub!("\"http://iiif.io/api/presentation/2/context.json\"",
|
152
|
+
data.sub!("\"http://iiif.io/api/presentation/2/context.json\"", Triannon::JsonldContext.iiif_context)
|
153
153
|
end
|
154
154
|
@json_ld ||= JSON.parse(data) rescue nil
|
155
155
|
end
|
156
156
|
|
157
|
-
def json_oa_context
|
158
|
-
# FIXME: this is a terrible place/way to see if we are running in the testing app!!
|
159
|
-
if Rails.root.to_s.match(/internal/) # testing via engine_cart
|
160
|
-
@json_oa_context ||= File.read(Rails.root.join("..", "..", "lib", "triannon", "oa_context_20130208.json"))
|
161
|
-
else
|
162
|
-
@json_oa_context ||= File.read(Rails.root.join("lib", "triannon", "oa_context_20130208.json"))
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def json_iiif_context
|
167
|
-
# FIXME: this is a terrible place/way to see if we are running in the testing app!!
|
168
|
-
if Rails.root.to_s.match(/internal/) # testing via engine_cart
|
169
|
-
@json_oa_context ||= File.read(Rails.root.join("..", "..", "lib", "triannon", "iiif_presentation_2_context.json"))
|
170
|
-
else
|
171
|
-
@json_oa_context ||= File.read(Rails.root.join("lib", "triannon", "iiif_presentation_2_context.json"))
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
157
|
def graph_exists?
|
176
158
|
graph && graph.size > 0
|
177
159
|
end
|
data/lib/triannon.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Triannon
|
2
|
+
class JsonldContext
|
3
|
+
|
4
|
+
OA_CONTEXT_URL = "http://www.w3.org/ns/oa.jsonld"
|
5
|
+
|
6
|
+
OA_DATED_CONTEXT_URL = "http://www.w3.org/ns/oa-context-20130208.json"
|
7
|
+
|
8
|
+
IIIF_CONTEXT_URL = "http://iiif.io/api/presentation/2/context.json"
|
9
|
+
|
10
|
+
# a crude way of locally caching context so we don't hammer w3c server for every jsonld parse
|
11
|
+
def self.oa_context
|
12
|
+
@@oa_context ||= File.read(File.dirname(__FILE__) + "/oa_context_20130208.json")
|
13
|
+
end
|
14
|
+
|
15
|
+
# a crude way of locally caching context so we don't hammer server for every jsonld parse
|
16
|
+
def self.iiif_context
|
17
|
+
@@iiif_context ||= File.read(File.dirname(__FILE__) + "/iiif_presentation_2_context.json")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
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.4.
|
4
|
+
version: 0.4.2
|
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: 2014-12-
|
13
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- lib/triannon/engine.rb
|
279
279
|
- lib/triannon/error.rb
|
280
280
|
- lib/triannon/iiif_presentation_2_context.json
|
281
|
+
- lib/triannon/jsonld_context.rb
|
281
282
|
- lib/triannon/oa_context_20130208.json
|
282
283
|
- lib/triannon/version.rb
|
283
284
|
homepage:
|