jekyll-rdf 2.0.0 → 2.1.0.alpha.pre.171

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: bb995c6b66f94be8fafd3b78c74a8bb82858c35f
4
- data.tar.gz: 97ad76c5961a904d35919cab1e52ad81fe21aef1
3
+ metadata.gz: bf67f6f007e203e27966536bdded0e5c552acbda
4
+ data.tar.gz: 192c1276717719dea8f449d58113a7e05606c731
5
5
  SHA512:
6
- metadata.gz: a4a626bbd804965f6e5259750ee6458ef9250cbe79f7d5b5cb7f94952b701b73bd7496ffed8296e825f2db68abd42ccfba16d5eed511d5b787d13438fcf68fbf
7
- data.tar.gz: e772f781b9ff347c466baa0caa8848d832ce898415feca39d95c63066e7c7567973cdb7f98b21ff83e90dbbcc1407abca6f9b8420c7b0456892b1f450e8dfca3
6
+ metadata.gz: fe5f7f9cc3881a868dae0a8db88afe0df263d6b0def386921459685e59aa9bd2eecb4375a5015a90b66b4969e99cfdbc2fe87fa636f1003238f1485b2f2a939a
7
+ data.tar.gz: 2917ae2a2b7852e676e484d0b1c353684296186e9e6c5443551ff99d4e2fcd414369d25a8e1451120dc8ac51227de16880d92d7bb3094780772f2d1838f7d5e7
data/lib/jekyll-rdf.rb CHANGED
@@ -29,6 +29,7 @@
29
29
  require 'jekyll'
30
30
  require 'linkeddata'
31
31
  require 'sparql'
32
+ require 'set'
32
33
 
33
34
  require 'jekyll/drops/rdf_term'
34
35
  require 'jekyll/drops/rdf_statement'
@@ -38,8 +39,14 @@ require 'jekyll/drops/rdf_resource_class'
38
39
  require 'jekyll/exceptions/NoPrefixMapped'
39
40
  require 'jekyll/exceptions/NoPrefixesDefined'
40
41
  require 'jekyll/exceptions/UnMarkedUri'
42
+ require 'jekyll/filters/rdf_resolve_prefix'
41
43
  require 'jekyll/filters/rdf_sparql_query'
42
44
  require 'jekyll/filters/rdf_property'
45
+ require 'jekyll/filters/rdf_collection'
46
+ require 'jekyll/filters/rdf_container'
47
+ require 'jekyll/rdf_generator_helper'
43
48
  require 'jekyll/rdf_main_generator'
49
+ require 'jekyll/rdf_page_helper'
44
50
  require 'jekyll/rdf_page_data'
51
+ require 'jekyll/rdf_class_extraction'
45
52
  require 'jekyll/rdf_template_mapper'
@@ -51,6 +51,33 @@ module Jekyll #:nodoc:
51
51
  #
52
52
  attr_accessor :subResources
53
53
 
54
+ ##
55
+ #
56
+ #
57
+ def initialize(term, sparql, site = nil, page = nil)
58
+ super(term, sparql)
59
+ if(site.is_a?(Jekyll::Site))
60
+ @site = site
61
+ end
62
+ if(page.is_a?(Jekyll::Page))
63
+ @page = page
64
+ end
65
+ end
66
+
67
+ def addNecessities(site, page)
68
+ if(site.is_a?(Jekyll::Site))
69
+ @site ||= site
70
+ end
71
+ if(page.is_a?(Jekyll::Page))
72
+ @page ||= page
73
+ end
74
+ return self
75
+ end
76
+
77
+ def ready?
78
+ return (@site.is_a?(Jekyll::Site)||@page.is_a?(Jekyll::Page))
79
+ end
80
+
54
81
  ##
55
82
  # Return a list of Jekyll::Drops::RdfStatements whose subject, predicate or object is the RDF resource represented by the receiver
56
83
  #
@@ -120,9 +147,61 @@ module Jekyll #:nodoc:
120
147
  # Return a list of Jekyll::Drops::RdfStatements whose object is the RDF resource represented by the receiver
121
148
  #
122
149
  def statements_as(role)
123
- graph.query(role.to_sym => term).map do |statement|
124
- RdfStatement.new(statement, graph, site)
150
+ if(!term.to_s[0..1].eql? "_:")
151
+ inputURI = "<#{term.to_s}>"
152
+ elsif(:predicate.eql? role)
153
+ return []
154
+ else
155
+ inputURI = term.to_s
156
+ end
157
+
158
+ case role
159
+ when :subject
160
+ query = "SELECT ?p ?o ?dt ?lit ?lang WHERE{ #{inputURI} ?p ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
161
+ sparql.query(query).map do |solution|
162
+ check = checkSolution(solution)
163
+ createStatement(term.to_s, solution.p, solution.o, solution.lit, check[:lang], check[:dataType])
164
+ end
165
+ when :predicate
166
+ query = "SELECT ?s ?o ?dt ?lit ?lang WHERE{ ?s #{inputURI} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
167
+ sparql.query(query).map do |solution|
168
+ check = checkSolution(solution)
169
+ createStatement(solution.s, term.to_s, solution.o, solution.lit, check[:lang], check[:dataType])
170
+ end
171
+ when :object
172
+ query = "SELECT ?s ?p WHERE{ ?s ?p #{inputURI}}"
173
+ sparql.query(query).map do |solution|
174
+ createStatement( solution.s, solution.p, term.to_s)
175
+ end
176
+ else
177
+ Jekyll.logger.error "Not existing role found in #{term.to_s}"
178
+ return
179
+ end
180
+ end
181
+
182
+ #checks if a query solution contains a language or type tag and returns those in a hash
183
+ private
184
+ def checkSolution(solution)
185
+ result = {:lang => nil, :dataType => nil}
186
+ if((solution.bound?(:lang)) && (!solution.lang.to_s.eql?("")))
187
+ result[:lang] = solution.lang.to_s.to_sym
188
+ end
189
+ if(solution.bound? :dt)
190
+ result[:dataType] = solution.dt
191
+ end
192
+ return result
193
+ end
194
+
195
+ private
196
+ def createStatement(subjectString, predicateString, objectString, isLit = nil, lang = nil, dataType = nil)
197
+ subject = RDF::URI(subjectString)
198
+ predicate = RDF::URI(predicateString)
199
+ if(!isLit.nil?&&isLit.true?)
200
+ object = RDF::Literal(objectString, language: lang, datatype: RDF::URI(dataType))
201
+ else
202
+ object = RDF::URI(objectString)
125
203
  end
204
+ return RdfStatement.new(RDF::Statement( subject, predicate, object), @sparql, @site)
126
205
  end
127
206
 
128
207
  private
@@ -131,38 +210,43 @@ module Jekyll #:nodoc:
131
210
  # * +domain_name+
132
211
  #
133
212
  def generate_file_name(domain_name, baseurl)
134
- begin
135
- uri = URI::split(term.to_s)
136
- file_name = "rdfsites/" # in this directory all external RDF sites are stored
137
- if (uri[2] == domain_name)
138
- file_name = ""
139
- uri[0] = nil
140
- uri[2] = nil
141
- if(uri[5].length > baseurl.length)
142
- if(uri[5][0..(baseurl.length)].eql? (baseurl + "/"))
143
- uri[5] = uri[5][(baseurl.length)..-1]
213
+ if(term.to_s[0..1].eql? "_:")
214
+ file_name = "rdfsites/blanknode/#{term.to_s}/"
215
+ else
216
+ begin
217
+ uri = URI::split(term.to_s)
218
+ file_name = "rdfsites/" # in this directory all external RDF sites are stored
219
+ if (uri[2] == domain_name)
220
+ file_name = ""
221
+ uri[0] = nil
222
+ uri[2] = nil
223
+ if(uri[5].length > baseurl.length)
224
+ if(uri[5][0..(baseurl.length)].eql? (baseurl + "/"))
225
+ uri[5] = uri[5][(baseurl.length)..-1]
226
+ end
227
+ elsif(uri[5].eql?(baseurl))
228
+ uri[5] = nil
144
229
  end
145
- elsif(uri[5].eql?(baseurl))
146
- uri[5] = nil
147
230
  end
148
- end
149
- (0..8).each do |i|
150
- if !(uri[i].nil?)
151
- case i
152
- when 5
153
- file_name += "#{uri[i][1..-1]}/"
154
- when 8
155
- file_name += "#/#{uri[i]}"
156
- else
157
- file_name += "#{uri[i]}/"
231
+ (0..8).each do |i|
232
+ if !(uri[i].nil?)
233
+ case i
234
+ when 5
235
+ file_name += "#{uri[i][1..-1]}/"
236
+ when 8
237
+ file_name += "#/#{uri[i]}"
238
+ else
239
+ file_name += "#{uri[i]}/"
240
+ end
158
241
  end
159
242
  end
243
+ unless file_name[-1] == '/'
244
+ file_name += '/'
245
+ end
246
+ rescue URI::InvalidURIError #unclean coding: blanknodes are recognized through errors
247
+ file_name = "invalids/#{term.to_s}"
248
+ Jekyll.logger.error("Invalid resource found: #{term.to_s} is not a proper uri")
160
249
  end
161
- unless file_name[-1] == '/'
162
- file_name += '/'
163
- end
164
- rescue URI::InvalidURIError #unclean coding: blanknodes are recognized through errors
165
- file_name = "rdfsites/blanknode/#{term.to_s}/"
166
250
  end
167
251
  file_name = file_name.gsub('_','_u')
168
252
  file_name = file_name.gsub('//','/') # needs a better regex to include /// ////...
@@ -39,8 +39,8 @@ module Jekyll #:nodoc:
39
39
  attr_accessor :subClasses
40
40
  attr_accessor :subClassHierarchyValue
41
41
 
42
- def initialize(term, graph)
43
- super(term, graph)
42
+ def initialize(term, sparql)
43
+ super(term, sparql)
44
44
  @subClasses = []
45
45
  @lock = -1
46
46
  @subClassHierarchyValue = 0
@@ -52,7 +52,13 @@ module Jekyll #:nodoc:
52
52
  end
53
53
 
54
54
  def findDirectSubClasses
55
- selection = statements_as(:object).select{ |s| s.predicate.term.to_s=="http://www.w3.org/2000/01/rdf-schema#subClassOf" }
55
+ if(!@term.to_s[0..1].eql? "_:")
56
+ term_uri = "<#{@term.to_s}>"
57
+ else
58
+ term_uri = @term.to_s
59
+ end
60
+ query = "SELECT ?s WHERE{ ?s <http://www.w3.org/2000/01/rdf-schema#subClassOf> #{term_uri}}"
61
+ selection = @sparql.query(query).map{ |solution| solution.s.to_s}
56
62
  return selection
57
63
  end
58
64
 
@@ -50,12 +50,12 @@ module Jekyll
50
50
  # Create a new Jekyll::Drops::RdfStatement
51
51
  #
52
52
  # * +statement+ - The statement to be represented
53
- # * +graph+ - The RDF::Graph which contains the +statement+
53
+ # * +sparql+ - The SPARQL::Client which contains the +statement+
54
54
  # * +site+ - The Jekyll::Site to be enriched
55
- def initialize(statement, graph, site)
56
- @subject ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.subject, graph, site)
57
- @predicate ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.predicate, graph, site)
58
- @object ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.object, graph, site)
55
+ def initialize(statement, sparql, site)
56
+ @subject ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.subject, sparql, site)
57
+ @predicate ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.predicate, sparql, site)
58
+ @object ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.object, sparql, site)
59
59
  end
60
60
  end
61
61
  end
@@ -37,19 +37,33 @@ module Jekyll
37
37
  attr_reader :term
38
38
 
39
39
  ##
40
- # The RDF::Graph which contains the represented +term+
40
+ # The SPARQL::Client which contains the represented +term+
41
41
  #
42
- attr_reader :graph
42
+ attr_reader :sparql
43
43
 
44
44
  ##
45
45
  # Create a new Jekyll::Drops::RdfTerm
46
46
  #
47
47
  # * +term+ - The term to be represented
48
- # * +graph+ - The RDF::Graph which contains the represented +term+
48
+ # * +sparql+ - The SPARQL::Client which contains the represented +term+
49
49
  #
50
- def initialize(term, graph)
50
+ def initialize(term, sparql)
51
51
  @term ||= term
52
- @graph ||= graph
52
+ @sparql ||= sparql
53
+ end
54
+
55
+ ##
56
+ # Funktion stub with no funktionality. Its purpose is to keep RdfResource compatible.
57
+ #
58
+ def addNecessities (site, page)
59
+ return self
60
+ end
61
+
62
+ ##
63
+ # Funktion stub with no funktionality. Its purpose is to keep RdfResource compatible.
64
+ #
65
+ def ready?
66
+ return true;
53
67
  end
54
68
 
55
69
  ##
@@ -66,18 +80,15 @@ module Jekyll
66
80
  # Convert an RDF term into a new Jekyll::Drops::RdfTerm
67
81
  #
68
82
  # * +term+ - The term to be represented
69
- # * +graph+ - The RDF::Graph which contains the represented +term+
83
+ # * +sparql+ - The SPARQL::Client which contains the represented +term+
70
84
  # * +site+ - The Jekyll::Site to be enriched
71
85
  #
72
- def self.build_term_drop(term, graph, site)
86
+ def self.build_term_drop(term, sparql, site)
73
87
  case term
74
88
  when RDF::URI, RDF::Node
75
- if site
76
- resource = site.data['resources'].find{ |r| r.term == term }
77
- end
78
- resource ? resource : RdfResource.new(term, graph)
89
+ return RdfResource.new(term, sparql)
79
90
  when RDF::Literal
80
- return RdfLiteral.new(term, graph)
91
+ return RdfLiteral.new(term, sparql)
81
92
  else
82
93
  return nil
83
94
  end
@@ -0,0 +1,57 @@
1
+ ##
2
+ # MIT License
3
+ #
4
+ # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi,
5
+ # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+
26
+ module Jekyll
27
+ module RdfCollection
28
+ def rdf_collection(input)
29
+ if(input.statements_as_subject.any?{ |statement|
30
+ statement.predicate.to_s.eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"
31
+ })
32
+ finalizedContainer = Set.new #avoid loops
33
+ nodeSequence = [input.iri]
34
+ nextSequence = []
35
+ results = []
36
+ sparqlClient = input.sparql
37
+ while(!nodeSequence.empty?)
38
+ currentContainer = nodeSequence.pop
39
+ query = "SELECT ?f ?r WHERE{ <#{currentContainer}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> ?r. <#{currentContainer}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?f}"
40
+ solutions = sparqlClient.query(query).each { |solution|
41
+ if((!solution.r.to_s.eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil") && (finalizedContainer.add? solution.r))
42
+ nextSequence.push solution.r.to_s
43
+ end
44
+ results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, input.sparql, input.site).addNecessities(input.site, input.page)
45
+ if(nodeSequence.empty?)
46
+ nodeSequence = nextSequence
47
+ nextSequence = []
48
+ end
49
+ }
50
+ end
51
+ return results
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ Liquid::Template.register_filter(Jekyll::RdfCollection)
@@ -0,0 +1,51 @@
1
+ ##
2
+ # MIT License
3
+ #
4
+ # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi,
5
+ # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+
26
+ module Jekyll
27
+ module RdfContainer
28
+ include Jekyll::RdfPrefixResolver
29
+ def rdf_container(input, type = nil)
30
+ sparqlClient = input.sparql
31
+ if(!(validContainer?(input, sparqlClient, type)))
32
+ Jekyll.logger.error "<#{input.iri}> is not recognized as a container"
33
+ return []
34
+ end
35
+ query = "SELECT ?p ?o WHERE{ <#{input.iri}> ?p ?o }"
36
+ solutions = sparqlClient.query(query).each_with_object([]) {|solution, array|
37
+ if((solution.p.to_s[0..43].eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#_") && (solution.p.to_s[44..-1] !~ /\D/))
38
+ array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, input.sparql, input.site).addNecessities(input.site, input.page)
39
+ end
40
+ }
41
+ return solutions
42
+ end
43
+ def validContainer?(input, sparqlClient, type = nil)
44
+ askQuery1 = "ASK WHERE {VALUES ?o {<http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>} <#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o}"
45
+ askQuery2 = "ASK WHERE {<#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o. ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Container>}"
46
+ return (sparqlClient.query(askQuery1).true?) || (sparqlClient.query(askQuery2).true?)
47
+ end
48
+ end
49
+ end
50
+
51
+ Liquid::Template.register_filter(Jekyll::RdfContainer)
@@ -29,6 +29,7 @@ module Jekyll
29
29
  # Internal module to hold the medthod #rdf_property
30
30
  #
31
31
  module RdfProperty
32
+ include Jekyll::RdfPrefixResolver
32
33
  ##
33
34
  # Computes all objects for which statements exist containing the given subject and predicate and returns any of them
34
35
  #
@@ -38,51 +39,88 @@ module Jekyll
38
39
  # * +list+ - (optional) decides the format of the return value. If set to true it returns an array, otherwise it returns a singleton String containing a URI.
39
40
  #
40
41
  def rdf_property(input, predicate, lang = nil, list = false)
42
+ return map_predicate(input, predicate, lang, list)
43
+ end
44
+
45
+ def rdf_inverse_property(input, predicate, lang = nil, list = false)
46
+ return map_predicate(input, predicate, lang, list, true)
47
+ end
48
+
49
+ private
50
+ def map_predicate(input, predicate, lang = nil, list = false, inverse = false)
41
51
  return input unless input.is_a?(Jekyll::Drops::RdfResource)
42
- begin
43
- predicate = rdf_resolve_prefix(input, predicate)
44
- result = input.statements_as_subject.select{ |s| s.predicate.term.to_s == predicate }
45
- if lang != nil
46
- if lang == 'cfg'
47
- lang = input.site.config['jekyll_rdf']['language']
48
- end
49
- result = result.select{ |s|
50
- if(s.object.term.is_a?(RDF::Literal))
51
- s.object.term.language == lang.to_sym
52
- else
53
- false
54
- end
55
- }
56
- end
57
- return unless !result.empty?
58
- if(list)
59
- return result.map{|p|
60
- p.object.to_s
61
- }
62
- else
63
- return (result.first.object).to_s
64
- end
52
+ predicate = rdf_resolve_prefix(input, predicate)
53
+ result = filter_statements(input, predicate, inverse, lang)
54
+ return unless !result.empty?
55
+ if(list)
56
+ return result
57
+ else
58
+ return result.first
65
59
  end
66
60
  end
67
61
 
68
62
  private
69
- def rdf_resolve_prefix(input, predicate)
70
- if(predicate[0] == "<" && predicate[-1] == ">")
71
- return predicate[1..-2]
63
+ def filter_statements(input, predicate, inverse = false, lang = nil)
64
+ client = input.sparql
65
+ query = ""
66
+ if (lang.eql? 'cfg')
67
+ lang_query = "FILTER(lang(?o) = '#{input.site.config['jekyll_rdf']['language']}')"
68
+ elsif lang.nil?
69
+ lang_query = ""
70
+ else
71
+ lang_query = "FILTER(lang(?o) = '#{lang}')"
72
72
  end
73
- arr=predicate.split(":",2) #bad regex, would also devide 'http://example....' into 'http' and '//example....',even though it is already a complete URI; if 'PREFIX http: <http://...> is defined, 'http' in 'http://example....' could be mistaken for a prefix
74
- if((arr[1].include? (":")) || (arr[1][0..1].eql?("//")))
75
- raise UnMarkedUri.new(predicate, input.page.data['template'])
73
+
74
+ if(!input.to_s[0..1].eql? "_:")
75
+ input_uri = "<#{input.to_s}>"
76
+ else
77
+ input_uri = input.to_s
76
78
  end
77
- if(!input.page.data["rdf_prefixes"].nil?)
78
- if(!input.page.data["rdf_prefix_map"][arr[0]].nil?)
79
- return arr[1].prepend(input.page.data["rdf_prefix_map"][arr[0]])
80
- else
81
- raise NoPrefixMapped.new(predicate, input.page.data['template'], arr[0])
79
+
80
+ if(inverse)
81
+ query = "SELECT ?s WHERE{ ?s <#{predicate}> #{input_uri} }"
82
+ result = client.query(query).map do |solution|
83
+ subject = RDF::URI(solution.s)
84
+ Jekyll::Drops::RdfResource.new(subject, input.sparql, input.site, input.page)
82
85
  end
83
86
  else
84
- raise NoPrefixesDefined.new(predicate, input.page.data['template'])
87
+ query = "SELECT ?o ?dt ?lit ?lang WHERE{ #{input_uri} <#{predicate}> ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang) #{lang_query} }"
88
+ result = client.query(query).map do |solution|
89
+ dist_literal_resource(input, solution)
90
+ end
85
91
  end
92
+ return result
93
+ end
94
+
95
+ ##
96
+ # Distinguishes the solution between an Literal and a Resource
97
+ #
98
+ private
99
+ def dist_literal_resource(input, solution)
100
+ if solution.lit.true?
101
+ check = check_solution(solution)
102
+ object = RDF::Literal(solution.o, language: check[:lang], datatype: RDF::URI(check[:dataType]))
103
+ result = Jekyll::Drops::RdfLiteral.new(object, input.sparql)
104
+ else
105
+ object = RDF::URI(solution.o)
106
+ result = Jekyll::Drops::RdfResource.new(object, input.sparql, input.site, input.page)
107
+ end
108
+ return result
109
+ end
110
+
111
+ ##
112
+ # check what language and datatype the passed literal has
113
+ #
114
+ private
115
+ def check_solution(solution)
116
+ result = {:lang => nil, :dataType => nil}
117
+ if((solution.bound?(:lang)) && (!solution.lang.to_s.eql?("")))
118
+ result[:lang] = solution.lang.to_s.to_sym
119
+ end
120
+ if(solution.bound? :dt)
121
+ result[:dataType] = solution.dt
122
+ end
123
+ return result
86
124
  end
87
125
  end
88
126
  end
@@ -0,0 +1,48 @@
1
+ ##
2
+ # MIT License
3
+ #
4
+ # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi,
5
+ # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+
26
+ module Jekyll
27
+ module RdfPrefixResolver
28
+ private
29
+ def rdf_resolve_prefix(input, predicate)
30
+ if(predicate[0] == "<" && predicate[-1] == ">")
31
+ return predicate[1..-2]
32
+ end
33
+ arr=predicate.split(":",2) #bad regex, would also devide 'http://example....' into 'http' and '//example....',even though it is already a complete URI; if 'PREFIX http: <http://...> is defined, 'http' in 'http://example....' could be mistaken for a prefix
34
+ if((arr[1].include? (":")) || (arr[1][0..1].eql?("//")))
35
+ raise UnMarkedUri.new(predicate, input.page.data['template'])
36
+ end
37
+ if(!input.page.data["rdf_prefixes"].nil?)
38
+ if(!input.page.data["rdf_prefix_map"][arr[0]].nil?)
39
+ return arr[1].prepend(input.page.data["rdf_prefix_map"][arr[0]])
40
+ else
41
+ raise NoPrefixMapped.new(predicate, input.page.data['template'], arr[0])
42
+ end
43
+ else
44
+ raise NoPrefixesDefined.new(predicate, input.page.data['template'])
45
+ end
46
+ end
47
+ end
48
+ end
@@ -44,10 +44,9 @@ module Jekyll
44
44
  query = query.prepend(" ").prepend(input.page.data["rdf_prefixes"])
45
45
  end
46
46
  begin
47
- input.site.data['sparql']
48
- result = input.site.data['sparql'].query(query).map do |solution|
49
- hsh = solution.to_hash
50
- hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.graph, input.site) }
47
+ result = input.sparql.query(query).map do |solution|
48
+ hsh = solution.to_h
49
+ hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.sparql, input.site).addNecessities(input.site, input.page)}
51
50
  hsh.collect{|k,v| [k.to_s, v]}.to_h
52
51
  end
53
52
  return result
@@ -56,7 +55,7 @@ module Jekyll
56
55
  rescue SPARQL::MalformedQuery => mq
57
56
  Jekyll.logger.error("malformed query found: \n #{query} \n Error Message: #{mq.message}")
58
57
  rescue Exception => e
59
- Jekyll.logger.error("unknown Exception of class: #{e.class} in sparql_query \n Query: #{query} \nMessage: #{e.message}")
58
+ Jekyll.logger.error("unknown Exception of class: #{e.class} in sparql_query \n Query: #{query} \nMessage: #{e.message} \nTrace #{e.backtrace.drop(1).map{|s| "\t#{s}"}.join("\n")}")
60
59
  end
61
60
  return []
62
61
  end
@@ -0,0 +1,35 @@
1
+ module Jekyll
2
+ module RdfClassExtraction
3
+ private
4
+ def search_for_classes(sparql)
5
+ class_recognition_query = "SELECT DISTINCT ?resourceUri WHERE{ {?resourceUri <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?o} UNION{ ?s <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?resourceUri} UNION{ ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?resourceUri}}"
6
+ class_search_results = sparql.query(class_recognition_query).map{ |sol| sol[:resourceUri] }.reject do |s| # Reject literals
7
+ s.class <= RDF::Literal
8
+ end.select do |s| # Select URIs and blank nodes in case of include_blank
9
+ s.class <=RDF::Node || s.class <= RDF::URI
10
+ end
11
+ return class_search_results
12
+ end
13
+
14
+ def create_resource_class(class_search_results, sparql)
15
+ class_search_results.each do |uri|
16
+ @classResources[uri.to_s]=Jekyll::Drops::RdfResourceClass.new(uri, sparql)
17
+ end
18
+
19
+ @classResources.each{|key, value|
20
+ value.findDirectSubClasses.each{|s|
21
+ value.addSubClass(@classResources[s])
22
+ }
23
+ }
24
+ end
25
+
26
+ def assign_class_templates(classes_to_templates)
27
+ if(classes_to_templates.is_a?(Hash))
28
+ classes_to_templates.each{|key, value|
29
+ @classResources[key].propagateTemplate(value,0)
30
+ @classResources[key].traverseHierarchyValue(0);
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,119 @@
1
+ module Jekyll
2
+ module RdfGeneratorHelper
3
+ private
4
+ def prepare_pages (site, mapper)
5
+ @pageResources.each{|uri, entry|
6
+ if(entry['./'].nil?)
7
+ if(@config['render_orphaned_uris'])
8
+ entry.each{|name, resource|
9
+ createPage(site, resource, mapper, @global_config)
10
+ }
11
+ end
12
+ else
13
+ resource = entry.delete('./')
14
+ resource.subResources = entry
15
+ createPage(site, resource, mapper, @global_config)
16
+ end
17
+ }
18
+
19
+ @blanknodes.each{|resource|
20
+ createPage(site, resource, mapper, @global_config)
21
+ }
22
+ end
23
+
24
+ def parse_resources (resources, sparql)
25
+ @pageResources={};
26
+ @blanknodes=[]
27
+ resources.each do |uri|
28
+ resource = Jekyll::Drops::RdfResource.new(uri, sparql)
29
+ if(uri.instance_of? RDF::URI)
30
+ uriString = uri.to_s
31
+ if((uriString.include? "#") && (uriString.index("#") < (uriString.length - 1))) #sorting in uris with a #
32
+ preSufUri = uriString.split("#")
33
+ if(!@pageResources.key? preSufUri[0])
34
+ @pageResources[preSufUri[0]] = {}
35
+ end
36
+ @pageResources[preSufUri[0]][preSufUri[1]] = resource
37
+ else #sorting in uris without a #
38
+ if(!@pageResources.key? uriString)
39
+ @pageResources[uriString]={}
40
+ end
41
+ @pageResources[uriString]['./'] = resource
42
+ end
43
+ elsif(uri.instance_of? RDF::Node)
44
+ @blanknodes << resource
45
+ end
46
+ end
47
+ end
48
+
49
+ def load_config (site)
50
+ begin
51
+ @config = site.config.fetch('jekyll_rdf')
52
+ rescue KeyError => e
53
+ Jekyll.logger.error("You've included Jekyll-RDF, but it is not configured. Aborting the jekyll-rdf plugin.")
54
+ return false
55
+ end
56
+
57
+ @global_config = Jekyll.configuration({})
58
+
59
+ #small fix because global_config doesn't work in a test enviorment
60
+ if(!@global_config.key? "url")
61
+ @global_config["url"] = site.config["url"]
62
+ @global_config["baseurl"] = site.config["baseurl"]
63
+ end
64
+ return true
65
+ end
66
+ ##
67
+ # #extract_resources returns resources from an RDF Sparql endpoint.
68
+ #
69
+ # Literals are omitted.
70
+ # Blank nodes are only returned if +include_blank+ is true.
71
+ # Duplicate nodes are removed.
72
+ #
73
+ # * +selection+ - choose any of the following:
74
+ # nil ::
75
+ # no restrictions, return subjects, predicates, objects
76
+ # "subjects" ::
77
+ # return only subjects
78
+ # "predicates" ::
79
+ # return only predicates
80
+ # "objects" ::
81
+ # return only objects
82
+ # Otherwise ::
83
+ # consider +selection+ to be a SPARQL query and return answer set to this SPARQL query
84
+ # * +include_blank+ - If true, blank nodes are also returned, otherwise blank nodes are omitted
85
+ # * +sparql+ - The SPARQL client to run queries against
86
+ #
87
+ def extract_resources(selection, include_blank, sparql)
88
+
89
+ case selection
90
+ when nil # Config parameter not present
91
+ object_resources = extract_resources("objects", include_blank, sparql)
92
+ subject_resources = extract_resources("subjects", include_blank, sparql)
93
+ predicate_resources = extract_resources("predicates", include_blank, sparql)
94
+ return object_resources.concat(subject_resources).concat(predicate_resources).uniq
95
+ when "objects"
96
+ query = "SELECT ?resourceUri WHERE{?s ?p ?resourceUri}"
97
+ when "subjects"
98
+ query = "SELECT ?resourceUri WHERE{?resourceUri ?p ?o}"
99
+ when "predicates"
100
+ query = "SELECT ?resourceUri WHERE{?s ?resourceUri ?o}"
101
+ else
102
+ # Custom query
103
+ query = selection
104
+ end
105
+ sparql.query(query).map{ |sol| sol[:resourceUri] }.reject do |s| # Reject literals
106
+ s.class <= RDF::Literal
107
+ end.select do |s| # Select URIs and blank nodes in case of include_blank
108
+ include_blank || s.class == RDF::URI
109
+ end.uniq
110
+ end
111
+
112
+ def createPage(site, resource, mapper, global_config)
113
+ page = RdfPageData.new(site, site.source, resource, mapper, global_config)
114
+ if(page.complete)
115
+ site.pages << page
116
+ end
117
+ end
118
+ end
119
+ end
@@ -32,6 +32,7 @@ module Jekyll
32
32
  class RdfMainGenerator < Jekyll::Generator
33
33
  safe true
34
34
  priority :highest
35
+ include Jekyll::RdfGeneratorHelper
35
36
 
36
37
  ##
37
38
  # #generate performs the enrichment of a Jekyll::Site with rdf triples
@@ -40,127 +41,28 @@ module Jekyll
40
41
  #
41
42
  def generate(site)
42
43
 
43
- begin
44
- config = site.config.fetch('jekyll_rdf')
45
- rescue Exception
46
- Jekyll.logger.error("You've included Jekyll-RDF, but it is not configured. Aborting the jekyll-rdf plugin.")
47
- return
44
+ if(!load_config(site))
45
+ return false#in case of error, exit routine
48
46
  end
49
-
50
- global_config = Jekyll.configuration({})
51
-
52
- #small fix because global_config doesn't work in a test enviorment
53
- if(!global_config.key? "url")
54
- global_config["url"] = site.config["url"]
55
- global_config["baseurl"] = site.config["baseurl"]
56
- end
57
-
58
- if(config.key? "template_mapping")
47
+ if(@config.key? "template_mapping")
59
48
  Jekyll.logger.error("Outdated format in _config.yml:\n 'template_mapping' detected but the following keys must be used now instead:\n instance_template_mappings -> maps single resources to single layouts\n class_template_mappings -> maps entire classes of resources to layouts\nJekyll-RDF wont render any pages for #{site.source}")
60
- return
49
+ return false
61
50
  end
62
51
 
63
- graph = RDF::Graph.load(config['path'])
52
+ graph = RDF::Graph.load(@config['path'])
64
53
  sparql = SPARQL::Client.new(graph)
65
54
 
66
55
  # restrict RDF graph with restriction
67
- resources = extract_resources(config['restriction'], config['include_blank'], graph, sparql)
68
-
56
+ resources = extract_resources(@config['restriction'], @config['include_blank'], sparql)
69
57
  site.data['sparql'] = sparql
70
58
  site.data['resources'] = []
71
59
 
72
- #parse resources
73
- pageResources={};
74
- blanknodes=[]
75
- resources.each do |uri|
76
- resource = Jekyll::Drops::RdfResource.new(uri, graph)
77
- if(uri.instance_of? RDF::URI)
78
- uriString = uri.to_s
79
- if((uriString.include? "#") && (uriString.index("#") < (uriString.length - 1))) #sorting in uris with a #
80
- preSufUri = uriString.split("#")
81
- if(!pageResources.key? preSufUri[0])
82
- pageResources[preSufUri[0]] = {}
83
- end
84
- pageResources[preSufUri[0]][preSufUri[1]] = resource
85
- elsif #sorting in uris without a #
86
- if(!pageResources.key? uriString)
87
- pageResources[uriString]={}
88
- end
89
- pageResources[uriString]['./'] = resource
90
- end
91
- elsif(uri.instance_of? RDF::Node)
92
- blanknodes << resource
93
- end
94
- end
95
-
96
- mapper = Jekyll::RdfTemplateMapper.new(config['instance_template_mappings'], config['class_template_mappings'], config['default_template'], graph, sparql)
97
-
98
- # create RDF pages for each URI
99
- pageResources.each{|uri, entry|
100
- if(entry['./'].nil?)
101
- if(config['render_orphaned_uris'])
102
- entry.each{|name, resource|
103
- site.pages << RdfPageData.new(site, site.source, resource, mapper, global_config)
104
- }
105
- end
106
- else
107
- resource = entry.delete('./')
108
- resource.subResources = entry
109
- site.pages << RdfPageData.new(site, site.source, resource, mapper, global_config)
110
- end
111
- }
60
+ parse_resources(resources, sparql)
112
61
 
113
- blanknodes.each{|resource|
114
- site.pages << RdfPageData.new(site, site.source, resource, mapper, global_config)
115
- }
116
- end
117
-
118
- ##
119
- # #extract_resources returns resources from an RDF graph.
120
- #
121
- # Literals are omitted.
122
- # Blank nodes are only returned if +include_blank+ is true.
123
- # Duplicate nodes are removed.
124
- #
125
- # * +selection+ - choose any of the following:
126
- # nil ::
127
- # no restrictions, return subjects, predicates, objects
128
- # "subjects" ::
129
- # return only subjects
130
- # "predicates" ::
131
- # return only predicates
132
- # "objects" ::
133
- # return only objects
134
- # Otherwise ::
135
- # consider +selection+ to be a SPARQL query and return answer set to this SPARQL query
136
- # * +include_blank+ - If true, blank nodes are also returned, otherwise blank nodes are omitted
137
- # * +graph+ - The RDF graph to restrict
138
- # * +sparql+ - The SPARQL client to run queries against
139
- #
140
- def extract_resources(selection, include_blank, graph, sparql)
62
+ mapper = Jekyll::RdfTemplateMapper.new(@config['instance_template_mappings'], @config['class_template_mappings'], @config['default_template'], sparql)
141
63
 
142
- case selection
143
- when nil # Config parameter not present
144
- object_resources = extract_resources("objects", include_blank, graph, sparql)
145
- subject_resources = extract_resources("subjects", include_blank, graph, sparql)
146
- predicate_resources = extract_resources("predicates", include_blank, graph, sparql)
147
- return object_resources.concat(subject_resources).concat(predicate_resources).uniq
148
- when "objects"
149
- graph.objects
150
- when "subjects"
151
- graph.subjects
152
- when "predicates"
153
- graph.predicates
154
- else
155
- # Custom query
156
- sparql.query(selection).map{ |sol| sol[:resourceUri] }
157
- end.reject do |s| # Reject literals
158
- s.class <= RDF::Literal
159
- end.select do |s| # Select URIs and blank nodes in case of include_blank
160
- include_blank || s.class == RDF::URI
161
- end.uniq
64
+ prepare_pages(site, mapper)
65
+ return true
162
66
  end
163
-
164
67
  end
165
-
166
68
  end
@@ -29,6 +29,8 @@ module Jekyll
29
29
  # JekyllRdf::RdfPageData creates pages for each RDF resource using a given template
30
30
  #
31
31
  class RdfPageData < Jekyll::Page
32
+ include Jekyll::RdfPageHelper
33
+ attr_reader :complete
32
34
 
33
35
  ##
34
36
  # initialize initializes the page
@@ -42,37 +44,24 @@ module Jekyll
42
44
  @base = base
43
45
  @dir = ""
44
46
  @name = resource.filename(URI::split(config['url'])[2], config['baseurl'])
47
+ @resource = resource
48
+ if(base.nil?)
49
+ Jekyll.logger.warn "Resource #{resource} not rendered: no base url found."
50
+ @complete = false #TODO: set a return here and adapt the test for displaying a warning for rendering a page without template
51
+ else
52
+ @complete = true
53
+ end
45
54
  self.process(@name)
55
+ map_template(resource, mapper)
46
56
 
47
- template = mapper.map(resource)
48
- self.read_yaml(File.join(base, '_layouts'), template)
49
- self.data['title'] = resource.iri
50
- self.data['rdf'] = resource
51
- self.data['template'] = template
52
- if(!resource.subResources.nil?)
53
- self.data['sub_rdf'] = resource.subResources.values
54
- self.data['sub_rdf'].each { |res|
55
- res.page = self
56
- res.site = site
57
- }
58
- end
59
- if !self.data["rdf_prefix_path"].nil?
60
- begin
61
- prefixFile=File.new(File.join(base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
62
- self.data["rdf_prefixes"] = prefixFile.join(" ")
63
- self.data["rdf_prefix_map"] = Hash[ *(prefixFile.collect { |v|
64
- arr = v.split(":",2)
65
- [arr[0][7..-1].strip, arr[1].strip[1..-2]]
66
- }.flatten)]
67
- rescue Errno::ENOENT => ex
68
- Jekyll.logger.error("context: #{resource} template: #{template} file not found: #{File.join(base, 'rdf-data', self.data["rdf_prefix_path"])}")
69
- end
57
+ if(!@complete)
58
+ return #return if something went wrong
70
59
  end
60
+ load_data(site)
61
+ load_prefixes()
71
62
  resource.page = self
72
63
  resource.site = site
73
64
  site.data['resources'] << resource
74
65
  end
75
-
76
66
  end
77
-
78
- end
67
+ end
@@ -0,0 +1,54 @@
1
+ module Jekyll
2
+ module RdfPageHelper
3
+ private
4
+ ##
5
+ # sets @template to the path of a fitting layout
6
+ # it will set @complete to false if no fitting template is found
7
+ # * +resource+ - the resource that will be mapped to a template
8
+ # * +mapper+ - the mapper that provides the resource mappings
9
+ def map_template(resource, mapper)
10
+ @template = mapper.map(resource)
11
+ if(@template.nil?)
12
+ Jekyll.logger.warn("Resource #{resource} not rendered: No fitting template or default template found.")
13
+ @complete = false
14
+ end
15
+ end
16
+
17
+ ##
18
+ # loads the data from the yaml-frontmatter and extends page.data with three key value pairs:
19
+ # -title -> contains the resource.iri
20
+ # -rdf -> contains the resource itself
21
+ # -template -> contains the path to the currenly used template
22
+ def load_data(site)
23
+ self.read_yaml(File.join(@base, '_layouts'), @template)
24
+ self.data['title'] = @resource.iri
25
+ self.data['rdf'] = @resource
26
+ self.data['template'] = @template
27
+ if(!@resource.subResources.nil?)
28
+ self.data['sub_rdf'] = @resource.subResources.values
29
+ self.data['sub_rdf'].each { |res|
30
+ res.page = self
31
+ res.site = site
32
+ }
33
+ end
34
+ end
35
+
36
+ ##
37
+ # loads the prefix data passed in the layout yaml-frontmatter into page.data["rdf_prefixes"] and page.data["rdf_prefix_map"]
38
+ def load_prefixes
39
+ if !self.data["rdf_prefix_path"].nil?
40
+ begin
41
+ prefixFile=File.new(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
42
+ self.data["rdf_prefixes"] = prefixFile.join(" ")
43
+ self.data["rdf_prefix_map"] = Hash[ *(prefixFile.collect { |v|
44
+ arr = v.split(":",2)
45
+ [arr[0][7..-1].strip, arr[1].strip[1..-2]]
46
+ }.flatten)]
47
+ rescue Errno::ENOENT => ex
48
+ Jekyll.logger.error("context: #{@resource} template: #{@template} file not found: #{File.join(@base, 'rdf-data', self.data["rdf_prefix_path"])}")
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
@@ -44,40 +44,20 @@ module Jekyll
44
44
 
45
45
  attr_accessor :classResources
46
46
 
47
+ include Jekyll::RdfClassExtraction
48
+
47
49
  ##
48
50
  # Create a new Jekyll::RdfTemplateMapper
49
51
  #
50
52
  # * +resources_to_templates+ - A Hash mapping a type resource to a template name
51
53
  # * +default_template+ - Default template name
52
- def initialize(resources_to_templates, classes_to_templates, default_template, graph, sparql)
54
+ def initialize(resources_to_templates, classes_to_templates, default_template, sparql)
53
55
  @resources_to_templates = resources_to_templates
54
56
  @default_template = default_template
55
57
  @classes_to_templates = classes_to_templates
56
-
57
58
  @classResources = {}
58
- classRecognitionQuery = "SELECT DISTINCT ?resourceUri WHERE{ {?resourceUri <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?o} UNION{ ?s <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?resourceUri} UNION{ ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?resourceUri}}"
59
- classSearchResults = sparql.query(classRecognitionQuery).map{ |sol| sol[:resourceUri] }.reject do |s| # Reject literals
60
- s.class <= RDF::Literal
61
- end.select do |s| # Select URIs and blank nodes in case of include_blank
62
- true || s.class == RDF::URI
63
- end
64
-
65
- classSearchResults.each do |uri|
66
- classResources[uri.to_s]=Jekyll::Drops::RdfResourceClass.new(uri, graph)
67
- end
68
-
69
- classResources.each{|key, value|
70
- value.findDirectSubClasses.each{|s|
71
- value.addSubClass(classResources[s.subject.term.to_s])
72
- }
73
- }
74
-
75
- if(classes_to_templates.is_a?(Hash))
76
- classes_to_templates.each{|key, value|
77
- classResources[key].propagateTemplate(value,0)
78
- classResources[key].traverseHierarchyValue(0);
79
- }
80
- end
59
+ create_resource_class(search_for_classes(sparql), sparql)
60
+ assign_class_templates(classes_to_templates)
81
61
  end
82
62
 
83
63
  ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0.alpha.pre.171
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2017-03-29 00:00:00.000000000 Z
19
+ date: 2017-07-03 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: linkeddata
@@ -24,28 +24,28 @@ dependencies:
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.99'
27
+ version: '2.0'
28
28
  type: :runtime
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.99'
34
+ version: '2.0'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sparql
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.99'
41
+ version: '2.2'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.99'
48
+ version: '2.2'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: jekyll
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '10.4'
70
- type: :runtime
70
+ type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
@@ -81,7 +81,7 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.8'
84
- type: :runtime
84
+ type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
@@ -95,7 +95,7 @@ dependencies:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '3.0'
98
- type: :runtime
98
+ type: :development
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
@@ -109,7 +109,7 @@ dependencies:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '1.1'
112
- type: :runtime
112
+ type: :development
113
113
  prerelease: false
114
114
  version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
@@ -159,10 +159,16 @@ files:
159
159
  - lib/jekyll/exceptions/NoPrefixMapped.rb
160
160
  - lib/jekyll/exceptions/NoPrefixesDefined.rb
161
161
  - lib/jekyll/exceptions/UnMarkedUri.rb
162
+ - lib/jekyll/filters/rdf_collection.rb
163
+ - lib/jekyll/filters/rdf_container.rb
162
164
  - lib/jekyll/filters/rdf_property.rb
165
+ - lib/jekyll/filters/rdf_resolve_prefix.rb
163
166
  - lib/jekyll/filters/rdf_sparql_query.rb
167
+ - lib/jekyll/rdf_class_extraction.rb
168
+ - lib/jekyll/rdf_generator_helper.rb
164
169
  - lib/jekyll/rdf_main_generator.rb
165
170
  - lib/jekyll/rdf_page_data.rb
171
+ - lib/jekyll/rdf_page_helper.rb
166
172
  - lib/jekyll/rdf_template_mapper.rb
167
173
  homepage: https://github.com/white-gecko/jekyll-rdf
168
174
  licenses:
@@ -179,13 +185,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
185
  version: '0'
180
186
  required_rubygems_version: !ruby/object:Gem::Requirement
181
187
  requirements:
182
- - - ">="
188
+ - - ">"
183
189
  - !ruby/object:Gem::Version
184
- version: '0'
190
+ version: 1.3.1
185
191
  requirements: []
186
192
  rubyforge_project:
187
- rubygems_version: 2.2.2
193
+ rubygems_version: 2.6.12
188
194
  signing_key:
189
195
  specification_version: 4
190
- summary: Hypertext Publication System for Templates Resource Rendering
196
+ summary: Hypertext Publication System for Templated Resource Rendering
191
197
  test_files: []