jekyll-rdf 2.1.0.alpha.pre.171 → 2.1.0.alpha.pre.186
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/drops/rdf_resource.rb +22 -22
- data/lib/jekyll/drops/rdf_resource_class.rb +8 -8
- data/lib/jekyll/drops/rdf_term.rb +1 -1
- data/lib/jekyll/filters/rdf_collection.rb +1 -1
- data/lib/jekyll/filters/rdf_container.rb +8 -8
- data/lib/jekyll/filters/rdf_sparql_query.rb +1 -1
- data/lib/jekyll/rdf_class_extraction.rb +4 -4
- data/lib/jekyll/rdf_generator_helper.rb +4 -4
- data/lib/jekyll/rdf_page_helper.rb +3 -3
- data/lib/jekyll/rdf_template_mapper.rb +12 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05c71bb1e8c3429261cc2f0751ce88548d7c3163
|
4
|
+
data.tar.gz: 02fef96d8ea857b7ee5363a53bfa814c0a36ae9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb188f104ce4f767c84c65eea1d3a6485a7785356e67cf6ca5350f4e603e9b9685ba65555e0e23e47eaf87be902698524f37dd2b1dd39eed0995670083bbf82
|
7
|
+
data.tar.gz: 3dbaa044e5d3a5ebaf43b194cf483e031fd467038a5e25162fa6103975a4ac8e21801f68665ba2c58f724d09b80baa653b96d03d8ca0d3b271ad48aa31b01b38
|
@@ -64,7 +64,7 @@ module Jekyll #:nodoc:
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def add_necessities(site, page)
|
68
68
|
if(site.is_a?(Jekyll::Site))
|
69
69
|
@site ||= site
|
70
70
|
end
|
@@ -113,8 +113,8 @@ module Jekyll #:nodoc:
|
|
113
113
|
@filename ||= generate_file_name(domain_name, baseurl)
|
114
114
|
end
|
115
115
|
|
116
|
-
def
|
117
|
-
@
|
116
|
+
def direct_classes
|
117
|
+
@direct_classes ||= begin
|
118
118
|
classes=[]
|
119
119
|
selection = statements_as(:subject).select{ |s| s.predicate.term.to_s=="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }
|
120
120
|
unless selection.empty?
|
@@ -148,30 +148,30 @@ module Jekyll #:nodoc:
|
|
148
148
|
#
|
149
149
|
def statements_as(role)
|
150
150
|
if(!term.to_s[0..1].eql? "_:")
|
151
|
-
|
151
|
+
input_uri = "<#{term.to_s}>"
|
152
152
|
elsif(:predicate.eql? role)
|
153
153
|
return []
|
154
154
|
else
|
155
|
-
|
155
|
+
input_uri = term.to_s
|
156
156
|
end
|
157
157
|
|
158
158
|
case role
|
159
159
|
when :subject
|
160
|
-
query = "SELECT ?p ?o ?dt ?lit ?lang WHERE{ #{
|
160
|
+
query = "SELECT ?p ?o ?dt ?lit ?lang WHERE{ #{input_uri} ?p ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
|
161
161
|
sparql.query(query).map do |solution|
|
162
|
-
check =
|
163
|
-
|
162
|
+
check = check_solution(solution)
|
163
|
+
create_statement(term.to_s, solution.p, solution.o, solution.lit, check[:lang], check[:data_type])
|
164
164
|
end
|
165
165
|
when :predicate
|
166
|
-
query = "SELECT ?s ?o ?dt ?lit ?lang WHERE{ ?s #{
|
166
|
+
query = "SELECT ?s ?o ?dt ?lit ?lang WHERE{ ?s #{input_uri} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
|
167
167
|
sparql.query(query).map do |solution|
|
168
|
-
check =
|
169
|
-
|
168
|
+
check = check_solution(solution)
|
169
|
+
create_statement(solution.s, term.to_s, solution.o, solution.lit, check[:lang], check[:data_type])
|
170
170
|
end
|
171
171
|
when :object
|
172
|
-
query = "SELECT ?s ?p WHERE{ ?s ?p #{
|
172
|
+
query = "SELECT ?s ?p WHERE{ ?s ?p #{input_uri}}"
|
173
173
|
sparql.query(query).map do |solution|
|
174
|
-
|
174
|
+
create_statement( solution.s, solution.p, term.to_s)
|
175
175
|
end
|
176
176
|
else
|
177
177
|
Jekyll.logger.error "Not existing role found in #{term.to_s}"
|
@@ -181,25 +181,25 @@ module Jekyll #:nodoc:
|
|
181
181
|
|
182
182
|
#checks if a query solution contains a language or type tag and returns those in a hash
|
183
183
|
private
|
184
|
-
def
|
185
|
-
result = {:lang => nil, :
|
184
|
+
def check_solution(solution)
|
185
|
+
result = {:lang => nil, :data_type => nil}
|
186
186
|
if((solution.bound?(:lang)) && (!solution.lang.to_s.eql?("")))
|
187
187
|
result[:lang] = solution.lang.to_s.to_sym
|
188
188
|
end
|
189
189
|
if(solution.bound? :dt)
|
190
|
-
result[:
|
190
|
+
result[:data_type] = solution.dt
|
191
191
|
end
|
192
192
|
return result
|
193
193
|
end
|
194
194
|
|
195
195
|
private
|
196
|
-
def
|
197
|
-
subject = RDF::URI(
|
198
|
-
predicate = RDF::URI(
|
199
|
-
if(!
|
200
|
-
object = RDF::Literal(
|
196
|
+
def create_statement(subject_string, predicate_string, object_string, is_lit = nil, lang = nil, data_type = nil)
|
197
|
+
subject = RDF::URI(subject_string)
|
198
|
+
predicate = RDF::URI(predicate_string)
|
199
|
+
if(!is_lit.nil?&&is_lit.true?)
|
200
|
+
object = RDF::Literal(object_string, language: lang, datatype: RDF::URI(data_type))
|
201
201
|
else
|
202
|
-
object = RDF::URI(
|
202
|
+
object = RDF::URI(object_string)
|
203
203
|
end
|
204
204
|
return RdfStatement.new(RDF::Statement( subject, predicate, object), @sparql, @site)
|
205
205
|
end
|
@@ -47,11 +47,11 @@ module Jekyll #:nodoc:
|
|
47
47
|
@alternativeTemplates = []
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def multiple_templates?
|
51
51
|
!@alternativeTemplates.empty?
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def find_direct_subclasses
|
55
55
|
if(!@term.to_s[0..1].eql? "_:")
|
56
56
|
term_uri = "<#{@term.to_s}>"
|
57
57
|
else
|
@@ -62,26 +62,26 @@ module Jekyll #:nodoc:
|
|
62
62
|
return selection
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def add_subclass(resource)
|
66
66
|
@subClasses << resource
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def propagate_template(template, lock)
|
70
70
|
if(@lock>lock||@lock==-1)
|
71
71
|
@lock=lock
|
72
72
|
@template=template
|
73
73
|
@alternativeTemplates.clear()
|
74
|
-
subClasses.each{|sub| sub.
|
74
|
+
subClasses.each{|sub| sub.propagate_template(template ,lock+1)}
|
75
75
|
elsif(@lock==lock)
|
76
76
|
@alternativeTemplates.push(template)
|
77
|
-
subClasses.each{|sub| sub.
|
77
|
+
subClasses.each{|sub| sub.propagate_template(template ,lock+1)}
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
81
|
+
def traverse_hierarchy_value(predecessorHierarchyValue)
|
82
82
|
if(@subClassHierarchyValue + 1 >= predecessorHierarchyValue) #avoid loops
|
83
83
|
@subClassHierarchyValue += 1
|
84
|
-
subClasses.each{|sub| sub.
|
84
|
+
subClasses.each{|sub| sub.traverse_hierarchy_value(@subClassHierarchyValue)}
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -41,7 +41,7 @@ module Jekyll
|
|
41
41
|
if((!solution.r.to_s.eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil") && (finalizedContainer.add? solution.r))
|
42
42
|
nextSequence.push solution.r.to_s
|
43
43
|
end
|
44
|
-
results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, input.sparql, input.site).
|
44
|
+
results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, input.sparql, input.site).add_necessities(input.site, input.page)
|
45
45
|
if(nodeSequence.empty?)
|
46
46
|
nodeSequence = nextSequence
|
47
47
|
nextSequence = []
|
@@ -27,23 +27,23 @@ module Jekyll
|
|
27
27
|
module RdfContainer
|
28
28
|
include Jekyll::RdfPrefixResolver
|
29
29
|
def rdf_container(input, type = nil)
|
30
|
-
|
31
|
-
if(!(
|
30
|
+
sparql_client = input.sparql
|
31
|
+
if(!(valid_container?(input, sparql_client, type)))
|
32
32
|
Jekyll.logger.error "<#{input.iri}> is not recognized as a container"
|
33
33
|
return []
|
34
34
|
end
|
35
35
|
query = "SELECT ?p ?o WHERE{ <#{input.iri}> ?p ?o }"
|
36
|
-
solutions =
|
36
|
+
solutions = sparql_client.query(query).each_with_object([]) {|solution, array|
|
37
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).
|
38
|
+
array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, input.sparql, input.site).add_necessities(input.site, input.page)
|
39
39
|
end
|
40
40
|
}
|
41
41
|
return solutions
|
42
42
|
end
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
return (
|
43
|
+
def valid_container?(input, sparql_client, type = nil)
|
44
|
+
ask_query_1 = "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
|
+
ask_query_2 = "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 (sparql_client.query(ask_query_1).true?) || (sparql_client.query(ask_query_2).true?)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -46,7 +46,7 @@ module Jekyll
|
|
46
46
|
begin
|
47
47
|
result = input.sparql.query(query).map do |solution|
|
48
48
|
hsh = solution.to_h
|
49
|
-
hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.sparql, input.site).
|
49
|
+
hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.sparql, input.site).add_necessities(input.site, input.page)}
|
50
50
|
hsh.collect{|k,v| [k.to_s, v]}.to_h
|
51
51
|
end
|
52
52
|
return result
|
@@ -17,8 +17,8 @@ module Jekyll
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@classResources.each{|key, value|
|
20
|
-
value.
|
21
|
-
value.
|
20
|
+
value.find_direct_subclasses.each{|s|
|
21
|
+
value.add_subclass(@classResources[s])
|
22
22
|
}
|
23
23
|
}
|
24
24
|
end
|
@@ -26,8 +26,8 @@ module Jekyll
|
|
26
26
|
def assign_class_templates(classes_to_templates)
|
27
27
|
if(classes_to_templates.is_a?(Hash))
|
28
28
|
classes_to_templates.each{|key, value|
|
29
|
-
@classResources[key].
|
30
|
-
@classResources[key].
|
29
|
+
@classResources[key].propagate_template(value,0)
|
30
|
+
@classResources[key].traverse_hierarchy_value(0);
|
31
31
|
}
|
32
32
|
end
|
33
33
|
end
|
@@ -6,18 +6,18 @@ module Jekyll
|
|
6
6
|
if(entry['./'].nil?)
|
7
7
|
if(@config['render_orphaned_uris'])
|
8
8
|
entry.each{|name, resource|
|
9
|
-
|
9
|
+
create_page(site, resource, mapper, @global_config)
|
10
10
|
}
|
11
11
|
end
|
12
12
|
else
|
13
13
|
resource = entry.delete('./')
|
14
14
|
resource.subResources = entry
|
15
|
-
|
15
|
+
create_page(site, resource, mapper, @global_config)
|
16
16
|
end
|
17
17
|
}
|
18
18
|
|
19
19
|
@blanknodes.each{|resource|
|
20
|
-
|
20
|
+
create_page(site, resource, mapper, @global_config)
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
@@ -109,7 +109,7 @@ module Jekyll
|
|
109
109
|
end.uniq
|
110
110
|
end
|
111
111
|
|
112
|
-
def
|
112
|
+
def create_page(site, resource, mapper, global_config)
|
113
113
|
page = RdfPageData.new(site, site.source, resource, mapper, global_config)
|
114
114
|
if(page.complete)
|
115
115
|
site.pages << page
|
@@ -38,9 +38,9 @@ module Jekyll
|
|
38
38
|
def load_prefixes
|
39
39
|
if !self.data["rdf_prefix_path"].nil?
|
40
40
|
begin
|
41
|
-
|
42
|
-
self.data["rdf_prefixes"] =
|
43
|
-
self.data["rdf_prefix_map"] = Hash[ *(
|
41
|
+
prefix_file=File.new(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
|
42
|
+
self.data["rdf_prefixes"] = prefix_file.join(" ")
|
43
|
+
self.data["rdf_prefix_map"] = Hash[ *(prefix_file.collect { |v|
|
44
44
|
arr = v.split(":",2)
|
45
45
|
[arr[0][7..-1].strip, arr[1].strip[1..-2]]
|
46
46
|
}.flatten)]
|
@@ -68,10 +68,10 @@ module Jekyll
|
|
68
68
|
tmpl = resources_to_templates ? resources_to_templates[resource.term.to_s] : nil
|
69
69
|
lock = -1
|
70
70
|
hier = -1
|
71
|
-
|
72
|
-
|
71
|
+
warn_mult_templ = false
|
72
|
+
duplicate_level_templ = []
|
73
73
|
if(tmpl.nil?)
|
74
|
-
resource.
|
74
|
+
resource.direct_classes.each do |classUri|
|
75
75
|
classRes = classResources[classUri]
|
76
76
|
if((classRes.lock <= lock || lock == -1) && !classRes.template.nil?)
|
77
77
|
if(classRes.subClassHierarchyValue > hier)
|
@@ -79,20 +79,20 @@ module Jekyll
|
|
79
79
|
lock = classRes.lock
|
80
80
|
tmpl = classRes.template
|
81
81
|
hier = classRes.subClassHierarchyValue
|
82
|
-
|
83
|
-
|
84
|
-
if(classRes.
|
85
|
-
|
86
|
-
|
82
|
+
warn_mult_templ = false
|
83
|
+
duplicate_level_templ.clear.push(tmpl)
|
84
|
+
if(classRes.multiple_templates?)
|
85
|
+
warn_mult_templ = true
|
86
|
+
duplicate_level_templ.concat(classRes.alternativeTemplates)
|
87
87
|
end
|
88
88
|
elsif(classRes.subClassHierarchyValue == hier)
|
89
|
-
|
90
|
-
|
89
|
+
warn_mult_templ = true
|
90
|
+
duplicate_level_templ.push(classRes.template)
|
91
91
|
end
|
92
92
|
end unless classRes.nil?
|
93
93
|
end
|
94
|
-
if(
|
95
|
-
Jekyll.logger.warn("Warning: multiple possible templates for #{resource.term.to_s}: #{
|
94
|
+
if(warn_mult_templ)
|
95
|
+
Jekyll.logger.warn("Warning: multiple possible templates for #{resource.term.to_s}: #{duplicate_level_templ.uniq.join(', ')}")
|
96
96
|
end
|
97
97
|
end
|
98
98
|
return tmpl unless tmpl.nil?
|
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.1.0.alpha.pre.
|
4
|
+
version: 2.1.0.alpha.pre.186
|
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-07-
|
19
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: linkeddata
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
version: 1.3.1
|
191
191
|
requirements: []
|
192
192
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.4.5
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: Hypertext Publication System for Templated Resource Rendering
|