jekyll-rdf 3.1.1.pre.develop.701 → 3.1.1.pre.develop.702
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 +4 -4
- data/lib/jekyll-rdf.rb +1 -0
- data/lib/jekyll/drops/rdf_graph.rb +56 -0
- data/lib/jekyll/filters/rdf_sparql_query.rb +7 -20
- data/lib/jekyll/helper/rdf_filter_helper.rb +23 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778b8d0b842c7ec97a201bdde42aab1ca10ef30d9d997ec3f18364a52cdd3e60
|
4
|
+
data.tar.gz: 355c3c76d1edf5c5ab6d79b6ee8d36f6f205b49725392e7b607972ad06e67a98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afc53787251593f1d94d98cd2e2d2c2af716a45fe735447e4323d7c0fa4bc6fa5572091ca6954b81d469bde00ae1f3393fe70885113bd0b0c6f7c9215a248f2
|
7
|
+
data.tar.gz: 619e6ce00fcc8e42a6ef1afa83dd578b6d5d1b5c69920fc83d97100757b133b446a003258f5cf8f96249902fae6d1d7a28476548f91656622c1253c8c5201dff
|
data/lib/jekyll-rdf.rb
CHANGED
@@ -43,6 +43,7 @@ require 'jekyll/drops/rdf_statement'
|
|
43
43
|
require 'jekyll/drops/rdf_literal'
|
44
44
|
require 'jekyll/drops/rdf_resource'
|
45
45
|
require 'jekyll/drops/rdf_resource_class'
|
46
|
+
require 'jekyll/drops/rdf_graph'
|
46
47
|
require 'jekyll/exceptions/NoPrefixMapped'
|
47
48
|
require 'jekyll/exceptions/NoPrefixesDefined'
|
48
49
|
require 'jekyll/exceptions/UnMarkedUri'
|
@@ -0,0 +1,56 @@
|
|
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 #:nodoc:
|
27
|
+
module JekyllRdf #:nodoc:
|
28
|
+
module Drops #:nodoc:
|
29
|
+
class RdfGraph < Liquid::Drop
|
30
|
+
attr_reader :graph
|
31
|
+
|
32
|
+
def initialize(graph)
|
33
|
+
@graph = graph
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
to_nquads
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_nquads
|
41
|
+
result = @graph.statements.map{|state|
|
42
|
+
state.to_nquads
|
43
|
+
}.join("")
|
44
|
+
return result
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_ntriples
|
48
|
+
result = @graph.statements.map{|state|
|
49
|
+
state.to_ntriples
|
50
|
+
}.join("")
|
51
|
+
return result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -38,27 +38,14 @@ module Jekyll
|
|
38
38
|
# * +query+ - the SPARQL query
|
39
39
|
#
|
40
40
|
def sparql_query(resource = nil, query)
|
41
|
-
query = query
|
42
|
-
if
|
43
|
-
query.gsub!('?resourceUri', "<#{Jekyll::JekyllRdf::Helper::RdfHelper::page.data['rdf'].term}>")
|
44
|
-
elsif(resource.class <= Array)
|
45
|
-
resource.each_with_index do |uri, index|
|
46
|
-
return unless valid_resource?(uri)
|
47
|
-
if(uri.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
48
|
-
query.gsub!("?resourceUri_#{index}", uri.term.to_ntriples)
|
49
|
-
else
|
50
|
-
query.gsub!("?resourceUri_#{index}", "#{rdf_resolve_prefix(uri.to_s)}")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
else
|
54
|
-
return unless valid_resource?(resource)
|
55
|
-
query.gsub!('?resourceUri', to_string_wrap(resource))
|
56
|
-
end if query.include? '?resourceUri' #the only purpose of the if statement is to substitute ?resourceUri
|
57
|
-
unless Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"].nil?
|
58
|
-
query = query.prepend(" ").prepend(Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"])
|
59
|
-
end
|
41
|
+
query = prepare_query(resource, query)
|
42
|
+
return if query.nil?
|
60
43
|
begin
|
61
|
-
result = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(query)
|
44
|
+
result = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(query)
|
45
|
+
if (result.class == RDF::Graph)
|
46
|
+
return Jekyll::JekyllRdf::Drops::RdfGraph.new(result)
|
47
|
+
end
|
48
|
+
result.map! do |solution|
|
62
49
|
hsh = solution.to_h
|
63
50
|
hsh.update(hsh){ |k,v| Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(v, Jekyll::JekyllRdf::Helper::RdfHelper::site, true).add_necessities(Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page)}
|
64
51
|
hsh.collect{|k,v| [k.to_s, v]}.to_h
|
@@ -55,6 +55,29 @@ module Jekyll
|
|
55
55
|
return false
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
def prepare_query(resource = nil, query)
|
60
|
+
query = query.clone #sometimes liquid wont reinit static strings in for loops
|
61
|
+
if(rdf_substitude_nil?(resource))
|
62
|
+
query.gsub!('?resourceUri', "<#{Jekyll::JekyllRdf::Helper::RdfHelper::page.data['rdf'].term}>")
|
63
|
+
elsif(resource.class <= Array)
|
64
|
+
resource.each_with_index do |uri, index|
|
65
|
+
return nil unless valid_resource?(uri)
|
66
|
+
if(uri.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
67
|
+
query.gsub!("?resourceUri_#{index}", uri.term.to_ntriples)
|
68
|
+
else
|
69
|
+
query.gsub!("?resourceUri_#{index}", "#{rdf_resolve_prefix(uri.to_s)}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
else
|
73
|
+
return nil unless valid_resource?(resource)
|
74
|
+
query.gsub!('?resourceUri', to_string_wrap(resource))
|
75
|
+
end if query.include? '?resourceUri' #the only purpose of the if statement is to substitute ?resourceUri
|
76
|
+
unless Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"].nil?
|
77
|
+
query = query.prepend(" ").prepend(Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"])
|
78
|
+
end
|
79
|
+
return query
|
80
|
+
end
|
58
81
|
end
|
59
82
|
|
60
83
|
module PrefixSolver
|
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.1.1.pre.develop.
|
4
|
+
version: 3.1.1.pre.develop.702
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elias Saalmann
|
@@ -207,6 +207,7 @@ extensions: []
|
|
207
207
|
extra_rdoc_files: []
|
208
208
|
files:
|
209
209
|
- lib/jekyll-rdf.rb
|
210
|
+
- lib/jekyll/drops/rdf_graph.rb
|
210
211
|
- lib/jekyll/drops/rdf_literal.rb
|
211
212
|
- lib/jekyll/drops/rdf_resource.rb
|
212
213
|
- lib/jekyll/drops/rdf_resource_class.rb
|