triannon 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df73d4970ac16fd6e16ceaca420806ffcd734213
4
- data.tar.gz: d2596bcef0e1f2f26004a5f6f856cd43062a6915
3
+ metadata.gz: 9a7823282b8cd47ddb17f44857294cfad6766d9d
4
+ data.tar.gz: cd3260e1d1f0a2d34b037cd859ece24db463eefc
5
5
  SHA512:
6
- metadata.gz: d1771d459b311f7c97ea77f07a1ce04d2f18ce2d92d5765ca752d59b77a6acc52dee668d59d7259f14013c8dad3470a005b1ac1e04e013fda19aac3aa3f201f7
7
- data.tar.gz: 0f6e883baa0961f8675a71f822759e81ac41f85f9730e59b9ecbe44a3cf0e6902db5eaad47d26764716a3ef95659c1a79904dae0358565985841f91c664bbca4
6
+ metadata.gz: 88a2eaa45c4eedf68f168b3077e767b6ec4a8e3278acba9a697e716ac05e7430e97b4608fc82e4d0a05c8cdb38908761a6cec8f16b6666d5ea1c89fa16753d03
7
+ data.tar.gz: c1ecd934d10e4dc3d8f2916aa74ebf0a46866597cbc07f5b715fe009524fce0cae1f5a4a318d1400e1b865b587c679c61e4c6d13575dfcb4de73a25b36c5fb1a
@@ -43,47 +43,6 @@ module Triannon
43
43
  end
44
44
  end
45
45
 
46
- def has_target
47
- # FIXME: target might be more than a string (examples 14-17)
48
- if graph_exists?
49
- q = self.class.anno_query.dup
50
- q << [:s, RDF::OpenAnnotation.hasTarget, :target]
51
- solution = graph.query q
52
- if solution && solution.size > 0
53
- targets = []
54
- solution.each {|res|
55
- targets << res.target.to_s
56
- }
57
- targets
58
- # TODO: raise exception if none?
59
- end
60
- end
61
- end
62
-
63
- def has_body
64
- # FIXME: body can be other things besides blank node with chars
65
- bodies = []
66
- if graph_exists?
67
- q = self.class.anno_query.dup
68
- q << [:s, RDF::OpenAnnotation.hasBody, :body]
69
- # for chars content
70
- # the following two lines are equivalent in identifying inline chars content
71
- # q << [:body, RDF.type, RDF::Content.ContentAsText]
72
- q << [:body, RDF::Content.chars, :chars]
73
- # for non-chars content
74
- # // non-embedded Text resource
75
- #?body a dctypes:Text ;
76
- # dc:format "application/msword .
77
- solution = graph.query q
78
- if solution && solution.size > 0
79
- solution.each {|res|
80
- bodies << res.chars.to_s
81
- }
82
- end
83
- end
84
- bodies
85
- end
86
-
87
46
  def motivated_by
88
47
  if graph_exists?
89
48
  q = self.class.anno_query.dup
@@ -107,6 +66,18 @@ module Triannon
107
66
  def graph= g
108
67
  @graph = g
109
68
  end
69
+
70
+ # @return json-ld representation of graph with OpenAnnotation context as a url
71
+ def jsonld_oa
72
+ inline_context = graph.dump(:jsonld, :context => "http://www.w3.org/ns/oa.jsonld")
73
+ inline_context.sub(/@context.*@graph/m, "@context\": \"http://www.w3.org/ns/oa.jsonld\",\n \"@graph")
74
+ end
75
+
76
+ # @return json-ld representation of graph with IIIF context as a url
77
+ def jsonld_iiif
78
+ inline_context = graph.dump(:jsonld, :context => "http://iiif.io/api/presentation/2/context.json")
79
+ inline_context.sub(/@context.*@graph/m, "@context\": \"http://iiif.io/api/presentation/2/context.json\",\n \"@graph")
80
+ end
110
81
 
111
82
  # query for a subject with type of RDF::OpenAnnotation.Annotation
112
83
  def self.anno_query
@@ -180,7 +151,7 @@ private
180
151
  end
181
152
 
182
153
  def json_oa_context
183
- # FIXME: this is a terrible place to do this!!
154
+ # FIXME: this is a terrible place/way to see if we are running in the testing app!!
184
155
  if Rails.root.to_s.match(/internal/) # testing via engine_cart
185
156
  @json_oa_context ||= File.read(Rails.root.join("..", "..", "lib", "triannon", "oa_context_20130208.json"))
186
157
  else
@@ -189,7 +160,7 @@ private
189
160
  end
190
161
 
191
162
  def json_iiif_context
192
- # FIXME: this is a terrible place to do this!!
163
+ # FIXME: this is a terrible place/way to see if we are running in the testing app!!
193
164
  if Rails.root.to_s.match(/internal/) # testing via engine_cart
194
165
  @json_oa_context ||= File.read(Rails.root.join("..", "..", "lib", "triannon", "iiif_presentation_2_context.json"))
195
166
  else
@@ -4,29 +4,24 @@
4
4
  <%= @annotation.url %>
5
5
  </p>
6
6
  <p>
7
- <strong>Target:</strong>
8
- <%= @annotation.has_target.map{|t| link_to(t, t)}.join(", ").html_safe %>
9
- </p>
10
- <p>
11
- <strong>Body (blank node with text):</strong>
12
- <% if @annotation.has_body.size > 0 -%>
13
- <%= @annotation.has_body.map{|b| "<pre>" + b + "</pre>"}.join.html_safe %>
14
- <% else %>
15
- (no body for this annotation)
16
- <% end -%>
17
- </p>
18
- <p>
19
7
  <strong>Motivated By:</strong>
20
- <%= @annotation.motivated_by.map{|m| link_to(m, m)}.join(", ").html_safe %>
8
+ <%= @annotation.motivated_by.map{|m| link_to(m, m)}.join(", ").html_safe if @annotation.motivated_by %>
21
9
  </p>
22
10
  <p>
23
- <strong>Type:</strong>
24
- <%= link_to @annotation.type, @annotation.type %>
25
- </p>
26
11
 
27
12
  <strong>Turtle:</strong>
28
13
  <pre>
29
14
  <%= @annotation.graph.dump(:ttl) %>
30
15
  </pre>
31
16
 
17
+ <strong>JSON-LD (OpenAnnotation context):</strong>
18
+ <pre>
19
+ <%= @annotation.jsonld_oa %>
20
+ </pre>
21
+
22
+ <strong>JSON-LD (IIIF context):</strong>
23
+ <pre>
24
+ <%= @annotation.jsonld_iiif %>
25
+ </pre>
26
+
32
27
  <%= link_to "Back to List", annotations_path %>
@@ -1,3 +1,3 @@
1
1
  module Triannon
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-20 00:00:00.000000000 Z
12
+ date: 2014-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails