jekyll-rdf 3.0.0.pre.develop.344 → 3.0.0.pre.develop.346
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 +1 -0
- data/lib/jekyll/filters/rdf_container.rb +1 -0
- data/lib/jekyll/filters/rdf_get.rb +1 -0
- data/lib/jekyll/filters/rdf_page_to_resource.rb +5 -1
- data/lib/jekyll/filters/rdf_property.rb +1 -1
- data/lib/jekyll/filters/rdf_resolve_prefix.rb +6 -6
- data/lib/jekyll/filters/rdf_sparql_query.rb +3 -1
- data/lib/jekyll/helper/rdf_general_helper.rb +36 -1
- data/lib/jekyll/helper/rdf_page_helper.rb +3 -11
- data/lib/jekyll/helper/rdf_prefix_helper.rb +43 -0
- data/lib/jekyll/rdf_main_generator.rb +1 -0
- data/lib/jekyll/rdf_page_data.rb +1 -1
- data/lib/jekyll-rdf.rb +1 -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: d9eedfe231b6b7df139d9d8fa8772516d50ff132d3c52f9b9e250d855ee1ee60
|
4
|
+
data.tar.gz: f985dead37964fd9db4c1d6bdf3393379316e97ec32f486c3625a7fcbc77814e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e4009cc2e5de5aa1494f6839672fafe70dbaee4eaee1c6448d14de0f5a7d135bd6933571b1cdc272ad3aada666e93b491f04553cebfd2bc67738476b5a1ad35
|
7
|
+
data.tar.gz: 503e1be34d489eb51ad06e3237559e2c73998c91d3082d3f8f25bd1a768f3a8ad33f1d7fe564e8c4ccc1f7d5ea9a81f5f26f02034d9843523338fbeb3b7e8255
|
@@ -29,6 +29,7 @@ module Jekyll
|
|
29
29
|
module Filter
|
30
30
|
def rdf_collection(input, predicate = nil)
|
31
31
|
input = rdf_page_to_resource(input)
|
32
|
+
return unless valid_resource?(input)
|
32
33
|
query = "SELECT ?f WHERE{ #{input.term.to_ntriples} " <<
|
33
34
|
(predicate.nil? ? "" : " <#{rdf_resolve_prefix(predicate)}> ?coll . ?coll ") <<
|
34
35
|
" <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}"
|
@@ -28,6 +28,7 @@ module Jekyll
|
|
28
28
|
module Filter
|
29
29
|
def rdf_container(input, type = nil)
|
30
30
|
input = rdf_page_to_resource(input)
|
31
|
+
return unless valid_resource?(input)
|
31
32
|
sparql_client = Jekyll::JekyllRdf::Helper::RdfHelper::sparql
|
32
33
|
n_triples = input.term.to_ntriples
|
33
34
|
if(!(valid_container?(n_triples, type)))
|
@@ -34,6 +34,7 @@ module Jekyll
|
|
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
36
|
request_uri = rdf_resolve_prefix(request_uri)
|
37
|
+
return unless valid_resource?(request_uri)
|
37
38
|
ask_exist = "ASK WHERE {{<#{request_uri}> ?p ?o}UNION{?s <#{request_uri}> ?o}UNION{?s ?p <#{request_uri}>}} "
|
38
39
|
return unless (Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(ask_exist).true?)
|
39
40
|
Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(request_uri), Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page)
|
@@ -8,7 +8,11 @@ module Jekyll
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def rdf_page_to_resource?(input)
|
11
|
-
return (input.nil? || input.class <= (Jekyll::RdfPageData) || (input.class <= Hash && input.respond_to?(:template) && input.respond_to?(:url) && input.respond_to?(:path) ))
|
11
|
+
return (!Jekyll::JekyllRdf::Helper::RdfHelper::page.data['rdf'].nil?)&&(input.nil? || input.class <= (Jekyll::RdfPageData) || (input.class <= Hash && input.respond_to?(:template) && input.respond_to?(:url) && input.respond_to?(:path) ))
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid_resource?(input)
|
15
|
+
return (input.class <= String || input.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
@@ -48,7 +48,7 @@ module Jekyll
|
|
48
48
|
private
|
49
49
|
def map_predicate(input, predicate, lang = nil, list = false, inverse = false)
|
50
50
|
input = rdf_page_to_resource(input)
|
51
|
-
return
|
51
|
+
return unless valid_resource?(input)
|
52
52
|
predicate = rdf_resolve_prefix(predicate)
|
53
53
|
result = filter_statements(input.term.to_ntriples, predicate, inverse, lang)
|
54
54
|
return unless !result.empty?
|
@@ -33,16 +33,16 @@ module Jekyll
|
|
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?("//")))
|
36
|
-
raise UnMarkedUri.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template'])
|
36
|
+
raise UnMarkedUri.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template']) #TODO .data['template'] is only defined on RdfPages
|
37
37
|
end
|
38
|
-
if(!Jekyll::JekyllRdf::Helper::RdfHelper::
|
39
|
-
if(!Jekyll::JekyllRdf::Helper::RdfHelper::
|
40
|
-
return arr[1].prepend(Jekyll::JekyllRdf::Helper::RdfHelper::
|
38
|
+
if(!Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"].nil?)
|
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]])
|
41
41
|
else
|
42
|
-
raise NoPrefixMapped.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template'], arr[0])
|
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
|
44
44
|
else
|
45
|
-
raise NoPrefixesDefined.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template'])
|
45
|
+
raise NoPrefixesDefined.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template']) #TODO .data['template'] is only defined on RdfPages
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -42,6 +42,7 @@ module Jekyll
|
|
42
42
|
query.gsub!('?resourceUri', "<#{Jekyll::JekyllRdf::Helper::RdfHelper::page.data['rdf'].term}>")
|
43
43
|
elsif(resource.class <= Array)
|
44
44
|
resource.each_with_index do |uri, index|
|
45
|
+
return unless valid_resource?(uri)
|
45
46
|
if(uri.class <= Jekyll::JekyllRdf::Drops::RdfResource)
|
46
47
|
query.gsub!("?resourceUri_#{index}", uri.term.to_ntriples)
|
47
48
|
else
|
@@ -49,8 +50,9 @@ module Jekyll
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
else
|
53
|
+
return unless valid_resource?(resource)
|
52
54
|
query.gsub!('?resourceUri', "<#{resource}>")
|
53
|
-
end
|
55
|
+
end if query.include? '?resourceUri' #the only purpose of the if statement is to substitute ?resourceUri
|
54
56
|
if(!Jekyll::JekyllRdf::Helper::RdfHelper::page.data["rdf_prefixes"].nil?)
|
55
57
|
query = query.prepend(" ").prepend(Jekyll::JekyllRdf::Helper::RdfHelper::page.data["rdf_prefixes"])
|
56
58
|
end
|
@@ -25,10 +25,13 @@
|
|
25
25
|
module Jekyll
|
26
26
|
module JekyllRdf
|
27
27
|
module Helper
|
28
|
+
|
28
29
|
##
|
29
30
|
# Internal module to hold support for functionalities like submitting sparql queries
|
30
31
|
#
|
31
32
|
module RdfHelper
|
33
|
+
@@prefixes = {}
|
34
|
+
|
32
35
|
def self.sparql= sparql
|
33
36
|
@@sparql = sparql
|
34
37
|
end
|
@@ -47,13 +50,45 @@ module Jekyll
|
|
47
50
|
|
48
51
|
def self.page= page
|
49
52
|
@@page = page
|
53
|
+
if(@@page.class <= Jekyll::RdfPageData && !@@page.data["rdf_prefixes"].nil?)
|
54
|
+
@@usePage = true
|
55
|
+
else
|
56
|
+
@@usePage = false
|
57
|
+
end
|
50
58
|
end
|
51
59
|
|
52
60
|
def self.page
|
53
61
|
@@page
|
54
62
|
end
|
63
|
+
|
64
|
+
def self.prefixes= path
|
65
|
+
@@prefixes = {}
|
66
|
+
self.load_prefixes(path, @@prefixes)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.load_prefixes(path, prefHolder)
|
70
|
+
begin
|
71
|
+
prefix_file = File.new(path).readlines
|
72
|
+
prefHolder["rdf_prefixes"] = prefix_file.join(" ")
|
73
|
+
prefHolder["rdf_prefix_map"] = Hash[ *(prefix_file.collect { |v|
|
74
|
+
arr = v.split(":",2)
|
75
|
+
[arr[0][7..-1].strip, arr[1].strip[1..-2]]
|
76
|
+
}.flatten)]
|
77
|
+
rescue Errno::ENOENT => ex
|
78
|
+
Jekyll.logger.error("Prefix file not found: #{path}")
|
79
|
+
raise
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.prefixes
|
84
|
+
if(@@usePage)
|
85
|
+
return @@page.data
|
86
|
+
else
|
87
|
+
return @@prefixes
|
88
|
+
end
|
89
|
+
end
|
55
90
|
end
|
91
|
+
|
56
92
|
end
|
57
|
-
|
58
93
|
end
|
59
94
|
end
|
@@ -3,6 +3,7 @@ module Jekyll
|
|
3
3
|
module Helper
|
4
4
|
module RdfPageHelper
|
5
5
|
private
|
6
|
+
include Jekyll::JekyllRdf::Helper::RdfPrefixHelper
|
6
7
|
##
|
7
8
|
# sets @template to the path of a fitting layout
|
8
9
|
# it will set @complete to false if no fitting template is found
|
@@ -37,18 +38,9 @@ module Jekyll
|
|
37
38
|
|
38
39
|
##
|
39
40
|
# loads the prefix data passed in the layout yaml-frontmatter into page.data["rdf_prefixes"] and page.data["rdf_prefix_map"]
|
40
|
-
def
|
41
|
+
def load_prefixes_yaml
|
41
42
|
if !self.data["rdf_prefix_path"].nil?
|
42
|
-
|
43
|
-
prefix_file=File.new(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
|
44
|
-
self.data["rdf_prefixes"] = prefix_file.join(" ")
|
45
|
-
self.data["rdf_prefix_map"] = Hash[ *(prefix_file.collect { |v|
|
46
|
-
arr = v.split(":",2)
|
47
|
-
[arr[0][7..-1].strip, arr[1].strip[1..-2]]
|
48
|
-
}.flatten)]
|
49
|
-
rescue Errno::ENOENT => ex
|
50
|
-
Jekyll.logger.error("context: #{@resource} template: #{@template} file not found: #{File.join(@base, 'rdf-data', self.data["rdf_prefix_path"])}")
|
51
|
-
end
|
43
|
+
load_prefixes(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip), self.data)
|
52
44
|
end
|
53
45
|
end
|
54
46
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
##
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2017 Sebastian Zänker
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
24
|
+
|
25
|
+
module Jekyll
|
26
|
+
module JekyllRdf
|
27
|
+
module Helper
|
28
|
+
##
|
29
|
+
# Internal module to hold support for functionalities like submitting sparql queries
|
30
|
+
#
|
31
|
+
module RdfPrefixHelper
|
32
|
+
##
|
33
|
+
# loads the prefix data passed in the layout yaml-frontmatter or in _config.yml into page.data["rdf_prefixes"] and page.data["rdf_prefix_map"]
|
34
|
+
def load_prefixes(path, prefHolder)
|
35
|
+
Jekyll::JekyllRdf::Helper::RdfHelper.load_prefixes(path, prefHolder)
|
36
|
+
rescue Errno::ENOENT => ex
|
37
|
+
Jekyll.logger.error("--> context resource: #{@resource} template: #{@template}") if self.class <= Jekyll::RdfPageData
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -54,6 +54,7 @@ module Jekyll
|
|
54
54
|
|
55
55
|
Jekyll::JekyllRdf::Helper::RdfHelper::sparql = sparql
|
56
56
|
Jekyll::JekyllRdf::Helper::RdfHelper::site = site
|
57
|
+
Jekyll::JekyllRdf::Helper::RdfHelper::prefixes = File.join(site.source, 'rdf-data', @config['prefixes'].strip) unless @config['prefixes'].nil?
|
57
58
|
|
58
59
|
# restrict RDF graph with restriction
|
59
60
|
resources = extract_resources(@config['restriction'], @config['include_blank'], sparql)
|
data/lib/jekyll/rdf_page_data.rb
CHANGED
data/lib/jekyll-rdf.rb
CHANGED
@@ -41,6 +41,7 @@ require 'jekyll/drops/rdf_resource_class'
|
|
41
41
|
require 'jekyll/exceptions/NoPrefixMapped'
|
42
42
|
require 'jekyll/exceptions/NoPrefixesDefined'
|
43
43
|
require 'jekyll/exceptions/UnMarkedUri'
|
44
|
+
require 'jekyll/helper/rdf_prefix_helper'
|
44
45
|
require 'jekyll/helper/rdf_general_helper'
|
45
46
|
require 'jekyll/helper/rdf_class_extraction'
|
46
47
|
require 'jekyll/helper/rdf_page_helper'
|
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.
|
4
|
+
version: 3.0.0.pre.develop.346
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elias Saalmann
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/jekyll/helper/rdf_general_helper.rb
|
179
179
|
- lib/jekyll/helper/rdf_generator_helper.rb
|
180
180
|
- lib/jekyll/helper/rdf_page_helper.rb
|
181
|
+
- lib/jekyll/helper/rdf_prefix_helper.rb
|
181
182
|
- lib/jekyll/hooks/rdf_page_pointer.rb
|
182
183
|
- lib/jekyll/rdf_main_generator.rb
|
183
184
|
- lib/jekyll/rdf_page_data.rb
|