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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 775e989fcd812cc52e1d3b838661d3c54d777fbc2c01d0336a2b32b5ddea8ca7
4
- data.tar.gz: df46278f14cb1079d0e5ee327d6afbf33e619ade2175cd30092b5522b80ad20c
3
+ metadata.gz: fcc48f965bf0e896c8abda64247b1223abc6610f4ef6f49ff76b5a320c4c8438
4
+ data.tar.gz: ef1208cc1c74fc71d64431b88bb1dfdfdeaae56063ca0ced51dc60d4f0766ec0
5
5
  SHA512:
6
- metadata.gz: f3eaf50c77d60e0376160001bf06029b83c7aa6984f51c534f46af86da299f7ef7638240f8b61e893ddac6e9bdc1e9441a6d568ab8bcd309954f3ad7f3df109f
7
- data.tar.gz: adcf92c3cdfaf50c173182524af45bc4ddbbd1ac7456245c81abae316de6a0115383e18d311c0c37262d09b3ce052200f781664cf94b4aaa39e741f95e00e2bb
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
- query = "SELECT ?f WHERE{ #{input.term.to_ntriples} " <<
34
- (predicate.nil? ? "" : " <#{rdf_resolve_prefix(predicate)}> ?coll . ?coll ") <<
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.term.to_ntriples
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
- ask_exist = "ASK WHERE {{<#{request_uri}> ?p ?o}UNION{?s <#{request_uri}> ?o}UNION{?s ?p <#{request_uri}>}} "
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.term.to_ntriples, predicate, inverse, lang)
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 <#{predicate}> #{n_triples} }"
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} <#{predicate}> ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang) #{lang_query} }"
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[1..-2]
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}", "<#{rdf_resolve_prefix(uri.to_s)}>")
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', "<#{resource}>")
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"])
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: 3.0.0.pre.develop.370
4
+ version: 3.0.0.pre.develop.371
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann