jekyll-attendease 0.9.3 → 0.9.7

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: f34a3a54e23f0d3b76b52f58ab12428d001bb44f
4
- data.tar.gz: 7ccb50dc81a6afa20724df44d60fdf2481603a66
3
+ metadata.gz: bd5a69a540b248bf67785ce3845b8a6e1230fed2
4
+ data.tar.gz: 3c96284cfdc27734e9497b149d8b4dadaa421a58
5
5
  SHA512:
6
- metadata.gz: e2eafd219f7d4901da9cc9da5927385ee45ae83a298c920fb3b07285f5247d086e4ff5ae51e96e9c0b656bf2a53be4985a0ff3da5586a32b9679c450f474979e
7
- data.tar.gz: 34457707f96c7b80acab36729f5ffc9a0b8b6203a16e4cf0cf5ba13e05aa539bb31c64136e92ee74650ad27eb583187cb6d57883bbe19c6feb852b057242e4df
6
+ metadata.gz: 420ffd467a791c03541a344c2e47d4c6dd726e82e3212ee0bf49ac458ba4ad66b2639473941eb42475a58d04d57c7eab79ec654aaf29565b3b24702e7ddd48bd
7
+ data.tar.gz: 7508996f41f5fb93879e74666de9ae269d1855825fda2da77c6b867cd09fcfcb66f354b94c3af940a3176763d21d260256f8053ab91c41b8e7a5503224f293b0
@@ -33,6 +33,7 @@ require 'jekyll/attendease_plugin/sponsors_index_page'
33
33
  require 'jekyll/attendease_plugin/venues_index_page'
34
34
  require 'jekyll/attendease_plugin/venue_page'
35
35
  require 'jekyll/attendease_plugin/site_page'
36
+ require 'jekyll/attendease_plugin/site_page_data'
36
37
 
37
38
  # Ve.rs.ion
38
39
  require 'jekyll/attendease_plugin/version'
@@ -45,6 +46,8 @@ Jekyll::Hooks.register :site, :after_reset do |site|
45
46
 
46
47
  site.config['attendease'] = site.config['attendease'].nil? ? default : Jekyll::Utils.deep_merge_hashes(default['attendease'], site.config['attendease'])
47
48
 
49
+ site.config['attendease_source'] ||= site.config['source']
50
+
48
51
  site.config.extend(AttendeaseJekyllConfigMixin)
49
52
 
50
53
  if site.config.attendease['api_host'].nil?
@@ -55,11 +58,11 @@ end
55
58
  Jekyll::Hooks.register :site, :post_write do |site|
56
59
  if pages = site.data['pages']
57
60
  pages.each do |page|
58
- if File.exists?(file = File.join(site.config['source'], page['slug'], 'index.html'))
61
+ if File.exists?(file = File.join(site.config['attendease_source'], page['slug'], 'index.html'))
59
62
  File.unlink(file)
60
63
  end
61
64
 
62
- if File.exists?(file = File.join(site.config['source'], page['slug'], 'index.json'))
65
+ if File.exists?(file = File.join(site.config['attendease_source'], page['slug'], 'index.json'))
63
66
  File.unlink(file)
64
67
  end
65
68
  end
@@ -14,4 +14,12 @@ module AttendeaseJekyllConfigMixin
14
14
  def cms_theme?
15
15
  attendease['jekyll33'] == true
16
16
  end
17
+
18
+ def live_mode?
19
+ !!attendease['live_mode']
20
+ end
21
+
22
+ def private_site?
23
+ !!attendease['private_site']
24
+ end
17
25
  end
@@ -29,14 +29,14 @@ module Jekyll
29
29
  site.config.attendease['api_host'] += '/'
30
30
  end
31
31
 
32
- @attendease_data_path = File.join(site.source, '_attendease', 'data')
32
+ @attendease_data_path = File.join(site.config['attendease_source'], '_attendease', 'data')
33
33
 
34
34
  FileUtils.mkdir_p(@attendease_data_path)
35
35
 
36
36
  if site.config.cms_theme?
37
- data_files = %w[ site event pages portal_pages site_settings organization_site_settings mappable ].map { |m| "#{m}.json"} << 'lingo.yml'
37
+ data_files = %w[site event pages portal_pages site_settings organization_site_settings mappable].map { |m| "#{m}.json"} << 'lingo.yml'
38
38
  else
39
- data_files = %w[ site event sessions presenters rooms filters venues sponsors pages site_settings mappable ].map { |m| "#{m}.json"} << 'lingo.yml'
39
+ data_files = %w[site event sessions presenters rooms filters venues sponsors pages site_settings].map { |m| "#{m}.json"} << 'lingo.yml'
40
40
  end
41
41
 
42
42
  # no more site in nextgen themes
@@ -47,6 +47,7 @@ module Jekyll
47
47
  data = nil
48
48
 
49
49
  file = File.join(@attendease_data_path, filename)
50
+
50
51
  if File.exists?(file) && use_cache?(site, file)
51
52
  update_data = false
52
53
 
@@ -16,21 +16,8 @@ module Jekyll
16
16
  def generate(site)
17
17
  Jekyll.logger.debug "[Attendease] Generating theme layouts..."
18
18
 
19
- attendease_precompiled_theme_layouts_path = File.join(site.source, 'attendease_layouts') # These are compiled to the html site.
20
- attendease_precompiled_theme_email_layouts_path = File.join(site.source, 'attendease_layouts', 'emails') # These are compiled for email.
21
19
  layouts_path = File.join(site.source, '_layouts')
22
20
 
23
- FileUtils.mkdir_p(attendease_precompiled_theme_layouts_path)
24
-
25
- # Precompiled layouts for attendease app and jekyll generated pages.
26
- base_layout = site.config['attendease']['base_layout'] || 'layout'
27
-
28
- base_layout_file = File.join(layouts_path, "#{base_layout}.html")
29
- unless File.exists?(base_layout_file)
30
- # Generate an extremely simple base layout if it does not exist.
31
- File.open(base_layout_file, 'w+') { |f| f.write("{{ content }}") }
32
- end
33
-
34
21
  cms_layouts = []
35
22
  begin
36
23
  Dir.glob(File.join(layouts_path, '*.html')).each do |l|
@@ -45,6 +32,26 @@ module Jekyll
45
32
  rescue
46
33
  end
47
34
 
35
+ cms_layouts.each do |layout|
36
+ site.pages << EventLayoutPage.new(site, site.source, 'attendease_layouts', "cms-#{layout}.html", layout, layout.capitalize)
37
+ end
38
+
39
+ return unless site.config.live_mode?
40
+
41
+ attendease_precompiled_theme_layouts_path = File.join(site.source, 'attendease_layouts') # These are compiled to the html site.
42
+ attendease_precompiled_theme_email_layouts_path = File.join(site.source, 'attendease_layouts', 'emails') # These are compiled for email.
43
+
44
+ FileUtils.mkdir_p(attendease_precompiled_theme_layouts_path)
45
+
46
+ # Precompiled layouts for attendease app and jekyll generated pages.
47
+ base_layout = site.config['attendease']['base_layout'] || 'layout'
48
+
49
+ base_layout_file = File.join(layouts_path, "#{base_layout}.html")
50
+ unless File.exists?(base_layout_file)
51
+ # Generate an extremely simple base layout if it does not exist.
52
+ File.open(base_layout_file, 'w+') { |f| f.write("{{ content }}") }
53
+ end
54
+
48
55
  layouts_to_precompile = %w{ layout register surveys } # These are compiled to the html site.
49
56
  layouts_to_precompile.each do |layout|
50
57
  # create a layout file if it already doesn't exist.
@@ -56,10 +63,6 @@ module Jekyll
56
63
  end
57
64
  end
58
65
 
59
- cms_layouts.each do |layout|
60
- site.pages << EventLayoutPage.new(site, site.source, 'attendease_layouts', "cms-#{layout}.html", layout, layout.capitalize)
61
- end
62
-
63
66
  # Precompiled layouts for attendease email
64
67
  base_email_layout = site.config['attendease']['base_email_layout'] || 'email'
65
68
  base_email_layout_file = File.join(layouts_path, "#{base_email_layout}.html")
@@ -22,6 +22,7 @@ module Jekyll
22
22
  priority :high
23
23
 
24
24
  def generate(site)
25
+ return false if site.config.cms_theme?
25
26
  Jekyll.logger.info "[Attendease] Generating theme templates..."
26
27
 
27
28
  # Generate the template files if they don't yet exist.
@@ -14,7 +14,7 @@ module Jekyll
14
14
  site.config.attendease['api_host'] += '/'
15
15
  end
16
16
 
17
- @attendease_data_path = File.join(site.source, '_attendease', 'data')
17
+ @attendease_data_path = File.join(site.config['attendease_source'], '_attendease', 'data')
18
18
 
19
19
  FileUtils.mkdir_p(@attendease_data_path) unless File.exists?(@attendease_data_path)
20
20
 
@@ -79,7 +79,7 @@ module Jekyll
79
79
  end
80
80
 
81
81
  def data_path
82
- File.join(site.config['source'], '_attendease', 'data')
82
+ File.join(site.config['attendease_source'], '_attendease', 'data')
83
83
  end
84
84
 
85
85
  def populate_sessions_with_related_data!(sessions)
@@ -0,0 +1,106 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class SitePageData < Page
4
+ attr_reader :page
5
+ attr_reader :site
6
+
7
+ PLACEHOLDER_REGEX = /\{\{/.freeze
8
+
9
+ def initialize(site, base, page, private_site)
10
+ @site = site
11
+ @base = base
12
+ @dir = page['slug']
13
+ @page = page
14
+ @name = "index#{private_site ? '-private' : ''}.json"
15
+
16
+ # The Jekyll::Regenerator expects data to exist and crashes without it.
17
+ # https://github.com/jekyll/jekyll/blob/v3.3.1/lib/jekyll/regenerator.rb#L166
18
+ @data = {}
19
+
20
+ self.process(@name)
21
+ end
22
+
23
+ def render_with_liquid?
24
+ false
25
+ end
26
+
27
+ def place_in_layout?
28
+ false
29
+ end
30
+
31
+ # Override the accessor:
32
+ #
33
+ # https://github.com/jekyll/jekyll/blob/v3.3.1/lib/jekyll/renderer.rb#L78
34
+ #
35
+ # The Jekyll::Rendereer calls document.content, so this seems like the
36
+ # best way to set our "page" content with what we want.
37
+ #
38
+ def content
39
+ zones = {}
40
+ keys = %w[content preferences]
41
+
42
+ if page['block_instances'].length
43
+ # create zone buckets
44
+ page['block_instances'].each do |i|
45
+ # go through all content
46
+ if site.config.event?
47
+ keys.each do |key|
48
+ i[key].each do |k, v|
49
+ if placeholder?(v)
50
+ # maintain the {{ t.foo }} variables
51
+ v.gsub!(/(\{\{\s*t\.[a-z_.]+\s*\}\})/, '{% raw %}\1{% endraw %}')
52
+ i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])
53
+ end
54
+ end
55
+ end
56
+
57
+ unless site.data['mappable'].nil? || site.data['mappable'].empty?
58
+ perform_substitution!(i, 'mappable' => site.data['mappable'])
59
+ end
60
+ end
61
+
62
+ zones[i['zone']] = [] if zones[i['zone']].nil?
63
+ zones[i['zone']] << i
64
+ end
65
+
66
+ # sort each bucket by widget weight
67
+ zones.each do |k, zone|
68
+ zone.sort! { |x, y| x['weight'] <=> y['weight'] }
69
+ end
70
+ end
71
+
72
+ zones.to_json
73
+ end
74
+
75
+ private
76
+
77
+ def perform_substitution!(object, substitution_lookup)
78
+ if object.is_a?(Hash)
79
+ object.each_pair do |k, v|
80
+ if placeholder?(v)
81
+ object[k] = render_with_substitutions(v, substitution_lookup)
82
+ else
83
+ perform_substitution!(v, substitution_lookup)
84
+ end
85
+ end
86
+ elsif object.is_a?(Array)
87
+ object.each_with_index do |e, i|
88
+ if placeholder?(e)
89
+ object[i] = render_with_substitutions(e, substitution_lookup)
90
+ else
91
+ perform_substitution!(e, substitution_lookup)
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ def placeholder?(object)
98
+ object.is_a?(String) && object =~ PLACEHOLDER_REGEX
99
+ end
100
+
101
+ def render_with_substitutions(template_string, substitution_lookup)
102
+ Liquid::Template.parse(template_string).render(substitution_lookup)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -2,8 +2,6 @@ module Jekyll
2
2
  module AttendeasePlugin
3
3
  class SitePagesGenerator < Generator
4
4
  safe true
5
- PLACEHOLDER_REGEX = /\{\{/.freeze
6
-
7
5
  # site.config:
8
6
  # Is where you can find the configs generated for your site
9
7
  # To check the structure sample go in your vagrant to
@@ -15,84 +13,10 @@ module Jekyll
15
13
 
16
14
  page['name'] = CGI.escapeHTML(page['name']) if page['name']
17
15
  site.pages << SitePage.new(site, site.source, page)
18
-
19
- zones = {}
20
- keys = %w[content preferences]
21
-
22
- if page['block_instances'].length
23
- # create zone buckets
24
- page['block_instances'].each do |i|
25
- # go through all content
26
- if site.config.event?
27
- keys.each do |key|
28
- i[key].each do |k, v|
29
- if placeholder?(v)
30
- # maintain the {{ t.foo }} variables
31
- v.gsub!(/(\{\{\s*t\.[a-z_.]+\s*\}\})/, '{% raw %}\1{% endraw %}')
32
- i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])
33
- end
34
- end
35
- end
36
-
37
- unless site.data['mappable'].nil? || site.data['mappable'].empty?
38
- perform_substitution!(i, 'mappable' => site.data['mappable'])
39
- end
40
- end
41
-
42
- zones[i['zone']] = [] if zones[i['zone']].nil?
43
- zones[i['zone']] << i
44
- end
45
-
46
- # sort each bucket by widget weight
47
- zones.each do |k, zone|
48
- zone.sort! { |x, y| x['weight'] <=> y['weight'] }
49
- end
50
-
51
- page_source_path = File.join(site.source, page['slug'])
52
- FileUtils.mkdir_p(page_source_path) unless File.exists?(page_source_path)
53
-
54
- json_filename = site.config.attendease['private_site'] ? 'index-private.json' : 'index.json'
55
-
56
- File.open(File.join(page_source_path, json_filename), 'w') do |f|
57
- f.write zones.to_json
58
- f.close
59
- end
60
-
61
- site.static_files << StaticFile.new(site, site.source, File.join('', page['slug']), json_filename)
62
- end
16
+ site.pages << SitePageData.new(site, site.source, page, site.config.private_site?)
63
17
  end
64
18
  end
65
19
  end
66
-
67
- private
68
-
69
- def perform_substitution!(object, substitution_lookup)
70
- if object.is_a?(Hash)
71
- object.each_pair do |k, v|
72
- if placeholder?(v)
73
- object[k] = render_with_substitutions(v, substitution_lookup)
74
- else
75
- perform_substitution!(v, substitution_lookup)
76
- end
77
- end
78
- elsif object.is_a?(Array)
79
- object.each_with_index do |e, i|
80
- if placeholder?(e)
81
- object[i] = render_with_substitutions(e, substitution_lookup)
82
- else
83
- perform_substitution!(e, substitution_lookup)
84
- end
85
- end
86
- end
87
- end
88
-
89
- def placeholder?(object)
90
- object.is_a?(String) && object =~ PLACEHOLDER_REGEX
91
- end
92
-
93
- def render_with_substitutions(template_string, substitution_lookup)
94
- Liquid::Template.parse(template_string).render(substitution_lookup)
95
- end
96
20
  end
97
21
  end
98
22
  end
@@ -3,7 +3,7 @@ module Jekyll
3
3
  class ScheduleWidgetTag < Liquid::Tag
4
4
  def render(context)
5
5
  schedule_data = ScheduleDataParser.new(context.registers[:site])
6
- base = File.join(context.registers[:site].config['source'])
6
+ base = File.join(context.registers[:site].config['attendease_source'])
7
7
 
8
8
  instances = schedule_data.sessions.inject([]) do |memo, s|
9
9
  s['instances'].each do |instance|
@@ -63,7 +63,7 @@ module Jekyll
63
63
  def render(context)
64
64
  I18n::Backend::Simple.include(I18n::Backend::Pluralization)
65
65
  I18n.enforce_available_locales = false
66
- i18n_path = File.join(context.registers[:site].config['source'], '_attendease', 'data', 'lingo.yml')
66
+ i18n_path = File.join(context.registers[:site].config['attendease_source'], '_attendease', 'data', 'lingo.yml')
67
67
  I18n.load_path << i18n_path unless I18n.load_path.include?(i18n_path)
68
68
  I18n.locale = context.registers[:page]['lang'] || context.registers[:site].config['attendease']['locale'] || context.registers[:site].config['attendease']['lang'] || :en
69
69
  I18n.t(@key, :count => @options['t_size'])
@@ -183,7 +183,8 @@ module Jekyll
183
183
  'pages' => pages,
184
184
  'settings' => { parentPagesAreClickable: !!parent_pages_are_clickable },
185
185
  'siteSettings' => site_settings,
186
- 'analytics' => analytics
186
+ 'analytics' => analytics,
187
+ 'basePath' => config['base_path']
187
188
  }
188
189
  else
189
190
  constants = {
@@ -201,7 +202,8 @@ module Jekyll
201
202
  'settings' => { parentPagesAreClickable: !!parent_pages_are_clickable },
202
203
  'siteSettings' => site_settings,
203
204
  'organizationSiteSettings' => organization_site_settings,
204
- 'analytics' => analytics
205
+ 'analytics' => analytics,
206
+ 'basePath' => config['base_path']
205
207
  }
206
208
  end
207
209
 
@@ -224,6 +226,8 @@ _EOT
224
226
  url = '//dashboard.localhost.attendease.com/webpack_assets/blockrenderer.bundle.js'
225
227
  when 'prerelease'
226
228
  url = '//cdn.attendease.com/blockrenderer/prerelease-latest.js'
229
+ when 'staging'
230
+ url = '//cdn.attendease.com/blockrenderer/staging-latest.js'
227
231
  when 'preview'
228
232
  url = '//cdn.attendease.com/blockrenderer/ci-latest.js'
229
233
  else
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  module AttendeasePlugin
3
- VERSION = '0.9.3'
3
+ VERSION = '0.9.7'
4
4
  end
5
5
  end
6
6
 
@@ -1,33 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Jekyll::AttendeasePlugin::EventTemplateGenerator do
4
- context 'event site' do
4
+ context 'legacy event site' do
5
5
  let(:site) { build_site }
6
6
 
7
7
  it 'creates the Attendease template files' do
8
8
  template_files = Dir.chdir(File.join(@template_root, 'attendease')) { Dir.glob('**/**.html') }
9
9
 
10
10
  template_files.each do |template_file|
11
- path = File.join(site.config['source'], '_attendease', 'templates', template_file)
11
+ path = File.join(site.config['attendease_source'], '_attendease', 'templates', template_file)
12
12
 
13
+ puts path
13
14
  expect(File.exists?(path)).to eq(true)
14
15
  expect(File.size(path)).to be > 0
15
16
  end
16
17
  end
17
18
  end
18
19
 
19
- context 'organization site' do
20
- let(:site) { build_org_site }
20
+ context 'CMS site' do
21
+ let(:site) { build_cms_site }
21
22
 
22
- it 'creates the Attendease template files' do
23
- template_files = Dir.chdir(File.join(@template_root, 'attendease')) { Dir.glob('**/**.html') }
24
-
25
- template_files.each do |template_file|
26
- path = File.join(site.config['source'], '_attendease', 'templates', template_file)
27
-
28
- expect(File.exists?(path)).to eq(true)
29
- expect(File.size(path)).to be > 0
30
- end
23
+ it 'skips creating the Attendease template files' do
24
+ expect(Pathname.new(site.config['attendease_source']).join('templates').exist?).to eq(false)
31
25
  end
32
26
  end
33
27
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Jekyll::AttendeasePlugin::SitePagesGenerator do
4
- let(:site) { build_site }
4
+ let(:site) { build_cms_site }
5
5
  let(:site_pages_generator) { find_generator(site, described_class) }
6
6
  let(:index_file) { 'index.html' }
7
7
  let(:page) { site.data['pages'].detect { |p| p['slug'] == 'test' } }
@@ -85,6 +85,7 @@ RSpec.configure do |config|
85
85
  'has_venues' => true,
86
86
  'has_mappable' => true,
87
87
  'environment' => 'test',
88
+ 'live_mode' => true,
88
89
  'locale' => 'en',
89
90
  'source_id' => 'foobar',
90
91
  'auth_host' => 'https://foobar.auth/',
@@ -106,6 +107,10 @@ RSpec.configure do |config|
106
107
  @site
107
108
  end
108
109
 
110
+ def build_cms_site
111
+ build_site({ 'attendease' => { 'jekyll33' => true } })
112
+ end
113
+
109
114
  def build_org_site
110
115
  build_site({ 'attendease' => { 'mode' => 'organization', 'jekyll33' => true } })
111
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-attendease
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Wood
@@ -184,6 +184,7 @@ files:
184
184
  - lib/jekyll/attendease_plugin/schedule_session_page.rb
185
185
  - lib/jekyll/attendease_plugin/schedule_sessions_page.rb
186
186
  - lib/jekyll/attendease_plugin/site_page.rb
187
+ - lib/jekyll/attendease_plugin/site_page_data.rb
187
188
  - lib/jekyll/attendease_plugin/site_pages_generator.rb
188
189
  - lib/jekyll/attendease_plugin/sponsor_generator.rb
189
190
  - lib/jekyll/attendease_plugin/sponsors_index_page.rb