jekyll-attendease 0.6.25k → 0.6.26a
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/attendease_plugin.rb +17 -0
- data/lib/jekyll/attendease_plugin/config_mixin.rb +17 -0
- data/lib/jekyll/attendease_plugin/event_data_generator.rb +101 -98
- data/lib/jekyll/attendease_plugin/organization_data_generator.rb +70 -0
- data/lib/jekyll/attendease_plugin/schedule_generator.rb +3 -1
- data/lib/jekyll/attendease_plugin/site_page_blocks_json.rb +42 -0
- data/lib/jekyll/attendease_plugin/site_pages_generator.rb +1 -1
- data/lib/jekyll/attendease_plugin/sponsor_generator.rb +4 -2
- data/lib/jekyll/attendease_plugin/version.rb +1 -1
- data/spec/lib/jekyll/attendease_plugin/event_data_generator_spec.rb +63 -43
- data/spec/lib/jekyll/attendease_plugin/event_layout_generator_spec.rb +3 -2
- data/spec/lib/jekyll/attendease_plugin/event_template_generator_spec.rb +23 -6
- data/spec/lib/jekyll/attendease_plugin/filters_spec.rb +5 -2
- data/spec/lib/jekyll/attendease_plugin/organization_data_generator_spec.rb +21 -0
- data/spec/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator_spec.rb +8 -8
- data/spec/lib/jekyll/attendease_plugin/schedule_generator_spec.rb +179 -142
- data/spec/lib/jekyll/attendease_plugin/site_page_spec.rb +3 -4
- data/spec/lib/jekyll/attendease_plugin/site_pages_generator_spec.rb +7 -10
- data/spec/lib/jekyll/attendease_plugin/sponsor_generator_spec.rb +13 -4
- data/spec/lib/jekyll/attendease_plugin/tags_spec.rb +3 -2
- data/spec/spec_helper.rb +36 -28
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f7ec275ba6622c90c49c18db39852a3032e3ed4
|
4
|
+
data.tar.gz: 38745b2ee3b79e571d6265ad8bd87f4827d82dc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62bd5a95f025116b9ad7187ff9c97e8f8de41544d959c2a40269a5a90ade37bba85c43d5eae67c03fb7fa657dab77fa90deeb8db1c507e36d835c59460a2e34b
|
7
|
+
data.tar.gz: f4eeb02f714ca86f635be3aafc2c7abc5ba890f96b455a2db88771e5d13a70784e892f0fb87c9854133d1fd159d543f01d69d59ca1c818193d766881fbcbda52
|
@@ -3,6 +3,7 @@ require 'jekyll/attendease_plugin/schedule_data_parser'
|
|
3
3
|
|
4
4
|
# Generators:
|
5
5
|
require 'jekyll/attendease_plugin/event_data_generator'
|
6
|
+
require 'jekyll/attendease_plugin/organization_data_generator'
|
6
7
|
require 'jekyll/attendease_plugin/event_layout_generator'
|
7
8
|
require 'jekyll/attendease_plugin/event_template_generator'
|
8
9
|
require 'jekyll/attendease_plugin/home_page_generator'
|
@@ -35,3 +36,19 @@ require 'jekyll/attendease_plugin/site_page'
|
|
35
36
|
|
36
37
|
# Ve.rs.ion
|
37
38
|
require 'jekyll/attendease_plugin/version'
|
39
|
+
|
40
|
+
# Register our config hook
|
41
|
+
require 'jekyll/attendease_plugin/config_mixin'
|
42
|
+
|
43
|
+
Jekyll::Hooks.register :site, :after_reset do |site|
|
44
|
+
default = YAML.load_file(File.join(File.expand_path(File.dirname(__FILE__)), 'attendease_plugin', '_config.yaml'))
|
45
|
+
|
46
|
+
site.config['attendease'] = site.config['attendease'].nil? ? default : Jekyll::Utils.deep_merge_hashes(default['attendease'], site.config['attendease'])
|
47
|
+
|
48
|
+
site.config.extend(AttendeaseJekyllConfigMixin)
|
49
|
+
|
50
|
+
if site.config.attendease['api_host'].nil?
|
51
|
+
raise 'Fatal: You must configure attendease:api_host in your _config.yml to point to the API host of your event or organization.'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AttendeaseJekyllConfigMixin
|
2
|
+
def attendease
|
3
|
+
self['attendease']
|
4
|
+
end
|
5
|
+
|
6
|
+
def event?
|
7
|
+
attendease['mode'] == 'event'
|
8
|
+
end
|
9
|
+
|
10
|
+
def organization?
|
11
|
+
attendease['mode'] == 'organization'
|
12
|
+
end
|
13
|
+
|
14
|
+
def cms_theme?
|
15
|
+
attendease['jekyll33'] == true
|
16
|
+
end
|
17
|
+
end
|
@@ -16,107 +16,113 @@ module Jekyll
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def use_cache?(file)
|
20
|
-
(Time.now.to_i - File.mtime(file).to_i) <= (
|
19
|
+
def use_cache?(site, file)
|
20
|
+
(Time.now.to_i - File.mtime(file).to_i) <= (site.config.attendease['cache_expiry'].nil? ? 30 : site.config.attendease['cache_expiry']) # file is less than 30 seconds old
|
21
21
|
end
|
22
22
|
|
23
23
|
def generate(site)
|
24
|
-
if
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
return if site.config.organization?
|
25
|
+
|
26
|
+
if site.config.attendease['api_host'] && !site.config.attendease['api_host'].match(/^https/)
|
27
|
+
raise "Is your Attendease api_host site properly in _config.yml? Needs to be something like https://myevent.attendease.com/"
|
28
|
+
else
|
29
|
+
# add a trailing slash if we are missing one.
|
30
|
+
if site.config.attendease['api_host'][-1, 1] != '/'
|
31
|
+
site.config.attendease['api_host'] += '/'
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
+
@attendease_data_path = File.join(site.source, '_attendease', 'data')
|
34
35
|
|
35
|
-
|
36
|
+
FileUtils.mkdir_p(@attendease_data_path)
|
36
37
|
|
38
|
+
if site.config.cms_theme?
|
39
|
+
data_files = %w{ site event pages site_settings }.map { |m| "#{m}.json"} << 'lingo.yml'
|
40
|
+
else
|
37
41
|
data_files = %w{ site event sessions presenters rooms filters venues sponsors pages site_settings }.map { |m| "#{m}.json"} << 'lingo.yml'
|
42
|
+
end
|
38
43
|
|
39
|
-
|
40
|
-
|
44
|
+
# no more site in nextgen themes
|
45
|
+
#data_files.shift if site.config.attendease['jekyll33']
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
data_files.each do |filename|
|
48
|
+
update_data = true
|
49
|
+
data = nil
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
file = File.join(@attendease_data_path, filename)
|
52
|
+
if File.exists?(file) && use_cache?(site, file)
|
53
|
+
update_data = false
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
else
|
57
|
-
data = File.read(file)
|
55
|
+
if filename.match(/json$/)
|
56
|
+
begin
|
57
|
+
data = JSON.parse(File.read(file))
|
58
|
+
rescue => e
|
59
|
+
raise "Error parsing #{file}: #{e.inspect}"
|
58
60
|
end
|
61
|
+
else
|
62
|
+
data = File.read(file)
|
59
63
|
end
|
64
|
+
end
|
60
65
|
|
61
|
-
|
66
|
+
key = "has_#{filename.split('.')[0]}"
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
# don't bother making a request for resources that don't exist in the event
|
69
|
+
if !site.config.attendease[key].nil? && !site.config.attendease[key]
|
70
|
+
update_data = false
|
71
|
+
data = []
|
72
|
+
end
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
if update_data
|
75
|
+
options = {}
|
76
|
+
options.merge!(:headers => {'X-Event-Token' => site.config.attendease['access_token']}) if site.config.attendease['access_token']
|
72
77
|
|
73
|
-
|
74
|
-
|
78
|
+
request_filename = filename.gsub(/yml$/, 'yaml')
|
79
|
+
response = get("#{site.config.attendease['api_host']}api/#{request_filename}?meta=true", options)
|
75
80
|
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
#if (filename.match(/yaml$/) || data.is_a?(Hash) && !data['error']) || data.is_a?(Array)
|
82
|
+
if (!response.nil? && response.response.is_a?(Net::HTTPOK))
|
83
|
+
Jekyll.logger.info "[Attendease] Saving #{filename} data..."
|
79
84
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
else
|
87
|
-
raise "Request failed for #{@attendease_config['api_host']}api/#{request_filename}. Is your Attendease api_host site properly in _config.yml?"
|
85
|
+
if filename.match(/json$/)
|
86
|
+
data = response.parsed_response
|
87
|
+
File.open(file, 'w') { |f| f.write(data.to_json) }
|
88
|
+
else # yaml
|
89
|
+
File.open(file, 'w') { |f| f.write(response.body) }
|
88
90
|
end
|
91
|
+
else
|
92
|
+
raise "Request failed for #{site.config.attendease['api_host']}api/#{request_filename}. Is your Attendease api_host site properly in _config.yml?"
|
89
93
|
end
|
94
|
+
end
|
90
95
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
96
|
+
# make this data available to anything that wants it
|
97
|
+
site.config['attendease'][File.basename(filename, '.*')] = data
|
98
|
+
site.data[File.basename(filename, '.*')] = data
|
99
|
+
|
100
|
+
if data.is_a?(Hash)
|
101
|
+
if filename == 'site.json'
|
102
|
+
# Adding to site config so we can access these variables globally wihtout using a Liquid Tag so we can use if/else
|
103
|
+
site.config['attendease']['data'] = {}
|
104
|
+
|
105
|
+
data.keys.each do |tag|
|
106
|
+
site.config['attendease']['data'][tag] = data[tag]
|
107
|
+
# memorandum from the department of redundancy department:
|
108
|
+
# --------------------------------------------------------
|
109
|
+
# support accessing the attendease_* variables without the
|
110
|
+
# attendease_ prefix because they're already namespaced in
|
111
|
+
# site.attendease.data
|
112
|
+
#
|
113
|
+
# TODO: update all themes to not use attendease_ variables
|
114
|
+
# and then retire them from the ThemeManager.
|
115
|
+
if tag.match(/^attendease_/)
|
116
|
+
site.config['attendease']['data'][tag.gsub(/^attendease_/, '')] = data[tag]
|
113
117
|
end
|
114
118
|
end
|
115
119
|
end
|
116
120
|
end
|
121
|
+
end
|
117
122
|
|
118
|
-
|
119
|
-
|
123
|
+
# provide a structure of session instances (timeslots) grouped
|
124
|
+
# by day (suitable for displaying a schedule)
|
125
|
+
unless site.config.cms_theme?
|
120
126
|
site.config['attendease']['days'] = []
|
121
127
|
schedule_data = ScheduleDataParser.new(site)
|
122
128
|
site.config['attendease']['event']['dates'].each do |day|
|
@@ -133,34 +139,31 @@ module Jekyll
|
|
133
139
|
day['instances'] = instances.sort {|x,y| [x['time'], x['session']['name']] <=> [y['time'], y['session']['name']]}
|
134
140
|
site.config['attendease']['days'] << day
|
135
141
|
end
|
142
|
+
end
|
136
143
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
144
|
+
# make the event available to anyone
|
145
|
+
event = JSON.parse(File.read("#{@attendease_data_path}/event.json"))
|
146
|
+
site.config['attendease']['event'] = event
|
147
|
+
|
148
|
+
if site.config.attendease['copy_data']
|
149
|
+
data_dir = File.join(site.source, 'attendease_data')
|
150
|
+
FileUtils.mkdir(data_dir) unless File.exists?(data_dir)
|
151
|
+
site.config['attendease']['data_files'] = {}
|
152
|
+
|
153
|
+
Dir.chdir(@attendease_data_path) do
|
154
|
+
extension = '.json'
|
155
|
+
Dir.glob('*.json').each do |f|
|
156
|
+
base_name = File.basename(f, extension)
|
157
|
+
digest = Digest::SHA2.file(f).hexdigest
|
158
|
+
digest_file = "#{base_name}-#{digest}.json"
|
159
|
+
FileUtils.cp(f, File.join(data_dir, digest_file))
|
160
|
+
site.config['attendease']['data_files'][base_name] = digest_file
|
155
161
|
end
|
156
|
-
|
157
|
-
# tell Jekyll about these new static files to publish
|
158
|
-
site.reader.read_directories 'attendease_data'
|
159
162
|
end
|
160
|
-
end
|
161
163
|
|
162
|
-
|
163
|
-
|
164
|
+
# tell Jekyll about these new static files to publish
|
165
|
+
site.reader.read_directories 'attendease_data'
|
166
|
+
end
|
164
167
|
end
|
165
168
|
end
|
166
169
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class OrganizationDataGenerator < EventDataGenerator
|
4
|
+
priority :highest
|
5
|
+
|
6
|
+
def generate(site)
|
7
|
+
return unless site.config.organization? && site.config.cms_theme?
|
8
|
+
|
9
|
+
if site.config.attendease['api_host'] && !site.config.attendease['api_host'].match(/^https/)
|
10
|
+
raise "Is your Attendease api_host site properly in _config.yml? Needs to be something like https://myorg.attendease.org/"
|
11
|
+
else
|
12
|
+
# add a trailing slash if we are missing one.
|
13
|
+
if site.config.attendease['api_host'][-1, 1] != '/'
|
14
|
+
site.config.attendease['api_host'] += '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
@attendease_data_path = File.join(site.source, '_attendease', 'data')
|
18
|
+
|
19
|
+
FileUtils.mkdir_p(@attendease_data_path) unless File.exists?(@attendease_data_path)
|
20
|
+
|
21
|
+
data_files = %w{ pages site_settings }.map { |m| "#{m}.json"}
|
22
|
+
|
23
|
+
data_files.each do |filename|
|
24
|
+
update_data = true
|
25
|
+
data = nil
|
26
|
+
|
27
|
+
file = File.join(@attendease_data_path, filename)
|
28
|
+
if File.exists?(file) && use_cache?(site, file)
|
29
|
+
update_data = false
|
30
|
+
|
31
|
+
if filename.match(/json$/)
|
32
|
+
begin
|
33
|
+
data = JSON.parse(File.read(file))
|
34
|
+
rescue => e
|
35
|
+
raise "Error parsing #{file}: #{e.inspect}"
|
36
|
+
end
|
37
|
+
else
|
38
|
+
data = File.read(file)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if update_data
|
43
|
+
options = {}
|
44
|
+
options.merge!(:headers => {'X-Organization-Token' => site.config.attendease['access_token']}) if site.config.attendease['access_token']
|
45
|
+
|
46
|
+
response = get("#{site.config.attendease['api_host']}api/v2/#{filename}", options)
|
47
|
+
|
48
|
+
if (!response.nil? && response.response.is_a?(Net::HTTPOK))
|
49
|
+
Jekyll.logger.info "[Attendease] Saving #{filename} data..."
|
50
|
+
|
51
|
+
if filename.match(/json$/)
|
52
|
+
data = response.parsed_response
|
53
|
+
File.open(file, 'w') { |f| f.write(data.to_json) }
|
54
|
+
else # yaml
|
55
|
+
File.open(file, 'w') { |f| f.write(response.body) }
|
56
|
+
end
|
57
|
+
else
|
58
|
+
raise "Request failed for #{site.config.attendease['api_host']}api/v2/#{filename}. Is your Attendease api_host site properly in _config.yml?"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
site.data[File.basename(filename, '.*')] = data
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
@@ -6,7 +6,9 @@ module Jekyll
|
|
6
6
|
attr_reader :schedule_data
|
7
7
|
|
8
8
|
def generate(site)
|
9
|
-
if site.config
|
9
|
+
return if !site.config.event? || (site.config.event? && site.config.cms_theme?)
|
10
|
+
|
11
|
+
if site.config['attendease']['api_host'] && site.config['attendease']['generate_schedule_pages']
|
10
12
|
|
11
13
|
@schedule_data = ScheduleDataParser.new(site)
|
12
14
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class SitePageBlocksJson < StaticFile
|
4
|
+
def initialize(site, base, page)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = page['slug']
|
8
|
+
@name = 'index.json'
|
9
|
+
|
10
|
+
self.process(@name)
|
11
|
+
|
12
|
+
#require 'pry'
|
13
|
+
#binding.pry
|
14
|
+
#self.read_yaml(File.join(base, '_attendease', 'templates', 'pages'), 'default.html')
|
15
|
+
self.read_yaml(File.join(base, '_layouts'), "#{page['layout']}.html")
|
16
|
+
|
17
|
+
self.data['title'] = page['title']
|
18
|
+
self.data['layout'] = page['layout']
|
19
|
+
|
20
|
+
zones = {}
|
21
|
+
|
22
|
+
# create zone buckets
|
23
|
+
page['block_instances'].each do |i|
|
24
|
+
zones[i['zone']] = [] if zones[i['zone']].nil?
|
25
|
+
zones[i['zone']] << i
|
26
|
+
end
|
27
|
+
|
28
|
+
# sort each bucket by widget weight
|
29
|
+
zones.each do |k, zone|
|
30
|
+
zone.sort! { |x, y| x['weight'] <=> y['weight'] }
|
31
|
+
self.data[k] = ''
|
32
|
+
zone.each do |i|
|
33
|
+
self.data[k] << i['rendered_html']
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
self.data['site_page'] = page
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -4,10 +4,12 @@ module Jekyll
|
|
4
4
|
safe true
|
5
5
|
|
6
6
|
def generate(site)
|
7
|
+
return if !site.config.event? || (site.config.event? && site.config.cms_theme?)
|
8
|
+
|
7
9
|
if site.config['attendease']['has_sponsors'] && site.config['attendease']['generate_sponsor_pages']
|
8
10
|
sponsors = site.data['sponsors']
|
11
|
+
sponsor_levels = site.data['event']['sponsor_levels']
|
9
12
|
|
10
|
-
sponsor_levels = site.config['attendease']['event']['sponsor_levels']
|
11
13
|
sponsor_levels.each do |level|
|
12
14
|
level['sponsors'] = []
|
13
15
|
end
|
@@ -22,7 +24,7 @@ module Jekyll
|
|
22
24
|
end
|
23
25
|
|
24
26
|
# make this available to any page that wants it
|
25
|
-
site.
|
27
|
+
site.data['sponsor_levels'] = sponsor_levels
|
26
28
|
|
27
29
|
# /sponsors pages.
|
28
30
|
dir = site.config['attendease']['sponsors_path_name']
|