jekyll-rdf 3.0.0.pre.develop.472 → 3.0.0.pre.develop.477

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: 8b1984a15f0479ec3957bec51c1d7a3740aced15093518ef240ce9626b119167
4
- data.tar.gz: 43602d81de94c0f5a3b5c34f605abfddb5c1afd19fcab14358b0932d638b599e
3
+ metadata.gz: 22c82cefcb8478a7c0d7ca8d832307107929bd10cb8f7fa17ab50e225158ce13
4
+ data.tar.gz: 52fda858d0d0f8094c2610b2f898a5e958b5a6aec83a8dbc31c8b3cb177be035
5
5
  SHA512:
6
- metadata.gz: dc5c7e3786f6b6c8bcfcc937b4be7b49ee5313d005529e469171155855609f4a4c7916f000f5f755fff2562efbd94856c0afaa314857ac8be53f2be9151467b6
7
- data.tar.gz: d5e473c6bc7442bc246aa1e094b8daaff706446eab702e75e89de3b594f2fd9add2d930a022606bc0e6196dbff41f70df067bdc47c616e64276075a803d31879
6
+ metadata.gz: de941230987979e7e693ae1fb32ae1c9dbe196ccbfa4e9cb99346a82a3497537f27a8955730a00e6c555bfa5e0413d170490fa63ee1ce8785d885ade6f36b984
7
+ data.tar.gz: f5e6dcb5c3aeb6ab86b35745cb5adfdd0a6acba45089422de942f0578f18666b1f2452250da2e8fac5fcc894b992c0197e9ef8e5ea07f21a2116b8a8c547ab11
data/lib/jekyll-rdf.rb CHANGED
@@ -58,5 +58,4 @@ require 'jekyll/filters/rdf_page_to_resource'
58
58
 
59
59
  Liquid::Template.register_filter(Jekyll::JekyllRdf::Filter)
60
60
  require 'jekyll/rdf_main_generator'
61
- require 'jekyll/rdf_page_data'
62
61
  require 'jekyll/rdf_template_mapper'
@@ -38,7 +38,7 @@ module Jekyll #:nodoc:
38
38
  attr_accessor :site
39
39
 
40
40
  ##
41
- # The Jekyll::RdfPageData of this Jekyll::JekyllRdf::Drops::RdfResource
41
+ # The Jekyll::Page of this Jekyll::JekyllRdf::Drops::RdfResource
42
42
  #
43
43
  attr_accessor :page
44
44
 
@@ -4,14 +4,15 @@ module Jekyll
4
4
  module RdfGeneratorHelper
5
5
  private
6
6
  def prepare_pages (site, mapper)
7
+ Jekyll::Page.prepend Jekyll::JekyllRdf::Helper::RdfPageHelper
7
8
  @pageResources.each{|uri, entry|
8
9
  resource = entry.delete('./')
9
10
  resource.subResources = entry
10
- create_page(site, resource, mapper, @global_config)
11
+ create_page(site, resource, mapper)
11
12
  }
12
13
 
13
14
  @blanknodes.each{|resource|
14
- create_page(site, resource, mapper, @global_config)
15
+ create_page(site, resource, mapper)
15
16
  }
16
17
  end
17
18
 
@@ -120,10 +121,24 @@ module Jekyll
120
121
  end.uniq
121
122
  end
122
123
 
123
- def create_page(site, resource, mapper, global_config)
124
- page = RdfPageData.new(site, site.source, resource, mapper, global_config)
124
+ def create_page(site, resource, mapper)
125
+ Jekyll::JekyllRdf::Helper::RdfPageHelper.prepare_resource resource, mapper
126
+ page = Jekyll::Page.new(site, site.source, resource.filedir, resource.filename)
127
+ page.re_init_as_rdf(resource, mapper)
125
128
  if(page.complete)
126
- site.pages << page
129
+ changes = false
130
+ site.pages.map!{|old_page|
131
+ if (File.join(old_page.dir, old_page.name) == File.join(page.dir, page.name))
132
+ changes||=true
133
+ page.assimilate_page(old_page)
134
+ page
135
+ else
136
+ old_page
137
+ end
138
+ }
139
+ unless changes
140
+ site.pages << page
141
+ end
127
142
  resource.add_necessities(site, page)
128
143
  resource.subResources.each {|key, value|
129
144
  value.add_necessities(site, page)
@@ -2,6 +2,54 @@ module Jekyll
2
2
  module JekyllRdf
3
3
  module Helper
4
4
  module RdfPageHelper
5
+ attr_reader :complete
6
+
7
+ def assimilate_page page
8
+ self.data.merge!(page.data)
9
+ setData()
10
+ if page.data['layout'].nil?
11
+ self.content.gsub!(/{{\s*content\s*}}/, page.content)
12
+ else
13
+ self.content = page.content
14
+ end
15
+ self
16
+ end
17
+
18
+ def re_init_as_rdf(resource, mapper)
19
+ @resource = resource
20
+ if(@base.nil?)
21
+ Jekyll.logger.warn "Resource #{resource} not rendered: no base url found."
22
+ @complete = false #TODO: set a return here and adapt the test for displaying a warning for rendering a page without template
23
+ else
24
+ @complete = true
25
+ end
26
+ map_template(resource, mapper)
27
+ return unless @complete
28
+ load_data(@site)
29
+ self.data['permalink'] = File.join(@dir, @name) #overwrite permalinks to stop them from interfering with JekyllRdfs rendersystem
30
+ return unless @complete
31
+ load_prefixes_yaml()
32
+ resource.page = self
33
+ resource.site = @site
34
+ @site.data['resources'] << resource
35
+ end
36
+
37
+ def self.prepare_resource resource, mapper
38
+ @@template = mapper.map(resource)
39
+ @@template.gsub!(".html", "") unless @@template.nil? #gsub only for downward compatibility // remove gsub + unless on next version update
40
+ end
41
+
42
+ def read_yaml(base, name, opts = {})
43
+ @path = @site.layouts[Jekyll::JekyllRdf::Helper::RdfPageHelper.template(true)].path unless Jekyll::JekyllRdf::Helper::RdfPageHelper.template.nil?
44
+ super(base, name, opts)
45
+ end
46
+
47
+ def self.template read_out = false
48
+ template = @@template
49
+ @@template = nil if read_out
50
+ template
51
+ end
52
+
5
53
  private
6
54
  include Jekyll::JekyllRdf::Helper::RdfPrefixHelper
7
55
  ##
@@ -10,7 +58,8 @@ module Jekyll
10
58
  # * +resource+ - the resource that will be mapped to a template
11
59
  # * +mapper+ - the mapper that provides the resource mappings
12
60
  def map_template(resource, mapper)
13
- @template = mapper.map(resource).gsub(".html", "") unless mapper.map(resource).nil? #gsub only for downward compatibility // remove gsub + unless on next version update
61
+ @template = mapper.map(resource)
62
+ @template.gsub!(".html", "") unless @template.nil? #gsub only for downward compatibility // remove gsub + unless on next version update
14
63
  if(@template.nil?)
15
64
  Jekyll.logger.warn("Resource #{resource} not rendered: No fitting template or default template found.")
16
65
  @complete = false
@@ -30,11 +79,7 @@ module Jekyll
30
79
  @complete = false
31
80
  return
32
81
  end
33
- @path = @site.layouts[@template].path
34
- self.read_yaml(@site.layouts[@template].instance_variable_get(:@base_dir), @site.layouts[@template].name)
35
- self.data['title'] = @resource.iri
36
- self.data['rdf'] = @resource
37
- self.data['template'] = @template
82
+ setData()
38
83
  if(!@resource.subResources.nil?)
39
84
  self.data['sub_rdf'] = @resource.subResources.values
40
85
  self.data['sub_rdf'].each { |res|
@@ -44,16 +89,21 @@ module Jekyll
44
89
  end
45
90
  end
46
91
 
92
+ def setData
93
+ self.data['rdf'] = @resource
94
+ self.data['template'] = @template
95
+ end
96
+
47
97
  ##
48
98
  # loads the prefix data passed in the layout yaml-frontmatter into page.data["rdf_prefixes"] and page.data["rdf_prefix_map"]
49
99
  def load_prefixes_yaml
50
- if !self.data["rdf_prefix_path"].nil?
100
+ unless self.data["rdf_prefix_path"].nil?
51
101
  load_prefixes(File.join(@site.layouts[@template].instance_variable_get(:@base_dir), self.data["rdf_prefix_path"].strip), self.data)
52
102
  end
53
103
  end
104
+
54
105
  end
55
106
 
56
107
  end
57
108
  end
58
109
  end
59
-
@@ -34,7 +34,7 @@ module Jekyll
34
34
  def load_prefixes(path, prefHolder)
35
35
  Jekyll::JekyllRdf::Helper::RdfHelper.load_prefixes(path, prefHolder)
36
36
  rescue Errno::ENOENT => ex
37
- Jekyll.logger.error("--> context resource: #{@resource} template: #{@template}") if self.class <= Jekyll::RdfPageData
37
+ Jekyll.logger.error("--> context resource: #{@resource} template: #{@template}") unless self.data["rdf"].nil?
38
38
  end
39
39
  end
40
40
 
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
27
- if(page.class <= Jekyll::RdfPageData)
27
+ unless(page.data['rdf'].nil?)
28
28
  payload["content"] = ""
29
29
  end
30
30
  if(page.data["rdf_prefixes"].nil? && !page.data["rdf_prefix_path"].nil?)
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.472
4
+ version: 3.0.0.pre.develop.477
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: 2018-07-15 00:00:00.000000000 Z
20
+ date: 2018-07-17 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: linkeddata
@@ -195,7 +195,6 @@ files:
195
195
  - lib/jekyll/helper/rdf_prefix_helper.rb
196
196
  - lib/jekyll/hooks/rdf_page_pointer.rb
197
197
  - lib/jekyll/rdf_main_generator.rb
198
- - lib/jekyll/rdf_page_data.rb
199
198
  - lib/jekyll/rdf_template_mapper.rb
200
199
  homepage: https://github.com/white-gecko/jekyll-rdf
201
200
  licenses:
@@ -1,66 +0,0 @@
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
27
-
28
- ##
29
- # JekyllRdf::RdfPageData creates pages for each RDF resource using a given template
30
- #
31
- class RdfPageData < Jekyll::Page
32
- include Jekyll::JekyllRdf::Helper::RdfPageHelper
33
- attr_reader :complete
34
-
35
- ##
36
- # initialize initializes the page
37
- # * +site+ - The Jekyll site we want to enrich with RDF data
38
- # * +base+ - The base of the site
39
- # * +resource+ - The RDF resource for which the page is rendered
40
- # * +mapper+ - The layout-mapping
41
- #
42
- def initialize(site, base, resource, mapper, config)
43
- @site = site
44
- @base = base
45
- @name = resource.filename
46
- @dir = resource.filedir
47
- @resource = resource
48
- if(base.nil?)
49
- Jekyll.logger.warn "Resource #{resource} not rendered: no base url found."
50
- @complete = false #TODO: set a return here and adapt the test for displaying a warning for rendering a page without template
51
- else
52
- @complete = true
53
- end
54
- self.process(@name)
55
- map_template(resource, mapper)
56
- return unless @complete
57
- load_data(site)
58
- self.data['permalink'] = File.join(@dir, @name) #overwrite permalinks to stop them from interfering with JekyllRdfs rendersystem
59
- return unless @complete
60
- load_prefixes_yaml()
61
- resource.page = self
62
- resource.site = site
63
- site.data['resources'] << resource
64
- end
65
- end
66
- end