triannon 0.0.3 → 0.0.4

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.
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <title>Cerberus</title>
7
+ <title>Triannon</title>
8
8
  <%= stylesheet_link_tag "triannon/application", media: "all" %>
9
9
  <%= javascript_include_tag "triannon/application" %>
10
10
  <%= csrf_meta_tags %>
@@ -21,7 +21,7 @@
21
21
  <span class="icon-bar"></span>
22
22
  <span class="icon-bar"></span>
23
23
  </button>
24
- <%= link_to "Cerberus", root_path, class: 'navbar-brand' %>
24
+ <%= link_to "Triannon", root_path, class: 'navbar-brand' %>
25
25
  </div>
26
26
  <div class="navbar-collapse collapse">
27
27
  <ul class="nav navbar-nav">
@@ -12,7 +12,7 @@
12
12
  <% end %>
13
13
 
14
14
  <div class="field">
15
- <%= f.label 'data (as JSON-LD)' %><br>
15
+ <%= f.label 'data (as json-ld or turtle)' %><br>
16
16
  <%= f.text_area :data %>
17
17
  </div>
18
18
  <div class="actions">
@@ -5,19 +5,19 @@
5
5
  </p>
6
6
  <p>
7
7
  <strong>Target:</strong>
8
- <%= link_to @annotation.has_target, @annotation.has_target %>
8
+ <%= @annotation.has_target.map{|t| link_to(t, t)}.join(", ").html_safe %>
9
9
  </p>
10
10
  <p>
11
11
  <strong>Body (blank node with text):</strong>
12
- <pre>
13
- <%= @annotation.has_body %>
14
- </pre>
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 -%>
15
17
  </p>
16
18
  <p>
17
19
  <strong>Motivated By:</strong>
18
- <% @annotation.motivated_by { |m|%>
19
- <%= link_to @annotation.m, @annotation.m %>
20
- <% } %>
20
+ <%= @annotation.motivated_by.map{|m| link_to(m, m)}.join(", ").html_safe %>
21
21
  </p>
22
22
  <p>
23
23
  <strong>Type:</strong>
@@ -0,0 +1,4 @@
1
+ # Add new mime types for use in respond_to blocks:
2
+ Mime::Type.register "application/ld+json", :jsonld
3
+ Mime::Type.register "application/x-turtle", :ttl, ["text/turtle"]
4
+ Mime::Type.register "application/rdf+xml", :rdfxml, ["text/rdf+xml", "text/rdf"]
@@ -0,0 +1,8 @@
1
+
2
+ def root_container_create
3
+ return if(ENV['CI'] && !ENV['RSPEC_RUNNING'])
4
+
5
+ Triannon::RootAnnotationCreator.create if File.exists? Triannon.triannon_file
6
+ end
7
+
8
+ # root_container_create
@@ -0,0 +1,6 @@
1
+ development:
2
+ ldp_url: yer_ldp_url_here
3
+ test: &test
4
+ ldp_url: yer_ldp_url_here
5
+ production:
6
+ ldp_url: yer_ldp_url_here
@@ -5,5 +5,20 @@ module Triannon
5
5
  def inject_Triannon_routes
6
6
  route "mount Triannon::Engine, at: 'annotations'"
7
7
  end
8
+
9
+ def create_triannon_yml_file
10
+ default_yml =<<-YML
11
+ development:
12
+ ldp_url: http://localhost:8983/fedora/rest/anno
13
+ triannon_base_url: http://your.triannon-server.com
14
+ test: &test
15
+ ldp_url: http://localhost:8983/fedora/rest/anno
16
+ triannon_base_url: http://your.triannon-server.com
17
+ production:
18
+ ldp_url:
19
+ triannon_base_url:
20
+ YML
21
+ create_file 'config/triannon.yml', default_yml
22
+ end
8
23
  end
9
24
  end
@@ -0,0 +1,14 @@
1
+ require 'rdf'
2
+ module RDF
3
+ # contains RDF predefined terms and properties for Triannon
4
+ class Triannon < RDF::StrictVocabulary("http://triannon.stanford.edu/ns/")
5
+
6
+ # Property definitions
7
+ property :externalReference,
8
+ comment: %(A reference to a resource external to Triannon storage.).freeze,
9
+ label: "externalReference".freeze,
10
+ "rdfs:isDefinedBy" => %(triannon:).freeze,
11
+ range: "xsd:anyURI".freeze, # rdf:URI? rdfs:Resource?
12
+ type: "rdf:Property".freeze
13
+ end
14
+ end
@@ -1,7 +1,51 @@
1
1
  require 'linkeddata'
2
2
  require 'rdf/open_annotation'
3
+ require 'rdf/ldp'
4
+ require 'rdf/fcrepo4'
5
+ require 'rdf/triannon_vocab'
3
6
  require 'bootstrap-sass'
7
+ require 'faraday'
4
8
 
5
9
  module Triannon
6
- require "triannon/engine"
10
+ require "triannon/engine"
11
+
12
+ class << self
13
+ attr_accessor :config
14
+ end
15
+
16
+ def self.triannon_file
17
+ "#{::Rails.root.to_s}/config/triannon.yml"
18
+ end
19
+
20
+ def self.config
21
+ @triannon_config ||= begin
22
+ raise "The #{::Rails.env} environment settings were not found in the triannon.yml config" unless config_yml[::Rails.env]
23
+ config_yml[::Rails.env].symbolize_keys
24
+ end
25
+ end
26
+
27
+ def self.config_yml
28
+ require 'erb'
29
+ require 'yaml'
30
+
31
+ return @triannon_yml if @triannon_yml
32
+ unless File.exists?(triannon_file)
33
+ raise "You are missing the triannon configuration file: #{triannon_file}."
34
+ end
35
+
36
+ begin
37
+ @triannon_yml = YAML::load_file(triannon_file)
38
+ rescue => e
39
+ raise("triannon.yml was found, but could not be parsed.\n")
40
+ end
41
+
42
+ if @triannon_yml.nil? || !@triannon_yml.is_a?(Hash)
43
+ raise("triannon.yml was found, but was blank or malformed.\n")
44
+ end
45
+
46
+ return @triannon_yml
47
+ end
48
+
49
+
50
+
7
51
  end
@@ -0,0 +1,53 @@
1
+ {
2
+ "oa": "http://www.w3.org/ns/oa#",
3
+ "cnt": "http://www.w3.org/2011/content#",
4
+ "dc": "http://purl.org/dc/elements/1.1/",
5
+ "dcterms": "http://purl.org/dc/terms/",
6
+ "dctypes": "http://purl.org/dc/dcmitype/",
7
+ "foaf": "http://xmlns.com/foaf/0.1/",
8
+ "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
9
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
10
+ "skos": "http://www.w3.org/2004/02/skos/core#",
11
+ "owl": "http://www.w3.org/2002/07/owl#",
12
+ "prov": "http://www.w3.org/ns/prov#",
13
+ "trig": "http://www.w3.org/2004/03/trix/rdfg-1/",
14
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
15
+ "triannon": " http://triannon.stanford.edu/ns/",
16
+
17
+ "hasBody" : {"@type":"@id", "@id" : "oa:hasBody"},
18
+ "hasTarget" : {"@type":"@id", "@id" : "oa:hasTarget"},
19
+ "hasSource" : {"@type":"@id", "@id" : "oa:hasSource"},
20
+ "hasSelector" : {"@type":"@id", "@id" : "oa:hasSelector"},
21
+ "hasState" : {"@type":"@id", "@id" : "oa:hasState"},
22
+ "hasScope" : {"@type":"@id", "@id" : "oa:hasScope"},
23
+ "annotatedBy" : {"@type":"@id", "@id" : "oa:annotatedBy"},
24
+ "serializedBy" : {"@type":"@id", "@id" : "oa:serializedBy"},
25
+ "motivatedBy" : {"@type":"@id", "@id" : "oa:motivatedBy"},
26
+ "equivalentTo" : {"@type":"@id", "@id" : "oa:equivalentTo"},
27
+ "styledBy" : {"@type":"@id", "@id" : "oa:styledBy"},
28
+ "cachedSource" : {"@type":"@id", "@id" : "oa:cachedSource"},
29
+ "conformsTo" : {"@type":"@id", "@id" : "dcterms:conformsTo"},
30
+ "default" : {"@type":"@id", "@id" : "oa:default"},
31
+ "item" : {"@type":"@id", "@id" : "oa:item"},
32
+ "first": {"@type":"@id", "@id" : "rdf:first"},
33
+ "rest": {"@type":"@id", "@id" : "rdf:rest", "@container" : "@list"},
34
+
35
+ "annotatedAt" : { "@type": "xsd:dateTimeStamp", "@id": "oa:annotatedAt" },
36
+ "end" : { "@type": "xsd:nonNegativeInteger", "@id": "oa:end" },
37
+ "exact" : "oa:exact",
38
+ "prefix" : "oa:prefix",
39
+ "serializedAt" : { "@type": "xsd:dateTimeStamp", "@id": "oa:serializedAt" },
40
+ "start" : { "@type": "xsd:nonNegativeInteger", "@id": "oa:start" },
41
+ "styleClass" : "oa:styleClass",
42
+ "suffix" : "oa:suffix",
43
+ "when" : { "@type": "xsd:dateTimeStamp", "@id": "oa:when" },
44
+
45
+ "chars" : "cnt:chars",
46
+ "bytes" : "cnt:bytes",
47
+ "format" : "dc:format",
48
+ "language" : "dc:language",
49
+ "value" : "rdf:value",
50
+ "label" : "rdfs:label",
51
+ "name" : "foaf:name",
52
+ "mbox" : "foaf:mbox"
53
+ }
@@ -1,3 +1,3 @@
1
1
  module Triannon
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.0.3
4
+ version: 0.0.4
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-09-23 00:00:00.000000000 Z
12
+ date: 2014-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -53,6 +53,34 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rdf-ldp
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rdf-fcrepo4
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
56
84
  - !ruby/object:Gem::Dependency
57
85
  name: bootstrap-sass
58
86
  requirement: !ruby/object:Gem::Requirement
@@ -82,13 +110,13 @@ dependencies:
82
110
  - !ruby/object:Gem::Version
83
111
  version: 5.0.0.beta1
84
112
  - !ruby/object:Gem::Dependency
85
- name: sqlite3
113
+ name: faraday
86
114
  requirement: !ruby/object:Gem::Requirement
87
115
  requirements:
88
116
  - - ">="
89
117
  - !ruby/object:Gem::Version
90
118
  version: '0'
91
- type: :development
119
+ type: :runtime
92
120
  prerelease: false
93
121
  version_requirements: !ruby/object:Gem::Requirement
94
122
  requirements:
@@ -165,6 +193,34 @@ dependencies:
165
193
  - - ">="
166
194
  - !ruby/object:Gem::Version
167
195
  version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: vcr
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ - !ruby/object:Gem::Dependency
211
+ name: webmock
212
+ requirement: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ type: :development
218
+ prerelease: false
219
+ version_requirements: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
168
224
  description:
169
225
  email:
170
226
  - cabeer@stanford.edu
@@ -184,19 +240,28 @@ files:
184
240
  - app/helpers/triannon/annotations_helper.rb
185
241
  - app/helpers/triannon/application_helper.rb
186
242
  - app/models/triannon/annotation.rb
187
- - app/models/triannon/graph_validator.rb
243
+ - app/models/triannon/annotation_ldp.rb
244
+ - app/services/triannon/ldp_creator.rb
245
+ - app/services/triannon/ldp_destroyer.rb
246
+ - app/services/triannon/ldp_loader.rb
247
+ - app/services/triannon/ldp_to_oa_mapper.rb
248
+ - app/services/triannon/root_annotation_creator.rb
188
249
  - app/views/layouts/triannon/application.html.erb
189
250
  - app/views/triannon/annotations/_form.html.erb
190
251
  - app/views/triannon/annotations/edit.html.erb
191
252
  - app/views/triannon/annotations/index.html.erb
192
253
  - app/views/triannon/annotations/new.html.erb
193
254
  - app/views/triannon/annotations/show.html.erb
255
+ - config/initializers/mime_types.rb
256
+ - config/initializers/root_annotation_container.rb
194
257
  - config/routes.rb
195
- - db/migrate/20140912173046_create_triannon_annotations.rb
258
+ - config/triannon.yml
196
259
  - lib/generators/triannon/install_generator.rb
260
+ - lib/rdf/triannon_vocab.rb
197
261
  - lib/tasks/triannon_tasks.rake
198
262
  - lib/triannon.rb
199
263
  - lib/triannon/engine.rb
264
+ - lib/triannon/oa_context_20130208.json
200
265
  - lib/triannon/version.rb
201
266
  homepage:
202
267
  licenses:
@@ -218,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
283
  version: '0'
219
284
  requirements: []
220
285
  rubyforge_project:
221
- rubygems_version: 2.2.0
286
+ rubygems_version: 2.2.2
222
287
  signing_key:
223
288
  specification_version: 4
224
289
  summary: Rails engine for working with storage of OpenAnnotations stored in Fedora4
@@ -1,33 +0,0 @@
1
- module Triannon
2
- class GraphValidator < ActiveModel::Validator
3
-
4
- def validate(anno)
5
- graph_exists? anno
6
- graph = anno.graph
7
- basic_solution = graph.query(self.basic_query)
8
- unless basic_solution && basic_solution.size == 1
9
- anno.errors[:data] << 'The oa:Annotation class MUST be associated with each Annotation.'
10
- anno.errors[:data] << 'each Annotation MUST have at least one target'
11
- end
12
- end
13
-
14
- def graph_exists?(anno)
15
- graph = anno.graph
16
- unless graph && graph.size > 0
17
- anno.errors[:data] << 'Unable to create non-null graph'
18
- end
19
- end
20
-
21
- # query for a subject with
22
- # predicate RDF::OpenAnnotation.hasTarget
23
- # type of RDF::OpenAnnotation.Annotation
24
- def self.basic_query
25
- @@basic_query ||= begin
26
- RDF::Query.new
27
- basic_query << [:s, RDF.type, RDF::URI("http://www.w3.org/ns/oa#Annotation")]
28
- basic_query << [:s, RDF::OpenAnnotation.hasTarget, nil]
29
- end
30
- end
31
-
32
- end
33
- end
@@ -1,9 +0,0 @@
1
- class CreateTriannonAnnotations < ActiveRecord::Migration
2
- def change
3
- create_table :triannon_annotations do |t|
4
- t.text :data
5
-
6
- t.timestamps null: false
7
- end
8
- end
9
- end