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
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'jekyll/attendease_plugin/event_data_generator'
|
2
|
+
require 'jekyll/attendease_plugin/event_layout_generator'
|
3
|
+
require 'jekyll/attendease_plugin/schedule_generator'
|
4
|
+
require 'jekyll/attendease_plugin/sponsor_generator'
|
5
|
+
require 'jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator'
|
6
|
+
require 'jekyll/attendease_plugin/redirect_page'
|
7
|
+
require 'jekyll/attendease_plugin/tags'
|
8
|
+
require 'jekyll/attendease_plugin/filters'
|
9
|
+
|
10
|
+
require 'jekyll/attendease_plugin/presenters_index_page'
|
11
|
+
require 'jekyll/attendease_plugin/presenter_page'
|
12
|
+
require 'jekyll/attendease_plugin/schedule_day_page'
|
13
|
+
require 'jekyll/attendease_plugin/schedule_index_page'
|
14
|
+
require 'jekyll/attendease_plugin/schedule_sessions_page'
|
15
|
+
require 'jekyll/attendease_plugin/schedule_session_page'
|
16
|
+
require 'jekyll/attendease_plugin/sponsors_index_page'
|
17
|
+
require 'jekyll/attendease_plugin/venues_index_page'
|
18
|
+
require 'jekyll/attendease_plugin/venue_page'
|
19
|
+
require 'jekyll/attendease_plugin/version'
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class EventDataGenerator < ::Jekyll::Generator
|
4
|
+
safe true
|
5
|
+
|
6
|
+
priority :highest
|
7
|
+
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
def get(url, options = {})
|
11
|
+
begin
|
12
|
+
self.class.get(url, options)
|
13
|
+
rescue => e
|
14
|
+
Jekyll.logger.error "Could not connect to #{url}."
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parameterize(source, sep = '-')
|
20
|
+
return '' if source.nil?
|
21
|
+
string = source.downcase
|
22
|
+
# Turn unwanted chars into the separator
|
23
|
+
string.gsub!(/[^a-z0-9\-_]+/, sep)
|
24
|
+
unless sep.nil? || sep.empty?
|
25
|
+
re_sep = Regexp.escape(sep)
|
26
|
+
# No more than one of the separator in a row.
|
27
|
+
string.gsub!(/#{re_sep}{2,}/, sep)
|
28
|
+
# Remove leading/trailing separator.
|
29
|
+
string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
|
30
|
+
end
|
31
|
+
string
|
32
|
+
end
|
33
|
+
|
34
|
+
def use_cache?(file)
|
35
|
+
(Time.now.to_i - File.mtime(file).to_i) <= (@attendease_config['cache_expiry'].nil? ? 30 : @attendease_config['cache_expiry']) # file is less than 30 seconds old
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate(site)
|
39
|
+
if @attendease_config = site.config['attendease']
|
40
|
+
if @attendease_config['api_host'] && !@attendease_config['api_host'].match(/^http/)
|
41
|
+
raise "Is your Attendease api_host site properly in _config.yml? Needs to be something like https://myevent.attendease.com/"
|
42
|
+
else
|
43
|
+
# add a trailing slash if we are missing one.
|
44
|
+
if @attendease_config['api_host'][-1, 1] != '/'
|
45
|
+
@attendease_config['api_host'] += '/'
|
46
|
+
end
|
47
|
+
|
48
|
+
@attendease_data_path = File.join(site.source, '_attendease', 'data')
|
49
|
+
|
50
|
+
FileUtils.mkdir_p(@attendease_data_path)
|
51
|
+
|
52
|
+
data_files = %w{ site event sessions presenters rooms filters venues sponsors }.map { |m| "#{m}.json"} << 'lingo.yml'
|
53
|
+
|
54
|
+
data_files.each do |file_name|
|
55
|
+
update_data = true
|
56
|
+
|
57
|
+
file = File.join(@attendease_data_path, file_name)
|
58
|
+
if File.exists?(file) && use_cache?(file)
|
59
|
+
update_data = false
|
60
|
+
|
61
|
+
if file_name.match(/json$/)
|
62
|
+
begin
|
63
|
+
data = JSON.parse(File.read(file))
|
64
|
+
rescue => e
|
65
|
+
raise "Error parsing #{file}: #{e.inspect}"
|
66
|
+
end
|
67
|
+
else
|
68
|
+
data = File.read(file)
|
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.nil? && data.response.is_a?(Net::HTTPOK))
|
89
|
+
Jekyll.logger.info "[Attendease] Saving #{file_name} data..."
|
90
|
+
|
91
|
+
if file_name.match(/json$/)
|
92
|
+
File.open(file, 'w+') { |f| f.write(data.parsed_response.to_json) }
|
93
|
+
else
|
94
|
+
File.open(file, 'w+') { |f| f.write(data.body) }
|
95
|
+
end
|
96
|
+
else
|
97
|
+
raise "Request failed for #{@attendease_config['api_host']}api/#{request_filename}. Is your Attendease api_host site properly in _config.yml?"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
if file_name == '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]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
elsif file_name == 'event.json'
|
120
|
+
site.config['attendease']['event'] = {}
|
121
|
+
|
122
|
+
data.keys.each do |tag|
|
123
|
+
site.config['attendease']['event'][tag] = data[tag]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Generate the template files if they don't yet exist.
|
129
|
+
%w{ schedule presenters venues sponsors}.each do |p|
|
130
|
+
path = File.join(site.source, '_attendease', 'templates', p)
|
131
|
+
FileUtils.mkdir_p(path)
|
132
|
+
raise "Could not create #{path}." unless File.exists?(path)
|
133
|
+
end
|
134
|
+
|
135
|
+
template_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates', '_includes', 'attendease'))
|
136
|
+
files_to_create_if_they_dont_exist = Dir.chdir(template_path) { Dir.glob('*/**.html') + Dir.glob('*.html') }
|
137
|
+
|
138
|
+
files_to_create_if_they_dont_exist.each do |file|
|
139
|
+
destination_file = File.join(site.source, '_attendease', 'templates', file)
|
140
|
+
FileUtils.cp(File.join(template_path, file), destination_file) unless File.exists?(destination_file)
|
141
|
+
end
|
142
|
+
|
143
|
+
# make the event available to anyone
|
144
|
+
event = JSON.parse(File.read("#{@attendease_data_path}/event.json"))
|
145
|
+
site.config['attendease']['event'] = event
|
146
|
+
end
|
147
|
+
|
148
|
+
else
|
149
|
+
raise "Please set the Attendease event data in your _config.yml"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class EventLayoutGenerator < ::Jekyll::Generator
|
4
|
+
safe true
|
5
|
+
|
6
|
+
priority :high
|
7
|
+
|
8
|
+
def generate(site)
|
9
|
+
Jekyll.logger.debug "[Attendease] Generating theme layouts..."
|
10
|
+
|
11
|
+
attendease_precompiled_theme_layouts_path = File.join(site.source, 'attendease_layouts')
|
12
|
+
|
13
|
+
FileUtils.mkdir_p(attendease_precompiled_theme_layouts_path)
|
14
|
+
|
15
|
+
base_layout = site.config['attendease']['base_layout']
|
16
|
+
|
17
|
+
layouts_to_precompile = %w{ layout register schedule presenters venues sponsors }
|
18
|
+
|
19
|
+
# Precompiled layout for website sections.
|
20
|
+
layouts_to_precompile.each do |layout|
|
21
|
+
if File.exists?(File.join(site.source, 'attendease_layouts', "#{base_layout}.html"))
|
22
|
+
# create a layout file if it already doesn't exist.
|
23
|
+
# the layout file will be used by attendease to wrap /register, /schedule, /presenters in the
|
24
|
+
# look the compiled file defines.
|
25
|
+
# ensure {{ content }} is in the file so we can render content in there!
|
26
|
+
unless File.exists?(File.join(attendease_precompiled_theme_layouts_path, "#{layout}.html"))
|
27
|
+
FileUtils.cp File.join(site.source, 'attendease_layouts', "#{base_layout}.html"), File.join(site.source, 'attendease_layouts', "#{layout}.html")
|
28
|
+
#site.pages << LayoutPage.new(site, site.source, 'attendease_layouts', "#{layout}.html", base_layout)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
Jekyll.logger.debug "Could not find attendease_layouts/#{base_layout}.html in your site source. Using the built-in template from jekyll-attendease."
|
32
|
+
#FileUtils.cp File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates', 'layout.html')), File.join(site.source, 'attendease_layouts', "#{base_layout}.html")
|
33
|
+
source_template = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates', 'layout.html'))
|
34
|
+
html = Liquid::Template.parse(File.read(source_template)).render('page' => { 'base_layout' => base_layout })
|
35
|
+
|
36
|
+
File.open(File.join(site.source, 'attendease_layouts', "#{base_layout}.html"), 'w') { |f| f.write(html) }
|
37
|
+
#site.pages << LayoutPage.new(site, site.source, 'attendease_layouts', "#{layout}.html", base_layout)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class PreZeroPointSixLinkRedirectGenerator < ::Jekyll::Generator
|
4
|
+
safe true
|
5
|
+
|
6
|
+
priority :low
|
7
|
+
|
8
|
+
def generate(site)
|
9
|
+
if site.config['attendease']['generate_schedule_pages'] && site.config['attendease']['redirect_ugly_urls']
|
10
|
+
schedule_generator = site.generators.select { |g| g.class == Jekyll::AttendeasePlugin::ScheduleGenerator }.first
|
11
|
+
|
12
|
+
# presenters
|
13
|
+
dir = site.config['attendease']['presenters_path_name']
|
14
|
+
schedule_generator.presenters.each do |o|
|
15
|
+
site.pages << RedirectPage.new(site, site.source, File.join(dir, o['id']), File.join('/', dir, o['slug']))
|
16
|
+
end
|
17
|
+
|
18
|
+
# venues
|
19
|
+
dir = site.config['attendease']['venues_path_name']
|
20
|
+
schedule_generator.venues.each do |o|
|
21
|
+
site.pages << RedirectPage.new(site, site.source, File.join(dir, o['id']), File.join('/', dir, o['slug']))
|
22
|
+
end
|
23
|
+
|
24
|
+
# sessions
|
25
|
+
dir = site.config['attendease']['schedule_path_name']
|
26
|
+
schedule_generator.sessions.each do |o|
|
27
|
+
site.pages << RedirectPage.new(site, site.source, File.join(dir, o['code']), File.join('/', dir, o['slug']))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end # end generate
|
31
|
+
|
32
|
+
end # end class
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class PresenterPage < Page
|
4
|
+
def initialize(site, base, dir, presenter, sessions)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = dir
|
8
|
+
@name = presenter['slug']
|
9
|
+
|
10
|
+
self.process(@name)
|
11
|
+
|
12
|
+
self.read_yaml(File.join(base, 'attendease_layouts'), 'presenters.html')
|
13
|
+
|
14
|
+
presenter_page_title = site.config['presenter_page_title'] ? site.config['presenter_page_title'] : 'Presenter: %s'
|
15
|
+
self.data['title'] = sprintf(presenter_page_title, presenter['first_name'] + ' ' + presenter['last_name'])
|
16
|
+
|
17
|
+
presenter['sessions'] = []
|
18
|
+
|
19
|
+
sessions.each do |session|
|
20
|
+
if session['speaker_ids'].include?(presenter['id'])
|
21
|
+
presenter['sessions'] << session
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
self.data['presenter'] = presenter
|
26
|
+
|
27
|
+
self.content = File.read(File.join(base, '_attendease', 'templates', 'presenters', 'presenter.html'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class PresentersIndexPage < Page
|
4
|
+
def initialize(site, base, dir, presenters)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = dir
|
8
|
+
@name = 'index.html'
|
9
|
+
|
10
|
+
self.process(@name)
|
11
|
+
|
12
|
+
self.read_yaml(File.join(base, 'attendease_layouts'), 'presenters.html')
|
13
|
+
|
14
|
+
self.data['title'] = site.config['presenters_index_title'] || 'Presenters'
|
15
|
+
|
16
|
+
self.data['presenters'] = presenters
|
17
|
+
|
18
|
+
self.content = File.read(File.join(base, '_attendease', 'templates', 'presenters', 'index.html'))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class RedirectPage < Page
|
4
|
+
def initialize(site, base, dir, redirect_url)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = dir
|
8
|
+
@name = 'index.html'
|
9
|
+
|
10
|
+
self.process(@name)
|
11
|
+
|
12
|
+
self.read_yaml(File.join(base, 'attendease_layouts'), 'layout.html')
|
13
|
+
self.data = {}
|
14
|
+
|
15
|
+
self.data['redirect_url'] = redirect_url
|
16
|
+
|
17
|
+
self.content = File.read(File.join(base, '_attendease', 'templates', 'redirect.html'))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class ScheduleDayPage < Page
|
4
|
+
def initialize(site, base, dir, day, sessions, dates)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = dir
|
8
|
+
@name = 'index.html'
|
9
|
+
|
10
|
+
self.process(@name)
|
11
|
+
|
12
|
+
self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
|
13
|
+
|
14
|
+
session_day_title_prefix = site.config['schedule_day_title_prefix'] || 'Schedule: '
|
15
|
+
self.data['title'] = "#{session_day_title_prefix}#{day['date_formatted']}"
|
16
|
+
|
17
|
+
self.data['day'] = day
|
18
|
+
self.data['dates'] = dates
|
19
|
+
|
20
|
+
instances = []
|
21
|
+
|
22
|
+
sessions.each do |s|
|
23
|
+
s['instances'].each do |instance|
|
24
|
+
if instance['date'] == day['date']
|
25
|
+
instance['session'] = s
|
26
|
+
instances << instance
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
self.data['instances'] = instances.sort{|x,y| [x['time'], x['session']['name']] <=> [y['time'], y['session']['name']]}
|
32
|
+
|
33
|
+
self.content = File.read(File.join(base, '_attendease', 'templates', 'schedule', 'day.html'))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,156 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module AttendeasePlugin
|
3
|
+
class ScheduleGenerator < Generator
|
4
|
+
safe true
|
5
|
+
attr_reader :event
|
6
|
+
attr_reader :sessions
|
7
|
+
attr_reader :presenters
|
8
|
+
attr_reader :rooms
|
9
|
+
attr_reader :filters
|
10
|
+
attr_reader :venues
|
11
|
+
|
12
|
+
def generate(site)
|
13
|
+
if site.config['attendease'] && site.config['attendease']['api_host'] && site.config['attendease']['generate_schedule_pages']
|
14
|
+
|
15
|
+
# Fetch all the session data!
|
16
|
+
attendease_api_host = site.config['attendease']['api_host']
|
17
|
+
attendease_access_token = site.config['attendease']['access_token']
|
18
|
+
|
19
|
+
attendease_data_path = File.join(site.source, '_attendease', 'data')
|
20
|
+
|
21
|
+
@event = site.config['attendease']['event']
|
22
|
+
|
23
|
+
sessions = JSON.parse(File.read("#{attendease_data_path}/sessions.json")).sort{|s1, s2| s1['name'] <=> s2['name']}
|
24
|
+
@presenters = JSON.parse(File.read("#{attendease_data_path}/presenters.json")).sort{|p1, p2| p1['last_name'] <=> p2['last_name']}
|
25
|
+
@rooms = JSON.parse(File.read("#{attendease_data_path}/rooms.json")).sort{|r1, r2| r1['name'] <=> r2['name']}
|
26
|
+
@filters = JSON.parse(File.read("#{attendease_data_path}/filters.json")).sort{|f1, f2| f1['name'] <=> f2['name']}
|
27
|
+
@venues = JSON.parse(File.read("#{attendease_data_path}/venues.json")).sort{|v1, v2| v1['name'] <=> v2['name']}
|
28
|
+
|
29
|
+
@presenters.each do |presenter|
|
30
|
+
presenter['slug'] = EventDataGenerator.parameterize("#{presenter['first_name']} #{presenter['last_name']}", '_') + '.html'
|
31
|
+
end
|
32
|
+
|
33
|
+
@venues.each do |venue|
|
34
|
+
venue['slug'] = EventDataGenerator.parameterize(venue['name'], '_') + '.html'
|
35
|
+
end
|
36
|
+
|
37
|
+
sessions.each do |session|
|
38
|
+
if site.config['attendease']['session_slug_uses_code']
|
39
|
+
session['slug'] = session['code'] + '.html'
|
40
|
+
else
|
41
|
+
session['slug'] = EventDataGenerator.parameterize(session['name'], '_') + '.html'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
@sessions = sessions_with_all_data(@event, sessions, @presenters, @rooms, @venues, @filters)
|
46
|
+
|
47
|
+
#
|
48
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
49
|
+
# /schedule pages.
|
50
|
+
dir = site.config['attendease']['schedule_path_name']
|
51
|
+
|
52
|
+
if (site.config['attendease'] && site.config['attendease']['show_day_index'])
|
53
|
+
site.pages << ScheduleIndexPage.new(site, site.source, File.join(dir), @event['dates'])
|
54
|
+
else
|
55
|
+
site.pages << ScheduleDayPage.new(site, site.source, File.join(dir), @event['dates'].first, @sessions, @event['dates'])
|
56
|
+
end
|
57
|
+
|
58
|
+
site.pages << ScheduleSessionsPage.new(site, site.source, File.join(dir, 'sessions'), @sessions, @event['dates'])
|
59
|
+
|
60
|
+
@event['dates'].each do |day|
|
61
|
+
site.pages << ScheduleDayPage.new(site, site.source, File.join(dir, day['date']), day, @sessions, @event['dates'])
|
62
|
+
end
|
63
|
+
|
64
|
+
@sessions.each do |session|
|
65
|
+
site.pages << ScheduleSessionPage.new(site, site.source, File.join(dir, 'sessions'), session)
|
66
|
+
end
|
67
|
+
|
68
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
69
|
+
# /presenters pages.
|
70
|
+
dir = site.config['attendease']['presenters_path_name']
|
71
|
+
|
72
|
+
@presenters.each do |presenter|
|
73
|
+
site.pages << PresenterPage.new(site, site.source, dir, presenter, @sessions)
|
74
|
+
end
|
75
|
+
|
76
|
+
site.pages << PresentersIndexPage.new(site, site.source, File.join(dir), @presenters)
|
77
|
+
|
78
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
79
|
+
# /venue pages.
|
80
|
+
dir = site.config['attendease']['venues_path_name']
|
81
|
+
|
82
|
+
@venues.each do |venue|
|
83
|
+
site.pages << VenuePage.new(site, site.source, dir, venue)
|
84
|
+
end
|
85
|
+
|
86
|
+
site.pages << VenuesIndexPage.new(site, site.source, File.join(dir), @venues)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def sessions_with_all_data(event, sessions, presenters, rooms, venues, filters)
|
91
|
+
sessionsData = []
|
92
|
+
|
93
|
+
sessions.each do |s|
|
94
|
+
session = s.select { |k, v| %w{ id name description code speaker_ids slug }.include?(k) }
|
95
|
+
session['presenters'] = []
|
96
|
+
presenters.select{|presenter| s['speaker_ids'].include?(presenter['id'])}.each do |presenter|
|
97
|
+
session['presenters'] << presenter.select { |k, v| %w{ id first_name last_name company title profile_url slug }.include?(k) }
|
98
|
+
end
|
99
|
+
|
100
|
+
filters_for_session_hash = {}
|
101
|
+
filters.each do |filter|
|
102
|
+
filter['filter_items'].each do |filter_item|
|
103
|
+
if s['filters'].include?(filter_item['id'])
|
104
|
+
filters_for_session_hash[filter['name']] = [] unless filters_for_session_hash[filter['name']]
|
105
|
+
filters_for_session_hash[filter['name']] << {
|
106
|
+
'name' => filter_item['name']
|
107
|
+
}
|
108
|
+
if event['primary_filter_id'] && event['primary_filter_id'] == filter['id']
|
109
|
+
session['primary_filter_name'] = filter['name']
|
110
|
+
session['primary_filter'] = filter_item['name']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
filters_for_session = filters_for_session_hash.map { |key, value| { 'name' => key, 'items' => value } }
|
117
|
+
|
118
|
+
session['filters'] = filters_for_session
|
119
|
+
|
120
|
+
filter_tags = []
|
121
|
+
filters_for_session.each do |filter|
|
122
|
+
item_names = []
|
123
|
+
if !filter['items'].nil?
|
124
|
+
filter['items'].each do |item|
|
125
|
+
filter_tags << EventDataGenerator.parameterize('attendease-filter-' + filter['name'] + "-" + item['name'])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
session['filter_tags'] = filter_tags.join(" ")
|
130
|
+
|
131
|
+
if s['instances']
|
132
|
+
instances = []
|
133
|
+
s['instances'].each do |i|
|
134
|
+
instance = i.select { |k, v| %w{ id date time end_time duration date_formatted time_formatted end_time_formatted duration_formatted room_id }.include?(k) }
|
135
|
+
|
136
|
+
room = rooms.select { |room| room['id'] == i['room_id'] }.first
|
137
|
+
venue = venues.select { |venue| venue['id'] == room['venue_id'] }.first
|
138
|
+
instance['room'] = room.merge({ 'venue_name' => venue['name'] })
|
139
|
+
instance['venue_slug'] = venue['slug']
|
140
|
+
|
141
|
+
instances << instance
|
142
|
+
end
|
143
|
+
session['instances'] = instances
|
144
|
+
else
|
145
|
+
session['instances'] = []
|
146
|
+
end
|
147
|
+
|
148
|
+
sessionsData << session
|
149
|
+
end
|
150
|
+
|
151
|
+
sessionsData
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|