jekyll-rdf 3.0.0.pre.develop.370 → 3.0.0.pre.develop.371
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/filters/rdf_collection.rb +3 -2
- data/lib/jekyll/filters/rdf_container.rb +1 -1
- data/lib/jekyll/filters/rdf_get.rb +3 -3
- data/lib/jekyll/filters/rdf_page_to_resource.rb +10 -0
- data/lib/jekyll/filters/rdf_property.rb +3 -3
- data/lib/jekyll/filters/rdf_resolve_prefix.rb +2 -2
- data/lib/jekyll/filters/rdf_sparql_query.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcc48f965bf0e896c8abda64247b1223abc6610f4ef6f49ff76b5a320c4c8438
|
4
|
+
data.tar.gz: ef1208cc1c74fc71d64431b88bb1dfdfdeaae56063ca0ced51dc60d4f0766ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c031d26d90a4113a8dad61b796af8a1b564b586349473272f33b0583f2dbc7f17af67f0cd1b04fb9884787cd704b48882c69546cfb71b2f43f5c9c595363c4
|
7
|
+
data.tar.gz: cd8bb9352fa2c8cd4fe282bb85b390f228258bc0aee043de9a90f67a7adfb6e12edea73eeebb64577a56b6f44f52ac58101d06fb187237573c9e7e5d8bcccd69
|
@@ -30,8 +30,9 @@ module Jekyll
|
|
30
30
|
def rdf_collection(input, predicate = nil)
|
31
31
|
input = rdf_page_to_resource(input)
|
32
32
|
return unless valid_resource?(input)
|
33
|
-
|
34
|
-
|
33
|
+
input = to_string_wrap(input)
|
34
|
+
query = "SELECT ?f WHERE{ #{input} " <<
|
35
|
+
(predicate.nil? ? "" : " #{rdf_resolve_prefix(predicate)} ?coll . ?coll ") <<
|
35
36
|
" <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>* ?r. ?r <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?f}"
|
36
37
|
results = []
|
37
38
|
Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(query).each{ |solution|
|
@@ -30,7 +30,7 @@ module Jekyll
|
|
30
30
|
input = rdf_page_to_resource(input)
|
31
31
|
return unless valid_resource?(input)
|
32
32
|
sparql_client = Jekyll::JekyllRdf::Helper::RdfHelper::sparql
|
33
|
-
n_triples = input
|
33
|
+
n_triples = to_string_wrap(input)
|
34
34
|
if(!(valid_container?(n_triples, type)))
|
35
35
|
Jekyll.logger.error "#{n_triples} is not recognized as a container"
|
36
36
|
return []
|
@@ -33,11 +33,11 @@ module Jekyll
|
|
33
33
|
module Filter
|
34
34
|
def rdf_get(request_uri)
|
35
35
|
request_uri = "<#{Jekyll::JekyllRdf::Helper::RdfHelper::page.data['rdf'].term.to_s}>" if (rdf_page_to_resource?(request_uri))
|
36
|
-
request_uri = rdf_resolve_prefix(request_uri)
|
37
36
|
return unless valid_resource?(request_uri)
|
38
|
-
|
37
|
+
request_uri = rdf_resolve_prefix(request_uri)
|
38
|
+
ask_exist = "ASK WHERE {{#{request_uri} ?p ?o}UNION{?s #{request_uri} ?o}UNION{?s ?p #{request_uri}}} "
|
39
39
|
return unless (Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(ask_exist).true?)
|
40
|
-
Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(request_uri), Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page)
|
40
|
+
Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(request_uri[1..-2]), Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -14,6 +14,16 @@ module Jekyll
|
|
14
14
|
def valid_resource?(input)
|
15
15
|
return (input.class <= String || input.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
16
16
|
end
|
17
|
+
|
18
|
+
def to_string_wrap(input)
|
19
|
+
if(input.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
20
|
+
return input.term.to_ntriples
|
21
|
+
elsif(input.class <= String)
|
22
|
+
return rdf_resolve_prefix(input)
|
23
|
+
else
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -50,7 +50,7 @@ module Jekyll
|
|
50
50
|
input = rdf_page_to_resource(input)
|
51
51
|
return unless valid_resource?(input)
|
52
52
|
predicate = rdf_resolve_prefix(predicate)
|
53
|
-
result = filter_statements(input
|
53
|
+
result = filter_statements(to_string_wrap(input), predicate, inverse, lang)
|
54
54
|
return unless !result.empty?
|
55
55
|
if(list)
|
56
56
|
return result
|
@@ -71,13 +71,13 @@ module Jekyll
|
|
71
71
|
end
|
72
72
|
|
73
73
|
if(inverse)
|
74
|
-
query = "SELECT ?s WHERE{ ?s
|
74
|
+
query = "SELECT ?s WHERE{ ?s #{predicate} #{n_triples} }"
|
75
75
|
result = client.query(query).map do |solution|
|
76
76
|
subject = RDF::URI(solution.s)
|
77
77
|
Jekyll::JekyllRdf::Drops::RdfResource.new(subject, Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page, true)
|
78
78
|
end
|
79
79
|
else
|
80
|
-
query = "SELECT ?o ?dt ?lit ?lang WHERE{ #{n_triples}
|
80
|
+
query = "SELECT ?o ?dt ?lit ?lang WHERE{ #{n_triples} #{predicate} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang) #{lang_query} }"
|
81
81
|
result = client.query(query).map do |solution|
|
82
82
|
dist_literal_resource(solution)
|
83
83
|
end
|
@@ -29,7 +29,7 @@ module Jekyll
|
|
29
29
|
private
|
30
30
|
def rdf_resolve_prefix(predicate)
|
31
31
|
if(predicate[0] == "<" && predicate[-1] == ">")
|
32
|
-
return predicate
|
32
|
+
return predicate
|
33
33
|
end
|
34
34
|
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
|
35
35
|
if((arr[1].include? (":")) || (arr[1][0..1].eql?("//")))
|
@@ -37,7 +37,7 @@ module Jekyll
|
|
37
37
|
end
|
38
38
|
if(!Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"].nil?)
|
39
39
|
if(!Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefix_map"][arr[0]].nil?)
|
40
|
-
return arr[1].prepend(Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefix_map"][arr[0]])
|
40
|
+
return "<#{arr[1].prepend(Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefix_map"][arr[0]])}>"
|
41
41
|
else
|
42
42
|
raise NoPrefixMapped.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template'], arr[0]) #TODO .data['template'] is only defined on RdfPages
|
43
43
|
end
|
@@ -46,12 +46,12 @@ module Jekyll
|
|
46
46
|
if(uri.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
47
47
|
query.gsub!("?resourceUri_#{index}", uri.term.to_ntriples)
|
48
48
|
else
|
49
|
-
query.gsub!("?resourceUri_#{index}", "
|
49
|
+
query.gsub!("?resourceUri_#{index}", "#{rdf_resolve_prefix(uri.to_s)}")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
else
|
53
53
|
return unless valid_resource?(resource)
|
54
|
-
query.gsub!('?resourceUri',
|
54
|
+
query.gsub!('?resourceUri', to_string_wrap(resource))
|
55
55
|
end if query.include? '?resourceUri' #the only purpose of the if statement is to substitute ?resourceUri
|
56
56
|
if(!Jekyll::JekyllRdf::Helper::RdfHelper::page.data["rdf_prefixes"].nil?)
|
57
57
|
query = query.prepend(" ").prepend(Jekyll::JekyllRdf::Helper::RdfHelper::page.data["rdf_prefixes"])
|