jekyll-attendease 0.6.25k → 0.6.26a

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
  SHA1:
3
- metadata.gz: c8b620d0db1b91004b9d7c239d24c3cdc9f2241f
4
- data.tar.gz: c3729714a5d44fa8ed75fd451ad6fe86f8dcb87b
3
+ metadata.gz: 5f7ec275ba6622c90c49c18db39852a3032e3ed4
4
+ data.tar.gz: 38745b2ee3b79e571d6265ad8bd87f4827d82dc8
5
5
  SHA512:
6
- metadata.gz: 5e44ba2475373318e199941347217b7b880775b238bac646295c8e58beb17f99f7741b50434dfacd6f07ac110054ccef93606304e095e704dfc43eebccf203f0
7
- data.tar.gz: f2b2e3fa7a426af36d88e3f56d6c4595c7c617f94e7a85f122b753e189b2d9df7eba157ad0a7593950e35ea12892de9ec04a440dc5b2b085c4b0b2d7e405c998
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) <= (@attendease_config['cache_expiry'].nil? ? 30 : @attendease_config['cache_expiry']) # file is less than 30 seconds old
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 @attendease_config = site.config['attendease']
25
- if @attendease_config['api_host'] && !@attendease_config['api_host'].match(/^http/)
26
- raise "Is your Attendease api_host site properly in _config.yml? Needs to be something like https://myevent.attendease.com/"
27
- else
28
- # add a trailing slash if we are missing one.
29
- if @attendease_config['api_host'][-1, 1] != '/'
30
- @attendease_config['api_host'] += '/'
31
- end
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
- @attendease_data_path = File.join(site.source, '_attendease', 'data')
34
+ @attendease_data_path = File.join(site.source, '_attendease', 'data')
34
35
 
35
- FileUtils.mkdir_p(@attendease_data_path)
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
- # no more site in nextgen themes
40
- #data_files.shift if @attendease_config['jekyll33']
44
+ # no more site in nextgen themes
45
+ #data_files.shift if site.config.attendease['jekyll33']
41
46
 
42
- data_files.each do |file_name|
43
- update_data = true
44
- data = nil
47
+ data_files.each do |filename|
48
+ update_data = true
49
+ data = nil
45
50
 
46
- file = File.join(@attendease_data_path, file_name)
47
- if File.exists?(file) && use_cache?(file)
48
- update_data = false
51
+ file = File.join(@attendease_data_path, filename)
52
+ if File.exists?(file) && use_cache?(site, file)
53
+ update_data = false
49
54
 
50
- if file_name.match(/json$/)
51
- begin
52
- data = JSON.parse(File.read(file))
53
- rescue => e
54
- raise "Error parsing #{file}: #{e.inspect}"
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
- key = "has_#{file_name.split('.')[0]}"
66
+ key = "has_#{filename.split('.')[0]}"
62
67
 
63
- # don't bother making a request for resources that don't exist in the event
64
- if !@attendease_config[key].nil? && !@attendease_config[key]
65
- update_data = false
66
- data = []
67
- end
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
- if update_data
70
- options = {}
71
- options.merge!(:headers => {'X-Event-Token' => @attendease_config['access_token']}) if @attendease_config['access_token']
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
- request_filename = file_name.gsub(/yml$/, 'yaml')
74
- response = get("#{@attendease_config['api_host']}api/#{request_filename}?meta=true", options)
78
+ request_filename = filename.gsub(/yml$/, 'yaml')
79
+ response = get("#{site.config.attendease['api_host']}api/#{request_filename}?meta=true", options)
75
80
 
76
- #if (file_name.match(/yaml$/) || data.is_a?(Hash) && !data['error']) || data.is_a?(Array)
77
- if (!response.nil? && response.response.is_a?(Net::HTTPOK))
78
- Jekyll.logger.info "[Attendease] Saving #{file_name} data..."
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
- if file_name.match(/json$/)
81
- data = response.parsed_response
82
- File.open(file, 'w+') { |f| f.write(data.to_json) }
83
- else # yaml
84
- File.open(file, 'w+') { |f| f.write(response.body) }
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
- # make this data available to anything that wants it
92
- site.config['attendease'][File.basename(file_name, '.*')] = data
93
- site.data[File.basename(file_name, '.*')] = data
94
-
95
- if data.is_a?(Hash)
96
- if file_name == 'site.json'
97
- # Adding to site config so we can access these variables globally wihtout using a Liquid Tag so we can use if/else
98
- site.config['attendease']['data'] = {}
99
-
100
- data.keys.each do |tag|
101
- site.config['attendease']['data'][tag] = data[tag]
102
- # memorandum from the department of redundancy department:
103
- # --------------------------------------------------------
104
- # support accessing the attendease_* variables without the
105
- # attendease_ prefix because they're already namespaced in
106
- # site.attendease.data
107
- #
108
- # TODO: update all themes to not use attendease_ variables
109
- # and then retire them from the ThemeManager.
110
- if tag.match(/^attendease_/)
111
- site.config['attendease']['data'][tag.gsub(/^attendease_/, '')] = data[tag]
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
- # provide a structure of session instances (timeslots) grouped
119
- # by day (suitable for displaying a schedule)
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
- # make the event available to anyone
138
- event = JSON.parse(File.read("#{@attendease_data_path}/event.json"))
139
- site.config['attendease']['event'] = event
140
-
141
- if @attendease_config['copy_data']
142
- data_dir = File.join(site.source, 'attendease_data')
143
- FileUtils.mkdir(data_dir) unless File.exists?(data_dir)
144
- site.config['attendease']['data_files'] = {}
145
-
146
- Dir.chdir(@attendease_data_path) do
147
- extension = '.json'
148
- Dir.glob('*.json').each do |f|
149
- base_name = File.basename(f, extension)
150
- digest = Digest::SHA2.file(f).hexdigest
151
- digest_file = "#{base_name}-#{digest}.json"
152
- FileUtils.cp(f, File.join(data_dir, digest_file))
153
- site.config['attendease']['data_files'][base_name] = digest_file
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
- else
163
- raise "Please set the Attendease event data in your _config.yml"
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['attendease'] && site.config['attendease']['api_host'] && site.config['attendease']['generate_schedule_pages']
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,7 +4,7 @@ module Jekyll
4
4
  safe true
5
5
 
6
6
  def generate(site)
7
- site.config['attendease']['pages'].each do |page|
7
+ site.data['pages'].each do |page|
8
8
  if !page['permanent']
9
9
  site.pages << SitePage.new(site, site.source, page)
10
10
 
@@ -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.config['attendease']['sponsor_levels'] = sponsor_levels
27
+ site.data['sponsor_levels'] = sponsor_levels
26
28
 
27
29
  # /sponsors pages.
28
30
  dir = site.config['attendease']['sponsors_path_name']