jekyll-attendease 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/attendease_plugin.rb +1 -0
- data/lib/jekyll/attendease_plugin/config_mixin.rb +4 -0
- data/lib/jekyll/attendease_plugin/site_page_data.rb +106 -0
- data/lib/jekyll/attendease_plugin/site_pages_generator.rb +1 -77
- data/lib/jekyll/attendease_plugin/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5a69a540b248bf67785ce3845b8a6e1230fed2
|
4
|
+
data.tar.gz: 3c96284cfdc27734e9497b149d8b4dadaa421a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 420ffd467a791c03541a344c2e47d4c6dd726e82e3212ee0bf49ac458ba4ad66b2639473941eb42475a58d04d57c7eab79ec654aaf29565b3b24702e7ddd48bd
|
7
|
+
data.tar.gz: 7508996f41f5fb93879e74666de9ae269d1855825fda2da77c6b867cd09fcfcb66f354b94c3af940a3176763d21d260256f8053ab91c41b8e7a5503224f293b0
|
@@ -33,6 +33,7 @@ require 'jekyll/attendease_plugin/sponsors_index_page'
|
|
33
33
|
require 'jekyll/attendease_plugin/venues_index_page'
|
34
34
|
require 'jekyll/attendease_plugin/venue_page'
|
35
35
|
require 'jekyll/attendease_plugin/site_page'
|
36
|
+
require 'jekyll/attendease_plugin/site_page_data'
|
36
37
|
|
37
38
|
# Ve.rs.ion
|
38
39
|
require 'jekyll/attendease_plugin/version'
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class SitePageData < Page
|
4
|
+
attr_reader :page
|
5
|
+
attr_reader :site
|
6
|
+
|
7
|
+
PLACEHOLDER_REGEX = /\{\{/.freeze
|
8
|
+
|
9
|
+
def initialize(site, base, page, private_site)
|
10
|
+
@site = site
|
11
|
+
@base = base
|
12
|
+
@dir = page['slug']
|
13
|
+
@page = page
|
14
|
+
@name = "index#{private_site ? '-private' : ''}.json"
|
15
|
+
|
16
|
+
# The Jekyll::Regenerator expects data to exist and crashes without it.
|
17
|
+
# https://github.com/jekyll/jekyll/blob/v3.3.1/lib/jekyll/regenerator.rb#L166
|
18
|
+
@data = {}
|
19
|
+
|
20
|
+
self.process(@name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_with_liquid?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def place_in_layout?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
# Override the accessor:
|
32
|
+
#
|
33
|
+
# https://github.com/jekyll/jekyll/blob/v3.3.1/lib/jekyll/renderer.rb#L78
|
34
|
+
#
|
35
|
+
# The Jekyll::Rendereer calls document.content, so this seems like the
|
36
|
+
# best way to set our "page" content with what we want.
|
37
|
+
#
|
38
|
+
def content
|
39
|
+
zones = {}
|
40
|
+
keys = %w[content preferences]
|
41
|
+
|
42
|
+
if page['block_instances'].length
|
43
|
+
# create zone buckets
|
44
|
+
page['block_instances'].each do |i|
|
45
|
+
# go through all content
|
46
|
+
if site.config.event?
|
47
|
+
keys.each do |key|
|
48
|
+
i[key].each do |k, v|
|
49
|
+
if placeholder?(v)
|
50
|
+
# maintain the {{ t.foo }} variables
|
51
|
+
v.gsub!(/(\{\{\s*t\.[a-z_.]+\s*\}\})/, '{% raw %}\1{% endraw %}')
|
52
|
+
i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
unless site.data['mappable'].nil? || site.data['mappable'].empty?
|
58
|
+
perform_substitution!(i, 'mappable' => site.data['mappable'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
zones[i['zone']] = [] if zones[i['zone']].nil?
|
63
|
+
zones[i['zone']] << i
|
64
|
+
end
|
65
|
+
|
66
|
+
# sort each bucket by widget weight
|
67
|
+
zones.each do |k, zone|
|
68
|
+
zone.sort! { |x, y| x['weight'] <=> y['weight'] }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
zones.to_json
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def perform_substitution!(object, substitution_lookup)
|
78
|
+
if object.is_a?(Hash)
|
79
|
+
object.each_pair do |k, v|
|
80
|
+
if placeholder?(v)
|
81
|
+
object[k] = render_with_substitutions(v, substitution_lookup)
|
82
|
+
else
|
83
|
+
perform_substitution!(v, substitution_lookup)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
elsif object.is_a?(Array)
|
87
|
+
object.each_with_index do |e, i|
|
88
|
+
if placeholder?(e)
|
89
|
+
object[i] = render_with_substitutions(e, substitution_lookup)
|
90
|
+
else
|
91
|
+
perform_substitution!(e, substitution_lookup)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def placeholder?(object)
|
98
|
+
object.is_a?(String) && object =~ PLACEHOLDER_REGEX
|
99
|
+
end
|
100
|
+
|
101
|
+
def render_with_substitutions(template_string, substitution_lookup)
|
102
|
+
Liquid::Template.parse(template_string).render(substitution_lookup)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -2,8 +2,6 @@ module Jekyll
|
|
2
2
|
module AttendeasePlugin
|
3
3
|
class SitePagesGenerator < Generator
|
4
4
|
safe true
|
5
|
-
PLACEHOLDER_REGEX = /\{\{/.freeze
|
6
|
-
|
7
5
|
# site.config:
|
8
6
|
# Is where you can find the configs generated for your site
|
9
7
|
# To check the structure sample go in your vagrant to
|
@@ -15,84 +13,10 @@ module Jekyll
|
|
15
13
|
|
16
14
|
page['name'] = CGI.escapeHTML(page['name']) if page['name']
|
17
15
|
site.pages << SitePage.new(site, site.source, page)
|
18
|
-
|
19
|
-
zones = {}
|
20
|
-
keys = %w[content preferences]
|
21
|
-
|
22
|
-
if page['block_instances'].length
|
23
|
-
# create zone buckets
|
24
|
-
page['block_instances'].each do |i|
|
25
|
-
# go through all content
|
26
|
-
if site.config.event?
|
27
|
-
keys.each do |key|
|
28
|
-
i[key].each do |k, v|
|
29
|
-
if placeholder?(v)
|
30
|
-
# maintain the {{ t.foo }} variables
|
31
|
-
v.gsub!(/(\{\{\s*t\.[a-z_.]+\s*\}\})/, '{% raw %}\1{% endraw %}')
|
32
|
-
i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
unless site.data['mappable'].nil? || site.data['mappable'].empty?
|
38
|
-
perform_substitution!(i, 'mappable' => site.data['mappable'])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
zones[i['zone']] = [] if zones[i['zone']].nil?
|
43
|
-
zones[i['zone']] << i
|
44
|
-
end
|
45
|
-
|
46
|
-
# sort each bucket by widget weight
|
47
|
-
zones.each do |k, zone|
|
48
|
-
zone.sort! { |x, y| x['weight'] <=> y['weight'] }
|
49
|
-
end
|
50
|
-
|
51
|
-
page_source_path = File.join(site.source, page['slug'])
|
52
|
-
FileUtils.mkdir_p(page_source_path) unless File.exists?(page_source_path)
|
53
|
-
|
54
|
-
json_filename = site.config.attendease['private_site'] ? 'index-private.json' : 'index.json'
|
55
|
-
|
56
|
-
File.open(File.join(page_source_path, json_filename), 'w') do |f|
|
57
|
-
f.write zones.to_json
|
58
|
-
f.close
|
59
|
-
end
|
60
|
-
|
61
|
-
site.static_files << StaticFile.new(site, site.source, File.join('', page['slug']), json_filename)
|
62
|
-
end
|
16
|
+
site.pages << SitePageData.new(site, site.source, page, site.config.private_site?)
|
63
17
|
end
|
64
18
|
end
|
65
19
|
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def perform_substitution!(object, substitution_lookup)
|
70
|
-
if object.is_a?(Hash)
|
71
|
-
object.each_pair do |k, v|
|
72
|
-
if placeholder?(v)
|
73
|
-
object[k] = render_with_substitutions(v, substitution_lookup)
|
74
|
-
else
|
75
|
-
perform_substitution!(v, substitution_lookup)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
elsif object.is_a?(Array)
|
79
|
-
object.each_with_index do |e, i|
|
80
|
-
if placeholder?(e)
|
81
|
-
object[i] = render_with_substitutions(e, substitution_lookup)
|
82
|
-
else
|
83
|
-
perform_substitution!(e, substitution_lookup)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def placeholder?(object)
|
90
|
-
object.is_a?(String) && object =~ PLACEHOLDER_REGEX
|
91
|
-
end
|
92
|
-
|
93
|
-
def render_with_substitutions(template_string, substitution_lookup)
|
94
|
-
Liquid::Template.parse(template_string).render(substitution_lookup)
|
95
|
-
end
|
96
20
|
end
|
97
21
|
end
|
98
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-attendease
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Wood
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/jekyll/attendease_plugin/schedule_session_page.rb
|
185
185
|
- lib/jekyll/attendease_plugin/schedule_sessions_page.rb
|
186
186
|
- lib/jekyll/attendease_plugin/site_page.rb
|
187
|
+
- lib/jekyll/attendease_plugin/site_page_data.rb
|
187
188
|
- lib/jekyll/attendease_plugin/site_pages_generator.rb
|
188
189
|
- lib/jekyll/attendease_plugin/sponsor_generator.rb
|
189
190
|
- lib/jekyll/attendease_plugin/sponsors_index_page.rb
|