jekyll-rdf 3.0.0.pre.develop.322 → 3.0.0.pre.develop.326

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: 5c802aae40cda124bc5120ab91440c1264b1417fbb494671036133e3533cc99d
4
- data.tar.gz: dd631ce941d2dbf3a895770f74c70e5b9f3d53cc0051f983d6058447004954fa
3
+ metadata.gz: 9786b31b9d783066f30dad1fe812d98ca1b5535130aec76bab5f1c101e670678
4
+ data.tar.gz: 13bc65feb1a733884e48c7d257665528dd99d06b93ebc65c39f0f3eb6b4f4164
5
5
  SHA512:
6
- metadata.gz: 7f178d602537055e491bc89b1b5b04522b7d83adade9231b6ac7bcf72545f54d74598dbe9bdb6dd15d397715612d806a4b8bc27ceb6d23ccacc36cf06b03902f
7
- data.tar.gz: c88bf30f791997681806b6edcf1b0d8c89674c6f19f793202b228e3792ba82196bdeb77c08196d84dae686b306185e82af5d77bf7d2bb677cdb17b117d24755c
6
+ metadata.gz: a10bb33202de94090845272dba6c25a7b8c4a1bb826cfd75bd42fc7fafe444d72710917cada85ee9dd8efacf93d4325a2a43ffbd0691e05fd9ecc2bce1b5c0f0
7
+ data.tar.gz: 452825c5a9c742013311fa7319a145754238beb05d323fe5ab1b166051873fee2f47734651c251953557d4c81c4ef0704228af84d343419137759fe95ee8a98e
@@ -49,7 +49,12 @@ module Jekyll #:nodoc:
49
49
  ##
50
50
  #
51
51
  #
52
- def initialize(term, site = nil, page = nil)
52
+ attr_reader :covered
53
+
54
+ ##
55
+ #
56
+ #
57
+ def initialize(term, site = nil, page = nil, covered = false)
53
58
  super(term)
54
59
  if(site.is_a?(Jekyll::Site))
55
60
  @site = site
@@ -58,6 +63,7 @@ module Jekyll #:nodoc:
58
63
  @page = page
59
64
  end
60
65
  @subResources = {}
66
+ @covered = covered
61
67
  end
62
68
 
63
69
  def add_necessities(site, page)
@@ -129,14 +135,18 @@ module Jekyll #:nodoc:
129
135
  # Return the URL of the page representing this RdfResource
130
136
  #
131
137
  def page_url
132
- @page_url ||= generate_file_name(@site.config["url"], @site.config["baseurl"]).chomp('index.html').chomp('.html')
138
+ return @page_url unless @page_url.nil?
139
+ generate_file_name(@site.config["url"], @site.config["baseurl"])
140
+ @page_url
133
141
  end
134
142
 
135
143
  ##
136
144
  # Return the path to the page representing this RdfResource
137
145
  #
138
146
  def render_path
139
- @render_path ||= generate_file_name(@site.config["url"], @site.config["baseurl"])
147
+ return @render_path unless @page_url.nil?
148
+ generate_file_name(@site.config["url"], @site.config["baseurl"])
149
+ @render_path
140
150
  end
141
151
 
142
152
  ##
@@ -200,7 +210,6 @@ module Jekyll #:nodoc:
200
210
  return result
201
211
  end
202
212
 
203
- private
204
213
  def create_statement(subject_string, predicate_string, object_string, is_lit = nil, lang = nil, data_type = nil)
205
214
  subject = RDF::URI(subject_string)
206
215
  predicate = RDF::URI(predicate_string)
@@ -212,62 +221,76 @@ module Jekyll #:nodoc:
212
221
  return RdfStatement.new(RDF::Statement( subject, predicate, object), @site)
213
222
  end
214
223
 
215
- private
216
224
  ##
217
225
  # Generate a filename corresponding to the RDF resource represented by the receiver. The mapping between RDF resources and filenames should be bijective. If the url of the rdf is the same as of the hosting site it will be omitted.
218
226
  # * +domain_name+
219
227
  #
220
228
  def generate_file_name(domain_name, baseurl)
229
+ fragment_holder = nil
230
+ domain_name = domain_name.to_s
231
+ baseurl = baseurl.to_s
232
+ (("/".eql? baseurl[-1]) || (baseurl.empty? && ("/".eql? domain_name[-1]))) ? rdfsites="rdfsites/": rdfsites="/rdfsites/"
221
233
  if(term.to_s[0..1].eql? "_:")
222
- file_name = "rdfsites/blanknode/#{term.to_s}/"
234
+ file_name = "#{rdfsites}blanknode/#{term.to_s.gsub('_:','blanknode_')}/" # ':' can not be used on windows
223
235
  else
224
236
  begin
225
237
  uri = Addressable::URI.parse(term.to_s).to_hash
226
- file_name = "rdfsites/" # in this directory all external RDF sites are stored
238
+ file_name = rdfsites # in this directory all external RDF sites are stored
227
239
  if((uri[:host].eql? domain_name) || ("#{uri[:scheme]}://#{uri[:host]}".eql? domain_name))
228
- file_name = ""
229
- uri[:scheme] = nil
230
- uri[:host] = nil
231
- if(uri[:path].length > baseurl.length)
232
- if(uri[:path][0..(baseurl.length)].eql? (baseurl + "/"))
233
- uri[:path] = uri[:path][(baseurl.length)..-1]
234
- end
240
+ if((baseurl.length == 0)) #Special cases like baseurl == path or non-existent baseurl
241
+ uri[:scheme] = nil
242
+ uri[:host] = nil
243
+ file_name = ""
235
244
  elsif(uri[:path].eql?(baseurl))
236
245
  uri[:path] = nil
237
- end
238
- end
239
- key_field = [:scheme, :userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment]
240
- key_field.each do |index|
241
- if !(uri[index].nil?)
242
- case index
243
- when :path
244
- file_name += "#{uri[index][1..-1]}/"
245
- when :fragment
246
- file_name += "#/#{uri[index]}"
247
- else
248
- file_name += "#{uri[index]}/"
246
+ uri[:scheme] = nil
247
+ uri[:host] = nil
248
+ file_name = ""
249
+ elsif(uri[:path].length > baseurl.length) #baseurl might be the first part of :path
250
+ if(uri[:path][0..(baseurl.length - 1)].eql? baseurl)
251
+ uri[:path] = uri[:path][(baseurl.length)..-1]
252
+ uri[:scheme] = nil
253
+ uri[:host] = nil
254
+ file_name = ""
249
255
  end
250
256
  end
251
257
  end
252
- unless file_name[-1] == '/'
253
- file_name += '/'
254
- end
255
- rescue URI::InvalidURIError => x #unclean coding: blanknodes are recognized through errors
258
+ #An URI consists of these fields [:scheme, :userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment]
259
+ file_name << "#{uri[:scheme]}/" unless uri[:scheme].nil?
260
+ file_name << "#{uri[:userinfo]}@" unless uri[:userinfo].nil?
261
+ file_name << "#{uri[:host]}/" unless uri[:host].nil?
262
+ file_name << "#{uri[:port]}/" unless uri[:port].nil?
263
+ # registry purpose unknown
264
+ file_name << "#{uri[:path][0..-1]}" unless uri[:path].nil?
265
+ fragment_holder = "##{uri[:fragment]}" unless uri[:fragment].nil?
266
+ # opaque jekyll produces static pages, so we do not dereferencing
267
+ # query queries do not address resources
268
+ # file_name << "#/#{uri[:fragment]}" unless uri[:fragment].nil? fragments are not evaluated by browsers, only by clients
269
+ rescue Addressable::URI::InvalidURIError => x
256
270
  file_name = "invalids/#{term.to_s}"
257
271
  Jekyll.logger.error("Invalid resource found: #{term.to_s} is not a proper uri")
258
272
  Jekyll.logger.error("URI parser exited with message: #{x.message}")
259
273
  end
260
274
  end
261
- file_name = file_name.gsub('_','_u')
262
275
  file_name = file_name.gsub('//','/') # needs a better regex to include /// ////...
263
- file_name = file_name.gsub(':','_D')
264
276
  file_name = file_name.strip
265
277
  if(file_name[-2..-1] == "#/")
266
278
  file_name = file_name[0..-3]
267
279
  end
268
- file_name += 'index.html'
280
+ if(file_name[-1] == '/')
281
+ file_name << "index.html"
282
+ else
283
+ last_slash = file_name.rindex('/')
284
+ last_slash = 0 if last_slash.nil?
285
+ ending = ""
286
+ if(file_name[-5..-1].eql? ".html")
287
+ ending = ".html" #in case .html is already contained by the term.url
288
+ else
289
+ file_name[last_slash..-1] = "#{file_name[last_slash..-1]}.html"
290
+ end
291
+ end
269
292
  @render_path = file_name
270
- @page_url = file_name.chomp('index.html').chomp('.html')
293
+ @page_url = "#{file_name.chomp('index.html').chomp('.html')}#{ending}#{fragment_holder}"
271
294
  file_name
272
295
  end
273
296
  end
@@ -53,9 +53,9 @@ module Jekyll
53
53
  # * +sparql+ - The SPARQL::Client which contains the +statement+
54
54
  # * +site+ - The Jekyll::Site to be enriched
55
55
  def initialize(statement, site)
56
- @subject ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.subject, site)
57
- @predicate ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.predicate, site)
58
- @object ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.object, site)
56
+ @subject ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.subject, site, true)
57
+ @predicate ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.predicate, site, true)
58
+ @object ||= Jekyll::Drops::RdfTerm.build_term_drop(statement.object, site, true)
59
59
  end
60
60
 
61
61
  def inspect
@@ -86,10 +86,10 @@ module Jekyll
86
86
  # * +term+ - The term to be represented
87
87
  # * +site+ - The Jekyll::Site to be enriched
88
88
  #
89
- def self.build_term_drop(term, site)
89
+ def self.build_term_drop(term, site, covered)
90
90
  case term
91
91
  when RDF::URI, RDF::Node
92
- return RdfResource.new(term, site)
92
+ return RdfResource.new(term, site, nil, covered)
93
93
  when RDF::Literal
94
94
  return RdfLiteral.new(term,)
95
95
  else
@@ -34,7 +34,7 @@ module Jekyll
34
34
  " <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}"
35
35
  results = []
36
36
  Jekyll::RdfHelper::sparql.query(query).each{ |solution|
37
- results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, Jekyll::RdfHelper::site).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
37
+ results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, Jekyll::RdfHelper::site, true).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
38
38
  }
39
39
  return results
40
40
  end
@@ -37,7 +37,7 @@ module Jekyll
37
37
  query = "SELECT ?p ?o WHERE{ #{n_triples} ?p ?o #{query_additions()}"
38
38
  solutions = sparql_client.query(query).each_with_object([]) {|solution, array|
39
39
  if(/^http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_\d+$/.match(solution.p.to_s))
40
- array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, Jekyll::RdfHelper::site).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
40
+ array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, Jekyll::RdfHelper::site, true).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
41
41
  end
42
42
  }
43
43
  return solutions
@@ -75,7 +75,7 @@ module Jekyll
75
75
  query = "SELECT ?s WHERE{ ?s <#{predicate}> #{n_triples} }"
76
76
  result = client.query(query).map do |solution|
77
77
  subject = RDF::URI(solution.s)
78
- Jekyll::Drops::RdfResource.new(subject, Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
78
+ Jekyll::Drops::RdfResource.new(subject, Jekyll::RdfHelper::site, Jekyll::RdfHelper::page, true)
79
79
  end
80
80
  else
81
81
  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} }"
@@ -96,7 +96,7 @@ module Jekyll
96
96
  result = Jekyll::Drops::RdfLiteral.new(object)
97
97
  else
98
98
  object = RDF::URI(solution.o)
99
- result = Jekyll::Drops::RdfResource.new(object, Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)
99
+ result = Jekyll::Drops::RdfResource.new(object, Jekyll::RdfHelper::site, Jekyll::RdfHelper::page, true)
100
100
  end
101
101
  return result
102
102
  end
@@ -49,7 +49,7 @@ module Jekyll
49
49
  begin
50
50
  result = Jekyll::RdfHelper::sparql.query(query).map do |solution|
51
51
  hsh = solution.to_h
52
- hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, Jekyll::RdfHelper::site).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)}
52
+ hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, Jekyll::RdfHelper::site, true).add_necessities(Jekyll::RdfHelper::site, Jekyll::RdfHelper::page)}
53
53
  hsh.collect{|k,v| [k.to_s, v]}.to_h
54
54
  end
55
55
  return result
@@ -3,17 +3,9 @@ module Jekyll
3
3
  private
4
4
  def prepare_pages (site, mapper)
5
5
  @pageResources.each{|uri, entry|
6
- if(entry['./'].nil?)
7
- if(@config['render_orphaned_uris'])
8
- entry.each{|name, resource|
9
- create_page(site, resource, mapper, @global_config)
10
- }
11
- end
12
- else
13
- resource = entry.delete('./')
14
- resource.subResources = entry
15
- create_page(site, resource, mapper, @global_config)
16
- end
6
+ resource = entry.delete('./')
7
+ resource.subResources = entry
8
+ create_page(site, resource, mapper, @global_config)
17
9
  }
18
10
 
19
11
  @blanknodes.each{|resource|
@@ -22,10 +14,10 @@ module Jekyll
22
14
  end
23
15
 
24
16
  def parse_resources (resources)
25
- @pageResources={};
17
+ @pageResources={}
26
18
  @blanknodes=[]
27
19
  resources.each do |uri|
28
- resource = Jekyll::Drops::RdfResource.new(uri)
20
+ resource = Jekyll::Drops::RdfResource.new(uri, nil, nil, true)
29
21
  if(uri.instance_of? RDF::URI)
30
22
  uriString = uri.to_s
31
23
  if((uriString.include? "#") && (uriString.index("#") < (uriString.length - 1))) #sorting in uris with a #
@@ -43,6 +35,11 @@ module Jekyll
43
35
  elsif(uri.instance_of? RDF::Node)
44
36
  @blanknodes << resource
45
37
  end
38
+
39
+ # give parents to orphaned resources
40
+ @pageResources.each_key{|key|
41
+ @pageResources[key]['./'] = Jekyll::Drops::RdfResource.new(RDF::URI(key)) if @pageResources[key]['./'].nil?
42
+ }
46
43
  end
47
44
  end
48
45
 
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.322
4
+ version: 3.0.0.pre.develop.326
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2017-11-03 00:00:00.000000000 Z
20
+ date: 2017-11-06 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: linkeddata
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: 1.3.1
201
201
  requirements: []
202
202
  rubyforge_project:
203
- rubygems_version: 2.7.0
203
+ rubygems_version: 2.7.1
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: Hypertext Publication System for Templated Resource Rendering