jekyll-attendease 0.5.5 → 0.6.0
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.rb +9 -705
- data/lib/jekyll/attendease_plugin.rb +19 -0
- data/lib/jekyll/attendease_plugin/event_data_generator.rb +154 -0
- data/lib/jekyll/attendease_plugin/event_layout_generator.rb +43 -0
- data/lib/jekyll/attendease_plugin/filters.rb +9 -0
- data/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator.rb +35 -0
- data/lib/jekyll/attendease_plugin/presenter_page.rb +31 -0
- data/lib/jekyll/attendease_plugin/presenters_index_page.rb +23 -0
- data/lib/jekyll/attendease_plugin/redirect_page.rb +22 -0
- data/lib/jekyll/attendease_plugin/schedule_day_page.rb +38 -0
- data/lib/jekyll/attendease_plugin/schedule_generator.rb +156 -0
- data/lib/jekyll/attendease_plugin/schedule_index_page.rb +23 -0
- data/lib/jekyll/attendease_plugin/schedule_session_page.rb +24 -0
- data/lib/jekyll/attendease_plugin/schedule_sessions_page.rb +26 -0
- data/lib/jekyll/attendease_plugin/sponsor_generator.rb +37 -0
- data/lib/jekyll/attendease_plugin/sponsors_index_page.rb +23 -0
- data/lib/jekyll/attendease_plugin/tags.rb +65 -0
- data/lib/jekyll/attendease_plugin/venue_page.rb +24 -0
- data/lib/jekyll/attendease_plugin/venues_index_page.rb +23 -0
- data/lib/jekyll/attendease_plugin/version.rb +6 -0
- data/spec/lib/jekyll/attendease_plugin/event_data_generator_spec.rb +16 -0
- data/spec/lib/jekyll/attendease_plugin/event_layout_generator_spec.rb +12 -0
- data/spec/lib/jekyll/attendease_plugin/filters_spec.rb +15 -0
- data/spec/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator_spec.rb +40 -0
- data/spec/lib/jekyll/attendease_plugin/schedule_generator_spec.rb +104 -0
- data/spec/lib/jekyll/attendease_plugin/sponsor_generator_spec.rb +12 -0
- data/spec/lib/jekyll/attendease_plugin/tags_spec.rb +45 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/support/fixtures_helpers.rb +7 -0
- data/templates/_includes/attendease/presenters/index.html +2 -2
- data/templates/_includes/attendease/presenters/presenter.html +3 -3
- data/templates/_includes/attendease/redirect.html +12 -0
- data/templates/_includes/attendease/schedule/day.html +5 -5
- data/templates/_includes/attendease/schedule/index.html +3 -3
- data/templates/_includes/attendease/schedule/session.html +3 -3
- data/templates/_includes/attendease/schedule/sessions.html +3 -3
- data/templates/_includes/attendease/sponsors/index.html +14 -3
- data/templates/layout.html +1 -1
- metadata +113 -20
- data/README.md +0 -181
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cd553e269268d96d6e3d33d06be1d4b80a36f0
|
4
|
+
data.tar.gz: 1d431f5ea201940d4c49417bc2fc5d6385d7b6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f860101c55c37f8c446edc468517f21a0e05ec2fd87c92a968c0a3de76f12ca64790502116d3cba71fc40901fee65f546eaed46b59a8e263c2e121541146b7b
|
7
|
+
data.tar.gz: b08a45e2f9b07ce9cd974cd3d4362929068c56379eb92042418765ce1637dadd6e30ef5c7edc0d2667d2bd9b6ab408fbf4f78f19a2fadd360ac35ef9e1551bd7
|
data/lib/jekyll-attendease.rb
CHANGED
@@ -1,711 +1,15 @@
|
|
1
|
+
require 'jekyll'
|
1
2
|
require 'httparty'
|
2
3
|
require 'json'
|
3
4
|
require 'i18n'
|
4
5
|
|
5
|
-
|
6
|
-
module Attendease
|
6
|
+
require 'jekyll/attendease_plugin'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
Liquid::Template.register_tag('attendease_auth_script', Jekyll::AttendeasePlugin::AuthScriptTag)
|
9
|
+
Liquid::Template.register_tag('attendease_scheduler_script', Jekyll::AttendeasePlugin::SchedulerScriptTag)
|
10
|
+
Liquid::Template.register_tag('attendease_locales_script', Jekyll::AttendeasePlugin::LocalesScriptTag)
|
11
|
+
Liquid::Template.register_tag('attendease_auth_account', Jekyll::AttendeasePlugin::AuthAccountTag)
|
12
|
+
Liquid::Template.register_tag('attendease_auth_action', Jekyll::AttendeasePlugin::AuthActionTag)
|
13
|
+
Liquid::Template.register_tag('t', Jekyll::AttendeasePlugin::TranslateTag)
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
include HTTParty
|
14
|
-
|
15
|
-
def get(url, options = {})
|
16
|
-
begin
|
17
|
-
self.class.get(url, options)
|
18
|
-
rescue => e
|
19
|
-
puts "Could not connect to #{url}."
|
20
|
-
puts e.inspect
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.parameterize(source, sep = '-')
|
25
|
-
return '' if source.nil?
|
26
|
-
string = source.downcase
|
27
|
-
# Turn unwanted chars into the separator
|
28
|
-
string.gsub!(/[^a-z0-9\-_]+/, sep)
|
29
|
-
unless sep.nil? || sep.empty?
|
30
|
-
re_sep = Regexp.escape(sep)
|
31
|
-
# No more than one of the separator in a row.
|
32
|
-
string.gsub!(/#{re_sep}{2,}/, sep)
|
33
|
-
# Remove leading/trailing separator.
|
34
|
-
string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
|
35
|
-
end
|
36
|
-
string
|
37
|
-
end
|
38
|
-
|
39
|
-
def generate(site)
|
40
|
-
if @attendease_config = site.config['attendease']
|
41
|
-
if @attendease_config['api_host'] && !@attendease_config['api_host'].match(/^http/)
|
42
|
-
raise "Is your Attendease api_host site properly in _config.yml? Needs to be something like https://myevent.attendease.com/"
|
43
|
-
else
|
44
|
-
# add a trailing slash if we are missing one.
|
45
|
-
if @attendease_config['api_host'][-1, 1] != '/'
|
46
|
-
@attendease_config['api_host'] += '/'
|
47
|
-
end
|
48
|
-
|
49
|
-
@attendease_data_path = "#{site.source}/_attendease_data"
|
50
|
-
|
51
|
-
FileUtils.mkdir_p(@attendease_data_path)
|
52
|
-
|
53
|
-
data_files = ['site.json', 'event.json', 'sessions.json', 'presenters.json', 'rooms.json', 'filters.json', 'venues.json', 'sponsors.json', 'lingo.yml']
|
54
|
-
|
55
|
-
data_files.each do |file_name|
|
56
|
-
update_data = true
|
57
|
-
|
58
|
-
if File.exists?("#{@attendease_data_path}/#{file_name}")
|
59
|
-
if (Time.now.to_i - File.mtime("#{@attendease_data_path}/#{file_name}").to_i) <= (@attendease_config['cache_expiry'].nil? ? 30 : @attendease_config['cache_expiry']) # file is less than 30 seconds old
|
60
|
-
update_data = false
|
61
|
-
|
62
|
-
if file_name.match(/json$/)
|
63
|
-
json = File.read("#{@attendease_data_path}/#{file_name}")
|
64
|
-
|
65
|
-
data = JSON.parse(json)
|
66
|
-
else
|
67
|
-
data = File.read("#{@attendease_data_path}/#{file_name}")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
key = "has_#{file_name.split('.')[0]}"
|
73
|
-
|
74
|
-
# don't bother making a request for resources that don't exist in the event
|
75
|
-
if !@attendease_config[key].nil? && !@attendease_config[key]
|
76
|
-
update_data = false
|
77
|
-
data = []
|
78
|
-
end
|
79
|
-
|
80
|
-
if update_data
|
81
|
-
options = {}
|
82
|
-
options.merge!(:headers => {'X-Event-Token' => @attendease_config['access_token']}) if @attendease_config['access_token']
|
83
|
-
|
84
|
-
request_filename = file_name.gsub(/yml$/, 'yaml')
|
85
|
-
data = get("#{@attendease_config['api_host']}api/#{request_filename}", options)
|
86
|
-
|
87
|
-
#if (file_name.match(/yaml$/) || data.is_a?(Hash) && !data['error']) || data.is_a?(Array)
|
88
|
-
if (data.response.is_a?(Net::HTTPOK))
|
89
|
-
puts "" if file_name == 'site.json' # leading space, that's all.
|
90
|
-
puts "[Attendease] Saving #{file_name} data..."
|
91
|
-
|
92
|
-
|
93
|
-
if file_name.match(/json$/)
|
94
|
-
File.open("#{@attendease_data_path}/#{file_name}", 'w+') { |file| file.write(data.parsed_response.to_json) }
|
95
|
-
else
|
96
|
-
File.open("#{@attendease_data_path}/#{file_name}", 'w+') { |file| file.write(data.body) }
|
97
|
-
end
|
98
|
-
else
|
99
|
-
raise "Request failed for #{@attendease_config['api_host']}api/#{request_filename}. Is your Attendease api_host site properly in _config.yml?"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
if file_name == 'site.json'
|
104
|
-
# Adding to site config so we can access these variables globally wihtout using a Liquid Tag so we can use if/else
|
105
|
-
site.config['attendease']['data'] = {}
|
106
|
-
|
107
|
-
data.keys.each do |tag|
|
108
|
-
site.config['attendease']['data'][tag] = data[tag]
|
109
|
-
# memorandum from the department of redundancy department:
|
110
|
-
# --------------------------------------------------------
|
111
|
-
# support accessing the attendease_* variables without the
|
112
|
-
# attendease_ prefix because they're already namespaced in
|
113
|
-
# site.attendease.data
|
114
|
-
if tag.match(/^attendease_/)
|
115
|
-
site.config['attendease']['data'][tag.gsub(/^attendease_/, '')] = data[tag]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
elsif file_name == 'event.json'
|
119
|
-
site.config['attendease']['event'] = {}
|
120
|
-
|
121
|
-
data.keys.each do |tag|
|
122
|
-
site.config['attendease']['event'][tag] = data[tag]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
event = JSON.parse(File.read("#{@attendease_data_path}/event.json"))
|
128
|
-
|
129
|
-
#sessions = JSON.parse(File.read("#{@attendease_data_path}/sessions.json")).sort{|s1, s2| s1['name'] <=> s2['name']}
|
130
|
-
#presenters = JSON.parse(File.read("#{@attendease_data_path}/presenters.json")).sort{|p1, p2| p1['last_name'] <=> p2['last_name']}
|
131
|
-
#rooms = JSON.parse(File.read("#{@attendease_data_path}/rooms.json")).sort{|r1, r2| r1['name'] <=> r2['name']}
|
132
|
-
#filters = JSON.parse(File.read("#{@attendease_data_path}/filters.json")).sort{|f1, f2| f1['name'] <=> f2['name']}
|
133
|
-
#venues = JSON.parse(File.read("#{@attendease_data_path}/venues.json")).sort{|v1, v2| v1['name'] <=> v2['name']}
|
134
|
-
if @attendease_config['has_sponsors']
|
135
|
-
sponsors = JSON.parse(File.read("#{@attendease_data_path}/sponsors.json"))
|
136
|
-
|
137
|
-
sponsor_levels = event['sponsor_levels']
|
138
|
-
sponsor_levels.each do |level|
|
139
|
-
level['sponsors'] = []
|
140
|
-
end
|
141
|
-
|
142
|
-
sponsors.each do |sponsor|
|
143
|
-
level = sponsor_levels.select { |m| m['_id'] == sponsor['level_id'] }.first
|
144
|
-
level['sponsors'] << sponsor
|
145
|
-
end
|
146
|
-
site.config['attendease']['sponsor_levels'] = sponsor_levels
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
else
|
151
|
-
raise "Please set the Attendease event data in your _config.yml"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
class EventThemes < Generator
|
157
|
-
safe true
|
158
|
-
|
159
|
-
priority :high
|
160
|
-
|
161
|
-
def generate(site)
|
162
|
-
puts "[Attendease] Generating theme layouts..."
|
163
|
-
|
164
|
-
attendease_precompiled_theme_layouts_path = "#{site.source}/attendease_layouts"
|
165
|
-
|
166
|
-
FileUtils.mkdir_p(attendease_precompiled_theme_layouts_path)
|
167
|
-
|
168
|
-
base_layout = (site.config['attendease'] && site.config['attendease']['base_layout']) ? site.config['attendease']['base_layout'] : 'layout'
|
169
|
-
|
170
|
-
layouts_to_precompile = ['layout', 'register', 'schedule', 'presenters', 'venues', 'sponsors']
|
171
|
-
|
172
|
-
# Precompiled layout for website sections.
|
173
|
-
layouts_to_precompile.each do |layout|
|
174
|
-
if File.exists?("#{site.source}/_layouts/#{base_layout}.html")
|
175
|
-
|
176
|
-
# create a layout file if it already doesn't exist.
|
177
|
-
# the layout file will be used by attendease to wrap /register, /schedule, /presnters in the
|
178
|
-
# look the compiled file defines.
|
179
|
-
# ensure {{ content }} is in the file so we can render content in there!
|
180
|
-
if !File.exists?("#{attendease_precompiled_theme_layouts_path}/#{layout}.html")
|
181
|
-
theme_layout_content = File.read("#{site.source}/_layouts/#{base_layout}.html")
|
182
|
-
File.open("#{site.source}/attendease_layouts/#{layout}.html", 'w+') { |file| file.write(theme_layout_content) }
|
183
|
-
site.pages << AttendeaseLayoutPage.new(site, site.source, 'attendease_layouts', "#{layout}.html", base_layout)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
class AttendeaseLayoutPage < Page
|
191
|
-
def initialize(site, base, dir, name, base_layout)
|
192
|
-
@site = site
|
193
|
-
@base = base
|
194
|
-
@dir = dir
|
195
|
-
@name = name
|
196
|
-
|
197
|
-
self.process(name)
|
198
|
-
|
199
|
-
self.read_yaml(File.expand_path(File.dirname(__FILE__) + "/../templates"), 'layout.html') # a template for the layout.
|
200
|
-
|
201
|
-
self.data['layout'] = base_layout
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
class AttendeaseAuthScriptTag < Liquid::Tag
|
206
|
-
def render(context)
|
207
|
-
api_host = context.registers[:site].config['attendease']['api_host']
|
208
|
-
'<script type="text/javascript" src="' + api_host + 'assets/attendease_event/auth.js"></script>'
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
class AttendeaseSchedulerScriptTag < Liquid::Tag
|
213
|
-
def render(context)
|
214
|
-
api_host = context.registers[:site].config['attendease']['api_host']
|
215
|
-
'<script type="text/javascript" src="' + api_host + 'assets/attendease_event/schedule.js"></script>'
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
class AttendeaseLocalesScriptTag < Liquid::Tag
|
220
|
-
def render(context)
|
221
|
-
'<script type="text/javascript">String.locale="en";String.toLocaleString("/api/lingo.json");</script>'
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
class AttendeaseTranslateTag < Liquid::Tag
|
226
|
-
def initialize(tag_name, params, tokens)
|
227
|
-
super
|
228
|
-
@args = split_params(params)
|
229
|
-
end
|
230
|
-
|
231
|
-
def split_params(params)
|
232
|
-
params.split(",").map(&:strip)
|
233
|
-
end
|
234
|
-
|
235
|
-
def render(context)
|
236
|
-
I18n::Backend::Simple.include(I18n::Backend::Pluralization)
|
237
|
-
I18n.enforce_available_locales = false
|
238
|
-
i18n_path = File.join(context.registers[:site].config['source'], '_attendease_data', 'lingo.yml')
|
239
|
-
I18n.load_path << i18n_path unless I18n.load_path.include?(i18n_path)
|
240
|
-
I18n.locale = context.registers[:page]['lang'] || context.registers[:site].config['attendease']['locale'] || context.registers[:site].config['attendease']['lang'] || :en
|
241
|
-
I18n.t(@args[0], :count => context['t_size'].nil? ? 0 : context['t_size'].to_i)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
class AttendeaseAuthAccountTag < Liquid::Tag
|
246
|
-
def render(context)
|
247
|
-
'<div id="attendease-auth-account"></div>'
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
class AttendeaseAuthActionTag < Liquid::Tag
|
252
|
-
def render(context)
|
253
|
-
'<div id="attendease-auth-action"></div>'
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
class AttendeaseContent < Liquid::Tag
|
258
|
-
def render(context)
|
259
|
-
"{{ content }}"
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
module Filters
|
264
|
-
def slugify(string)
|
265
|
-
EventData.parameterize(string, '_')
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
class ScheduleIndexPage < Page
|
270
|
-
def initialize(site, base, dir, dates)
|
271
|
-
@site = site
|
272
|
-
@base = base
|
273
|
-
@dir = dir
|
274
|
-
@name = 'index.html'
|
275
|
-
|
276
|
-
self.process(@name)
|
277
|
-
|
278
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
|
279
|
-
|
280
|
-
self.data['title'] = site.config['schedule_index_title_prefix'] || 'Schedule'
|
281
|
-
|
282
|
-
self.data['dates'] = dates
|
283
|
-
|
284
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'schedule', 'index.html'))
|
285
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'schedule', 'index.html')) # Use theme specific layout
|
286
|
-
else
|
287
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'schedule/index.html')) # Use template
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
class ScheduleDayPage < Page
|
293
|
-
def initialize(site, base, dir, day, sessions, dates)
|
294
|
-
@site = site
|
295
|
-
@base = base
|
296
|
-
@dir = dir
|
297
|
-
@name = 'index.html'
|
298
|
-
|
299
|
-
self.process(@name)
|
300
|
-
|
301
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
|
302
|
-
|
303
|
-
session_day_title_prefix = site.config['schedule_day_title_prefix'] || 'Schedule: '
|
304
|
-
self.data['title'] = "#{session_day_title_prefix}#{day['date_formatted']}"
|
305
|
-
|
306
|
-
self.data['day'] = day
|
307
|
-
self.data['dates'] = dates
|
308
|
-
|
309
|
-
instances = []
|
310
|
-
|
311
|
-
sessions.each do |s|
|
312
|
-
s['instances'].each do |instance|
|
313
|
-
if instance['date'] == day['date']
|
314
|
-
instance['session'] = s
|
315
|
-
|
316
|
-
instances << instance
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
self.data['instances'] = instances.sort{|x,y| [x['time'], x['session']['name']] <=> [y['time'], y['session']['name']]}
|
322
|
-
|
323
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'schedule', 'day.html'))
|
324
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'schedule', 'day.html')) # Use theme specific layout
|
325
|
-
else
|
326
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'schedule/day.html')) # Use template
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
class ScheduleSessionsPage < Page
|
332
|
-
def initialize(site, base, dir, sessions, dates)
|
333
|
-
@site = site
|
334
|
-
@base = base
|
335
|
-
@dir = dir
|
336
|
-
@name = 'index.html'
|
337
|
-
|
338
|
-
self.process(@name)
|
339
|
-
|
340
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
|
341
|
-
|
342
|
-
self.data['title'] = site.config['schedule_sessions_title'] || 'Schedule: Sessions'
|
343
|
-
|
344
|
-
sessionsData = []
|
345
|
-
|
346
|
-
self.data['sessions'] = sessions
|
347
|
-
self.data['dates'] = dates
|
348
|
-
|
349
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'schedule', 'sessions.html'))
|
350
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'schedule', 'sessions.html')) # Use theme specific layout
|
351
|
-
else
|
352
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'schedule/sessions.html')) # Use template
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
class ScheduleSessionPage < Page
|
358
|
-
def initialize(site, base, dir, session)
|
359
|
-
@site = site
|
360
|
-
@base = base
|
361
|
-
@dir = dir
|
362
|
-
@name = 'index.html'
|
363
|
-
|
364
|
-
self.process(@name)
|
365
|
-
|
366
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
|
367
|
-
|
368
|
-
schedule_session_page_title = site.config['schedule_session_page_title'] || 'Schedule: %s'
|
369
|
-
self.data['title'] = sprintf(schedule_session_page_title, session['name'])
|
370
|
-
|
371
|
-
self.data['session'] = session
|
372
|
-
|
373
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'schedule', 'session.html'))
|
374
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'schedule', 'session.html')) # Use theme specific layout
|
375
|
-
else
|
376
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'schedule/session.html')) # Use template
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
|
-
class PresentersIndexPage < Page
|
382
|
-
def initialize(site, base, dir, presenters)
|
383
|
-
@site = site
|
384
|
-
@base = base
|
385
|
-
@dir = dir
|
386
|
-
@name = 'index.html'
|
387
|
-
|
388
|
-
self.process(@name)
|
389
|
-
|
390
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'presenters.html')
|
391
|
-
|
392
|
-
self.data['title'] = site.config['presenters_index_title'] || 'Presenters'
|
393
|
-
|
394
|
-
self.data['presenters'] = presenters
|
395
|
-
|
396
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'presenters', 'index.html'))
|
397
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'presenters', 'index.html')) # Use theme specific layout
|
398
|
-
else
|
399
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'presenters/index.html')) # Use template
|
400
|
-
end
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
class PresenterPage < Page
|
405
|
-
def initialize(site, base, dir, presenter, sessions)
|
406
|
-
@site = site
|
407
|
-
@base = base
|
408
|
-
@dir = dir
|
409
|
-
@name = 'index.html'
|
410
|
-
|
411
|
-
self.process(@name)
|
412
|
-
|
413
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'presenters.html')
|
414
|
-
|
415
|
-
presenter_page_title = site.config['presenter_page_title'] ? site.config['presenter_page_title'] : 'Presenter: %s'
|
416
|
-
self.data['title'] = sprintf(presenter_page_title, presenter['first_name'] + ' ' + presenter['last_name'])
|
417
|
-
|
418
|
-
presenter['sessions'] = []
|
419
|
-
|
420
|
-
sessions.each do |session|
|
421
|
-
if session['speaker_ids'].include?(presenter['id'])
|
422
|
-
presenter['sessions'] << session
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
self.data['presenter'] = presenter
|
427
|
-
|
428
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'presenters', 'presenter.html'))
|
429
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'presenters', 'presenter.html')) # Use theme specific layout
|
430
|
-
else
|
431
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'presenters/presenter.html')) # Use template
|
432
|
-
end
|
433
|
-
end
|
434
|
-
end
|
435
|
-
|
436
|
-
class VenuesIndexPage < Page
|
437
|
-
def initialize(site, base, dir, venues)
|
438
|
-
@site = site
|
439
|
-
@base = base
|
440
|
-
@dir = dir
|
441
|
-
@name = 'index.html'
|
442
|
-
|
443
|
-
self.process(@name)
|
444
|
-
|
445
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'venues.html')
|
446
|
-
|
447
|
-
self.data['title'] = site.config['venues_index_title'] || 'Venues'
|
448
|
-
|
449
|
-
self.data['venues'] = venues
|
450
|
-
|
451
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'venues', 'index.html'))
|
452
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'venues', 'index.html')) # Use theme specific layout
|
453
|
-
else
|
454
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'venues/index.html')) # Use template
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
|
459
|
-
class VenuePage < Page
|
460
|
-
def initialize(site, base, dir, venue)
|
461
|
-
@site = site
|
462
|
-
@base = base
|
463
|
-
@dir = dir
|
464
|
-
@name = 'index.html'
|
465
|
-
|
466
|
-
self.process(@name)
|
467
|
-
|
468
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'venues.html')
|
469
|
-
|
470
|
-
venue_page_title = site.config['venue_page_title'] ? site.config['venue_page_title'] : 'Venue: %s'
|
471
|
-
self.data['title'] = sprintf(venue_page_title, venue['name'])
|
472
|
-
|
473
|
-
self.data['venue'] = venue
|
474
|
-
|
475
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'venues', 'venue.html'))
|
476
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'venues', 'venue.html')) # Use theme specific layout
|
477
|
-
else
|
478
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'venues/venue.html')) # Use template
|
479
|
-
end
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
|
-
class SponsorsIndexPage < Page
|
484
|
-
def initialize(site, base, dir, sponsor_levels)
|
485
|
-
@site = site
|
486
|
-
@base = base
|
487
|
-
@dir = dir
|
488
|
-
@name = 'index.html'
|
489
|
-
|
490
|
-
self.process(@name)
|
491
|
-
|
492
|
-
self.read_yaml(File.join(base, 'attendease_layouts'), 'sponsors.html')
|
493
|
-
|
494
|
-
self.data['title'] = site.config['sponsors_index_title'] || 'Sponsors'
|
495
|
-
|
496
|
-
self.data['sponsor_levels'] = sponsor_levels
|
497
|
-
|
498
|
-
if File.exists?(File.join(base, '_includes', 'attendease', 'sponsors', 'index.html'))
|
499
|
-
self.content = File.read(File.join(base, '_includes', 'attendease', 'sponsors', 'index.html')) # Use theme specific layout
|
500
|
-
else
|
501
|
-
self.content = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', 'sponsors/index.html')) # Use template
|
502
|
-
end
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
class AttendeaseScheduleGenerator < Generator
|
507
|
-
safe true
|
508
|
-
|
509
|
-
def generate(site)
|
510
|
-
if site.config['attendease'] && site.config['attendease']['api_host'] && site.config['attendease']['generate_schedule_pages']
|
511
|
-
|
512
|
-
# Fetch all the session data!
|
513
|
-
attendease_api_host = site.config['attendease']['api_host']
|
514
|
-
attendease_access_token = site.config['attendease']['access_token']
|
515
|
-
|
516
|
-
attendease_data_path = "#{site.source}/_attendease_data"
|
517
|
-
|
518
|
-
event = JSON.parse(File.read("#{attendease_data_path}/event.json"))
|
519
|
-
sessions = JSON.parse(File.read("#{attendease_data_path}/sessions.json")).sort{|s1, s2| s1['name'] <=> s2['name']}
|
520
|
-
presenters = JSON.parse(File.read("#{attendease_data_path}/presenters.json")).sort{|p1, p2| p1['last_name'] <=> p2['last_name']}
|
521
|
-
rooms = JSON.parse(File.read("#{attendease_data_path}/rooms.json")).sort{|r1, r2| r1['name'] <=> r2['name']}
|
522
|
-
filters = JSON.parse(File.read("#{attendease_data_path}/filters.json")).sort{|f1, f2| f1['name'] <=> f2['name']}
|
523
|
-
venues = JSON.parse(File.read("#{attendease_data_path}/venues.json")).sort{|v1, v2| v1['name'] <=> v2['name']}
|
524
|
-
|
525
|
-
# Generate the template files if they don't yet exist.
|
526
|
-
files_to_create_if_they_dont_exist = [
|
527
|
-
'schedule/index.html', 'schedule/day.html', 'schedule/sessions.html', 'schedule/session.html',
|
528
|
-
'presenters/index.html', 'presenters/presenter.html',
|
529
|
-
'venues/index.html', 'venues/venue.html', 'sponsors/index.html'
|
530
|
-
]
|
531
|
-
|
532
|
-
files_to_create_if_they_dont_exist.each do |file|
|
533
|
-
FileUtils.mkdir_p("#{site.source}/_includes/attendease/schedule")
|
534
|
-
FileUtils.mkdir_p("#{site.source}/_includes/attendease/presenters")
|
535
|
-
FileUtils.mkdir_p("#{site.source}/_includes/attendease/venues")
|
536
|
-
FileUtils.mkdir_p("#{site.source}/_includes/attendease/sponsors")
|
537
|
-
|
538
|
-
if !File.exists?(File.join(site.source, '_includes/attendease/', file))
|
539
|
-
include_file = File.read(File.join(File.dirname(__FILE__), '..', '/templates/_includes/attendease/', file))
|
540
|
-
File.open(File.join(site.source, '_includes/attendease/', file), 'w+') { |out_file| out_file.write(include_file) }
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
sessions = Jekyll::Attendease::sessions_with_all_data(event, sessions, presenters, rooms, venues, filters)
|
545
|
-
|
546
|
-
# /schedule pages.
|
547
|
-
dir = site.config['attendease']['schedule_path_name']
|
548
|
-
|
549
|
-
if (site.config['attendease'] && site.config['attendease']['show_day_index'])
|
550
|
-
site.pages << ScheduleIndexPage.new(site, site.source, File.join(dir), event['dates'])
|
551
|
-
else
|
552
|
-
site.pages << ScheduleDayPage.new(site, site.source, File.join(dir), event['dates'].first, sessions, event['dates'])
|
553
|
-
end
|
554
|
-
|
555
|
-
site.pages << ScheduleSessionsPage.new(site, site.source, File.join(dir, 'sessions'), sessions, event['dates'])
|
556
|
-
|
557
|
-
event['dates'].each do |day|
|
558
|
-
site.pages << ScheduleDayPage.new(site, site.source, File.join(dir, day['date']), day, sessions, event['dates'])
|
559
|
-
end
|
560
|
-
|
561
|
-
sessions.each do |session|
|
562
|
-
site.pages << ScheduleSessionPage.new(site, site.source, File.join(dir, session['code']), session)
|
563
|
-
end
|
564
|
-
|
565
|
-
# /presenters pages.
|
566
|
-
dir = site.config['attendease']['presenters_path_name']
|
567
|
-
|
568
|
-
presenters.each do |presenter|
|
569
|
-
presenter['slug'] = EventData.parameterize("#{presenter['first_name']} #{presenter['last_name']}", '_') + '.html'
|
570
|
-
site.pages << PresenterPage.new(site, site.source, File.join(dir, presenter['slug']), presenter, sessions)
|
571
|
-
end
|
572
|
-
|
573
|
-
site.pages << PresentersIndexPage.new(site, site.source, File.join(dir), presenters)
|
574
|
-
|
575
|
-
# /venue pages.
|
576
|
-
dir = (site.config['attendease'] && site.config['attendease']['venues_path_name']) ? site.config['attendease']['venues_path_name'] : 'venues'
|
577
|
-
|
578
|
-
venues.each do |venue|
|
579
|
-
venue['slug'] = EventData.parameterize(venue['name'], '_') + '.html'
|
580
|
-
site.pages << VenuePage.new(site, site.source, File.join(dir, venue['slug']), venue)
|
581
|
-
end
|
582
|
-
|
583
|
-
site.pages << VenuesIndexPage.new(site, site.source, File.join(dir), venues)
|
584
|
-
|
585
|
-
# /sponsors pages.
|
586
|
-
dir = site.config['attendease']['sponsors_path_name']
|
587
|
-
|
588
|
-
if site.config['attendease']['has_sponsors']
|
589
|
-
site.pages << SponsorsIndexPage.new(site, site.source, File.join(dir), site.config['attendease']['sponsor_levels'])
|
590
|
-
end
|
591
|
-
|
592
|
-
#sponsors.each do |sponsor|
|
593
|
-
# site.pages << SponsorPage.new(site, site.source, File.join(dir, EventData.parameterize(sponsor['name']) + '.html', '_'), sponsor)
|
594
|
-
#end
|
595
|
-
|
596
|
-
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
end
|
601
|
-
|
602
|
-
def self.sessions_with_all_data(event, sessions, presenters, rooms, venues, filters)
|
603
|
-
sessionsData = []
|
604
|
-
|
605
|
-
sessions.each do |s|
|
606
|
-
session = {
|
607
|
-
'id' => s['id'],
|
608
|
-
'name' => s['name'],
|
609
|
-
'description' => s['description'],
|
610
|
-
'code' => s['code'],
|
611
|
-
'speaker_ids' => s['speaker_ids']
|
612
|
-
}
|
613
|
-
|
614
|
-
session['presenters'] = []
|
615
|
-
presenters.select{|presenter| s['speaker_ids'].include?(presenter['id'])}.each do |presenter|
|
616
|
-
session['presenters'] << {
|
617
|
-
'id' => presenter['id'],
|
618
|
-
'first_name' => presenter['first_name'],
|
619
|
-
'last_name' => presenter['last_name'],
|
620
|
-
'company' => presenter['company'],
|
621
|
-
'title' => presenter['title'],
|
622
|
-
'profile_url' => presenter['profile_url'],
|
623
|
-
}
|
624
|
-
end
|
625
|
-
|
626
|
-
filters_for_session_hash = {}
|
627
|
-
filters.each do |filter|
|
628
|
-
filter['filter_items'].each do |filter_item|
|
629
|
-
if s['filters'].include?(filter_item['id'])
|
630
|
-
filters_for_session_hash[filter['name']] = [] unless filters_for_session_hash[filter['name']]
|
631
|
-
filters_for_session_hash[filter['name']] << {
|
632
|
-
'name' => filter_item['name']
|
633
|
-
}
|
634
|
-
if event['primary_filter_id'] && event['primary_filter_id'] == filter['id']
|
635
|
-
session['primary_filter_name'] = filter['name']
|
636
|
-
session['primary_filter'] = filter_item['name']
|
637
|
-
end
|
638
|
-
end
|
639
|
-
end
|
640
|
-
end
|
641
|
-
|
642
|
-
filters_for_session = filters_for_session_hash.map do |key, value|
|
643
|
-
{
|
644
|
-
'name' => key,
|
645
|
-
'items' => value
|
646
|
-
}
|
647
|
-
end
|
648
|
-
|
649
|
-
session['filters'] = filters_for_session
|
650
|
-
|
651
|
-
filter_tags = []
|
652
|
-
filters_for_session.each do |filter|
|
653
|
-
item_names = []
|
654
|
-
if !filter['items'].nil?
|
655
|
-
filter['items'].each do |item|
|
656
|
-
filter_tags << EventData.parameterize('attendease-filter-' + filter['name'] + "-" + item['name'])
|
657
|
-
end
|
658
|
-
end
|
659
|
-
end
|
660
|
-
session['filter_tags'] = filter_tags.join(" ")
|
661
|
-
|
662
|
-
if s['instances']
|
663
|
-
instances = []
|
664
|
-
s['instances'].each do |i|
|
665
|
-
instance = {
|
666
|
-
'id' => i['id'],
|
667
|
-
'date' => i['date'],
|
668
|
-
'time' => i['time'],
|
669
|
-
'end_time' => i['end_time'],
|
670
|
-
'duration' => i['duration'],
|
671
|
-
'date_formatted' => i['date_formatted'],
|
672
|
-
'time_formatted' => i['time_formatted'],
|
673
|
-
'end_time_formatted' => i['end_time_formatted'],
|
674
|
-
'duration_formatted' => i['duration_formatted'],
|
675
|
-
'room_id' => i['room_id'],
|
676
|
-
}
|
677
|
-
|
678
|
-
room = rooms.select{|room| room['id'] == i['room_id'] }.first
|
679
|
-
venue = venues.select{|venue| venue['id'] == room['venue_id'] }.first
|
680
|
-
|
681
|
-
instance['room'] = {
|
682
|
-
'name' => room['name'],
|
683
|
-
'venue_id' => room['venue_id'],
|
684
|
-
'venue_name' => venue['name'],
|
685
|
-
'capacity' => room['capacity']
|
686
|
-
}
|
687
|
-
|
688
|
-
instances << instance
|
689
|
-
end
|
690
|
-
session['instances'] = instances
|
691
|
-
else
|
692
|
-
session['instances'] = []
|
693
|
-
end
|
694
|
-
|
695
|
-
sessionsData << session
|
696
|
-
end
|
697
|
-
|
698
|
-
sessionsData
|
699
|
-
end
|
700
|
-
|
701
|
-
end
|
702
|
-
end
|
703
|
-
|
704
|
-
Liquid::Template.register_tag('attendease_content', Jekyll::Attendease::AttendeaseContent)
|
705
|
-
Liquid::Template.register_tag('attendease_auth_script', Jekyll::Attendease::AttendeaseAuthScriptTag)
|
706
|
-
Liquid::Template.register_tag('attendease_scheduler_script', Jekyll::Attendease::AttendeaseSchedulerScriptTag)
|
707
|
-
Liquid::Template.register_tag('attendease_locales_script', Jekyll::Attendease::AttendeaseLocalesScriptTag)
|
708
|
-
Liquid::Template.register_tag('attendease_auth_account', Jekyll::Attendease::AttendeaseAuthAccountTag)
|
709
|
-
Liquid::Template.register_tag('attendease_auth_action', Jekyll::Attendease::AttendeaseAuthActionTag)
|
710
|
-
Liquid::Template.register_tag('t', Jekyll::Attendease::AttendeaseTranslateTag)
|
711
|
-
Liquid::Template.register_filter(Jekyll::Attendease::Filters)
|
15
|
+
Liquid::Template.register_filter(Jekyll::AttendeasePlugin::Filters)
|