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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-attendease.rb +9 -705
  3. data/lib/jekyll/attendease_plugin.rb +19 -0
  4. data/lib/jekyll/attendease_plugin/event_data_generator.rb +154 -0
  5. data/lib/jekyll/attendease_plugin/event_layout_generator.rb +43 -0
  6. data/lib/jekyll/attendease_plugin/filters.rb +9 -0
  7. data/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator.rb +35 -0
  8. data/lib/jekyll/attendease_plugin/presenter_page.rb +31 -0
  9. data/lib/jekyll/attendease_plugin/presenters_index_page.rb +23 -0
  10. data/lib/jekyll/attendease_plugin/redirect_page.rb +22 -0
  11. data/lib/jekyll/attendease_plugin/schedule_day_page.rb +38 -0
  12. data/lib/jekyll/attendease_plugin/schedule_generator.rb +156 -0
  13. data/lib/jekyll/attendease_plugin/schedule_index_page.rb +23 -0
  14. data/lib/jekyll/attendease_plugin/schedule_session_page.rb +24 -0
  15. data/lib/jekyll/attendease_plugin/schedule_sessions_page.rb +26 -0
  16. data/lib/jekyll/attendease_plugin/sponsor_generator.rb +37 -0
  17. data/lib/jekyll/attendease_plugin/sponsors_index_page.rb +23 -0
  18. data/lib/jekyll/attendease_plugin/tags.rb +65 -0
  19. data/lib/jekyll/attendease_plugin/venue_page.rb +24 -0
  20. data/lib/jekyll/attendease_plugin/venues_index_page.rb +23 -0
  21. data/lib/jekyll/attendease_plugin/version.rb +6 -0
  22. data/spec/lib/jekyll/attendease_plugin/event_data_generator_spec.rb +16 -0
  23. data/spec/lib/jekyll/attendease_plugin/event_layout_generator_spec.rb +12 -0
  24. data/spec/lib/jekyll/attendease_plugin/filters_spec.rb +15 -0
  25. data/spec/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator_spec.rb +40 -0
  26. data/spec/lib/jekyll/attendease_plugin/schedule_generator_spec.rb +104 -0
  27. data/spec/lib/jekyll/attendease_plugin/sponsor_generator_spec.rb +12 -0
  28. data/spec/lib/jekyll/attendease_plugin/tags_spec.rb +45 -0
  29. data/spec/spec_helper.rb +83 -0
  30. data/spec/support/fixtures_helpers.rb +7 -0
  31. data/templates/_includes/attendease/presenters/index.html +2 -2
  32. data/templates/_includes/attendease/presenters/presenter.html +3 -3
  33. data/templates/_includes/attendease/redirect.html +12 -0
  34. data/templates/_includes/attendease/schedule/day.html +5 -5
  35. data/templates/_includes/attendease/schedule/index.html +3 -3
  36. data/templates/_includes/attendease/schedule/session.html +3 -3
  37. data/templates/_includes/attendease/schedule/sessions.html +3 -3
  38. data/templates/_includes/attendease/sponsors/index.html +14 -3
  39. data/templates/layout.html +1 -1
  40. metadata +113 -20
  41. data/README.md +0 -181
@@ -0,0 +1,23 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class ScheduleIndexPage < Page
4
+ def initialize(site, base, dir, 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
+ self.data['title'] = site.config['schedule_index_title_prefix'] || 'Schedule'
15
+
16
+ self.data['dates'] = dates
17
+
18
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'schedule', 'index.html'))
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,24 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class ScheduleSessionPage < Page
4
+ def initialize(site, base, dir, session)
5
+ @site = site
6
+ @base = base
7
+ @dir = dir
8
+ @name = session['slug']
9
+
10
+ self.process(@name)
11
+
12
+ self.read_yaml(File.join(base, 'attendease_layouts'), 'schedule.html')
13
+
14
+ schedule_session_page_title = site.config['schedule_session_page_title'] || 'Schedule: %s'
15
+ self.data['title'] = sprintf(schedule_session_page_title, session['name'])
16
+
17
+ self.data['session'] = session
18
+
19
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'schedule', 'session.html'))
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,26 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class ScheduleSessionsPage < Page
4
+ def initialize(site, base, dir, 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
+ self.data['title'] = site.config['schedule_sessions_title'] || 'Schedule: Sessions'
15
+
16
+ sessionsData = []
17
+
18
+ self.data['sessions'] = sessions
19
+ self.data['dates'] = dates
20
+
21
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'schedule', 'sessions.html'))
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,37 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class SponsorGenerator < ::Jekyll::Generator
4
+ safe true
5
+
6
+ def generate(site)
7
+ if site.config['attendease']['has_sponsors']
8
+ @attendease_data_path = File.join(site.source, '_attendease', 'data')
9
+ sponsors = JSON.parse(File.read("#{@attendease_data_path}/sponsors.json"))
10
+
11
+ sponsor_levels = site.config['attendease']['event']['sponsor_levels']
12
+ sponsor_levels.each do |level|
13
+ level['sponsors'] = []
14
+ end
15
+
16
+ sponsors.each do |sponsor|
17
+ level = sponsor_levels.select { |m| m['_id'] == sponsor['level_id'] }.first
18
+ level['sponsors'] << sponsor
19
+ end
20
+
21
+ # make this available to any page that wants it
22
+ site.config['attendease']['sponsor_levels'] = sponsor_levels
23
+
24
+ # /sponsors pages.
25
+ dir = site.config['attendease']['sponsors_path_name']
26
+
27
+ site.pages << SponsorsIndexPage.new(site, site.source, File.join(dir), site.config['attendease']['sponsor_levels'])
28
+
29
+ #sponsors.each do |sponsor|
30
+ # site.pages << SponsorPage.new(site, site.source, File.join(dir, EventData.parameterize(sponsor['name']) + '.html', '_'), sponsor)
31
+ #end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,23 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class SponsorsIndexPage < Page
4
+ def initialize(site, base, dir, sponsor_levels)
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'), 'sponsors.html')
13
+
14
+ self.data['title'] = site.config['sponsors_index_title'] || 'Sponsors'
15
+
16
+ self.data['sponsor_levels'] = sponsor_levels
17
+
18
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'sponsors', 'index.html'))
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,65 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class AuthScriptTag < Liquid::Tag
4
+ def render(context)
5
+ api_host = context.registers[:site].config['attendease']['api_host']
6
+ '<script type="text/javascript" src="' + api_host + 'assets/attendease_event/auth.js"></script>'
7
+ end
8
+ end
9
+
10
+ class SchedulerScriptTag < Liquid::Tag
11
+ def render(context)
12
+ api_host = context.registers[:site].config['attendease']['api_host']
13
+ '<script type="text/javascript" src="' + api_host + 'assets/attendease_event/schedule.js"></script>'
14
+ end
15
+ end
16
+
17
+ class LocalesScriptTag < Liquid::Tag
18
+ def render(context)
19
+ locale = context.registers[:site].config['attendease']['locale']
20
+ '<script type="text/javascript">String.locale="' + locale + '";String.toLocaleString("/api/lingo.json");</script>'
21
+ end
22
+ end
23
+
24
+ class TranslateTag < Liquid::Tag
25
+ def initialize(tag_name, params, tokens)
26
+ super
27
+ args = split_params(params)
28
+ @key = args.shift
29
+ @options = { 't_size' => 0 }
30
+ if args.length
31
+ args.each do |a|
32
+ match = a.match(/^(.+):\s*(.+)$/)
33
+ @options[match[1]] = match[2].to_i if match
34
+ end
35
+ end
36
+ end
37
+
38
+ def split_params(params)
39
+ params.split(",").map(&:strip)
40
+ end
41
+
42
+ def render(context)
43
+ I18n::Backend::Simple.include(I18n::Backend::Pluralization)
44
+ I18n.enforce_available_locales = false
45
+ i18n_path = File.join(context.registers[:site].config['source'], '_attendease', 'data', 'lingo.yml')
46
+ I18n.load_path << i18n_path unless I18n.load_path.include?(i18n_path)
47
+ I18n.locale = context.registers[:page]['lang'] || context.registers[:site].config['attendease']['locale'] || context.registers[:site].config['attendease']['lang'] || :en
48
+ I18n.t(@key, :count => @options['t_size'])
49
+ end
50
+ end
51
+
52
+ class AuthAccountTag < Liquid::Tag
53
+ def render(context)
54
+ '<div id="attendease-auth-account"></div>'
55
+ end
56
+ end
57
+
58
+ class AuthActionTag < Liquid::Tag
59
+ def render(context)
60
+ '<div id="attendease-auth-action"></div>'
61
+ end
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,24 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class VenuePage < Page
4
+ def initialize(site, base, dir, venue)
5
+ @site = site
6
+ @base = base
7
+ @dir = dir
8
+ @name = venue['slug']
9
+
10
+ self.process(@name)
11
+
12
+ self.read_yaml(File.join(base, 'attendease_layouts'), 'venues.html')
13
+
14
+ venue_page_title = site.config['venue_page_title'] ? site.config['venue_page_title'] : 'Venue: %s'
15
+ self.data['title'] = sprintf(venue_page_title, venue['name'])
16
+
17
+ self.data['venue'] = venue
18
+
19
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'venues', 'venue.html'))
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,23 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ class VenuesIndexPage < Page
4
+ def initialize(site, base, dir, venues)
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'), 'venues.html')
13
+
14
+ self.data['title'] = site.config['venues_index_title'] || 'Venues'
15
+
16
+ self.data['venues'] = venues
17
+
18
+ self.content = File.read(File.join(base, '_attendease', 'templates', 'venues', 'index.html'))
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,6 @@
1
+ module Jekyll
2
+ module AttendeasePlugin
3
+ VERSION = "0.6.0"
4
+ end
5
+ end
6
+
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jekyll::AttendeasePlugin::EventDataGenerator do
4
+
5
+ it 'creates the Attendease stub pages' do
6
+ template_files = Dir.chdir(@template_root) { Dir.glob('*/**.html') }
7
+
8
+ template_files.each do |template_file|
9
+ path = File.join(@site.config['source'], '_attendease', 'templates', template_file)
10
+ expect(File.exists?(path)).to eq(true)
11
+ expect(File.size(path)).to > 0
12
+ end
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jekyll::AttendeasePlugin::EventLayoutGenerator do
4
+
5
+ it 'creates the layout stubs' do
6
+ %w{ layout register schedule presenters venues sponsors }.each do |layout|
7
+ expect(File.exists?(File.join(@site.source, 'attendease_layouts', "#{layout}.html"))).to eq(true)
8
+ end
9
+ end
10
+
11
+ end
12
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe "Jekyll Attendease filters" do
4
+ let(:context) { { :registers => { :site => @site, :page => {} } } }
5
+
6
+ def render(content)
7
+ ::Liquid::Template.parse(content).render({}, context)
8
+ end
9
+
10
+ context "{{ 'foo Bar bat' | slugify %}" do
11
+ subject { render("{{ 'foo Bar bat' | slugify }}") }
12
+ it { is_expected.to eq "foo_bar_bat" }
13
+ end
14
+ end
15
+
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jekyll::AttendeasePlugin::PreZeroPointSixLinkRedirectGenerator do
4
+
5
+ context 'in a site with config.attendease.redirect_ugly_urls = true' do
6
+ before(:all) do
7
+ @site = build_site({ 'attendease' => { 'redirect_ugly_urls' => true } })
8
+ @schedule_generator = find_generator(Jekyll::AttendeasePlugin::ScheduleGenerator)
9
+ end
10
+
11
+ it 'creates a redirect file from the old presenter.id URL to the new slug' do
12
+ file = File.join(@site.config['destination'], @site.config['attendease']['presenters_path_name'], @schedule_generator.presenters.first['id'], 'index.html')
13
+
14
+ expect(File.exists?(file)).to eq(true)
15
+ expect(File.file?(file)).to eq(true)
16
+ expect(File.read(file)).to include @schedule_generator.presenters.first['slug']
17
+ expect(File.read(file)).to_not include 'My awesome'
18
+ end
19
+
20
+ it 'creates a redirect file from the old venue.id URL to the new slug' do
21
+ file = File.join(@site.config['destination'], @site.config['attendease']['venues_path_name'], @schedule_generator.venues.first['id'], 'index.html')
22
+
23
+ expect(File.exists?(file)).to eq(true)
24
+ expect(File.file?(file)).to eq(true)
25
+ expect(File.read(file)).to include @schedule_generator.venues.first['slug']
26
+ expect(File.read(file)).to_not include 'My awesome'
27
+ end
28
+
29
+ it 'creates a redirect file from the old session.code URL to the new slug' do
30
+ file = File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], @schedule_generator.sessions.first['code'], 'index.html')
31
+
32
+ expect(File.exists?(file)).to eq(true)
33
+ expect(File.file?(file)).to eq(true)
34
+ expect(File.read(file)).to include @schedule_generator.sessions.first['slug']
35
+ expect(File.read(file)).to_not include 'My awesome'
36
+ end
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jekyll::AttendeasePlugin::ScheduleGenerator do
4
+
5
+ before(:all) do
6
+ @schedule_generator = find_generator(described_class)
7
+ @date = @schedule_generator.event['dates'].first['date']
8
+ @session_slug = @schedule_generator.sessions.first['slug']
9
+ @presenter_slug = @schedule_generator.presenters.first['slug']
10
+ @venue_slug = Jekyll::AttendeasePlugin::EventDataGenerator.parameterize(@schedule_generator.venues.first['name'], '_') + '.html'
11
+ end
12
+
13
+ it 'creates a presenters index page' do
14
+ file = File.join(@site.config['destination'], @site.config['attendease']['presenters_path_name'], 'index.html')
15
+ expect(File.exists?(file)).to eq(true)
16
+ expect(File.file?(file)).to eq(true)
17
+ end
18
+
19
+ it 'creates a presenter page' do
20
+ file = File.join(@site.config['destination'], @site.config['attendease']['presenters_path_name'], @presenter_slug)
21
+ expect(File.exists?(file)).to eq(true)
22
+ expect(File.file?(file)).to eq(true)
23
+ end
24
+
25
+ it 'creates a venue index page' do
26
+ file = File.join(@site.config['destination'], @site.config['attendease']['venues_path_name'], 'index.html')
27
+ expect(File.exists?(file)).to eq(true)
28
+ expect(File.file?(file)).to eq(true)
29
+ end
30
+
31
+ it 'creates a venue page' do
32
+ file = File.join(@site.config['destination'], @site.config['attendease']['venues_path_name'], @venue_slug)
33
+ expect(File.exists?(file)).to eq(true)
34
+ expect(File.file?(file)).to eq(true)
35
+ end
36
+
37
+ it 'creates a schedule index page' do
38
+ file = File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'index.html')
39
+ expect(File.exists?(file)).to eq(true)
40
+ expect(File.file?(file)).to eq(true)
41
+ end
42
+
43
+ it 'creates a schedule day index page' do
44
+ file = File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], @date, 'index.html')
45
+ expect(File.exists?(file)).to eq(true)
46
+ expect(File.file?(file)).to eq(true)
47
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'index.html'))).to include 'attendease-session-and-instance'
48
+ end
49
+
50
+ it 'creates a schedule sessions index page' do
51
+ file = File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', 'index.html')
52
+ expect(File.exists?(file)).to eq(true)
53
+ expect(File.file?(file)).to eq(true)
54
+ end
55
+
56
+ it 'creates a schedule session page' do
57
+ file = File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', @session_slug)
58
+ expect(File.exists?(file)).to eq(true)
59
+ expect(File.file?(file)).to eq(true)
60
+ end
61
+
62
+ context 'presenter linking' do
63
+ it 'links presenters correctly from the presenter index page' do
64
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['presenters_path_name'], 'index.html'))).to include @presenter_slug
65
+ end
66
+
67
+ it 'links presenters correctly from the session page' do
68
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', @session_slug))).to include @presenter_slug
69
+ end
70
+ end
71
+
72
+ context 'venue linking' do
73
+ it 'links venues correctly from the venue index page' do
74
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['venues_path_name'], 'index.html'))).to include @venue_slug
75
+ end
76
+
77
+ it 'links venues correctly from the presenter page' do
78
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['presenters_path_name'], @presenter_slug))).to include @venue_slug
79
+ end
80
+
81
+ it 'links venues correctly from the session page' do
82
+ expect(File.read(File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', @session_slug))).to include @venue_slug
83
+ end
84
+ end
85
+
86
+
87
+ context 'in a site with attendease.show_day_index = true' do
88
+ it 'creates the day index page' do
89
+ site = build_site({ 'attendease' => { 'show_day_index' => true } })
90
+ expect(File.read(File.join(site.config['destination'], site.config['attendease']['schedule_path_name'], 'index.html'))).to_not include 'attendease-session-and-instance'
91
+ end
92
+ end
93
+
94
+ context 'in a site with attendease.session_slug_uses_code = true' do
95
+ it 'creates a schedule session page' do
96
+ @site = build_site({ 'attendease' => { 'session_slug_uses_code' => true } })
97
+ @schedule_generator = find_generator(described_class)
98
+ session_slug = @schedule_generator.sessions.first['slug']
99
+
100
+ expect(File.exists?(File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', session_slug))).to eq(true)
101
+ end
102
+ end
103
+ end
104
+