jekyll-attendease 0.6.0 → 0.6.1

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: 80cd553e269268d96d6e3d33d06be1d4b80a36f0
4
- data.tar.gz: 1d431f5ea201940d4c49417bc2fc5d6385d7b6d3
3
+ metadata.gz: 00c6babd1870a4e7bf21953cac303f50e3279816
4
+ data.tar.gz: 42ddbde603be6c2d82b25ad25becd8248f4a88cf
5
5
  SHA512:
6
- metadata.gz: 0f860101c55c37f8c446edc468517f21a0e05ec2fd87c92a968c0a3de76f12ca64790502116d3cba71fc40901fee65f546eaed46b59a8e263c2e121541146b7b
7
- data.tar.gz: b08a45e2f9b07ce9cd974cd3d4362929068c56379eb92042418765ce1637dadd6e30ef5c7edc0d2667d2bd9b6ab408fbf4f78f19a2fadd360ac35ef9e1551bd7
6
+ metadata.gz: 3028a82d5c90d131c9cdfc2579d1ff3347ae14eaa1c97bffee5ecdab9cc7cae97004c338dbbaa7ca051d84f49c0a6d8da7c82e8dbd270b6a1d6dd27390bedfd2
7
+ data.tar.gz: a08e3ff4945fa97061a8e2575bc7c24085ffa35d2f6512fe381893bab7ea94403e17133b88d2a6793170990c983b22768157561b19ec634a14d8a121ea1a7ff3
@@ -6,6 +6,7 @@ require 'jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator'
6
6
  require 'jekyll/attendease_plugin/redirect_page'
7
7
  require 'jekyll/attendease_plugin/tags'
8
8
  require 'jekyll/attendease_plugin/filters'
9
+ require 'jekyll/attendease_plugin/helpers'
9
10
 
10
11
  require 'jekyll/attendease_plugin/presenters_index_page'
11
12
  require 'jekyll/attendease_plugin/presenter_page'
@@ -16,21 +16,6 @@ module Jekyll
16
16
  end
17
17
  end
18
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
19
  def use_cache?(file)
35
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
36
21
  end
@@ -53,6 +38,7 @@ module Jekyll
53
38
 
54
39
  data_files.each do |file_name|
55
40
  update_data = true
41
+ data = nil
56
42
 
57
43
  file = File.join(@attendease_data_path, file_name)
58
44
  if File.exists?(file) && use_cache?(file)
@@ -82,45 +68,48 @@ module Jekyll
82
68
  options.merge!(:headers => {'X-Event-Token' => @attendease_config['access_token']}) if @attendease_config['access_token']
83
69
 
84
70
  request_filename = file_name.gsub(/yml$/, 'yaml')
85
- data = get("#{@attendease_config['api_host']}api/#{request_filename}", options)
71
+ response = get("#{@attendease_config['api_host']}api/#{request_filename}", options)
86
72
 
87
73
  #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))
74
+ if (!response.nil? && response.response.is_a?(Net::HTTPOK))
89
75
  Jekyll.logger.info "[Attendease] Saving #{file_name} data..."
90
76
 
91
77
  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) }
78
+ data = response.parsed_response
79
+ File.open(file, 'w+') { |f| f.write(data.to_json) }
80
+ else # yaml
81
+ File.open(file, 'w+') { |f| f.write(response.body) }
95
82
  end
96
83
  else
97
84
  raise "Request failed for #{@attendease_config['api_host']}api/#{request_filename}. Is your Attendease api_host site properly in _config.yml?"
98
85
  end
99
86
  end
100
87
 
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]
88
+ if data.is_a?(Hash)
89
+ if file_name == 'site.json'
90
+ # Adding to site config so we can access these variables globally wihtout using a Liquid Tag so we can use if/else
91
+ site.config['attendease']['data'] = {}
92
+
93
+ data.keys.each do |tag|
94
+ site.config['attendease']['data'][tag] = data[tag]
95
+ # memorandum from the department of redundancy department:
96
+ # --------------------------------------------------------
97
+ # support accessing the attendease_* variables without the
98
+ # attendease_ prefix because they're already namespaced in
99
+ # site.attendease.data
100
+ #
101
+ # TODO: update all themes to not use attendease_ variables
102
+ # and then retire them from the ThemeManager.
103
+ if tag.match(/^attendease_/)
104
+ site.config['attendease']['data'][tag.gsub(/^attendease_/, '')] = data[tag]
105
+ end
117
106
  end
118
- end
119
- elsif file_name == 'event.json'
120
- site.config['attendease']['event'] = {}
107
+ elsif file_name == 'event.json'
108
+ site.config['attendease']['event'] = {}
121
109
 
122
- data.keys.each do |tag|
123
- site.config['attendease']['event'][tag] = data[tag]
110
+ data.keys.each do |tag|
111
+ site.config['attendease']['event'][tag] = data[tag]
112
+ end
124
113
  end
125
114
  end
126
115
  end
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module AttendeasePlugin
3
3
  module Filters
4
4
  def slugify(string)
5
- EventDataGenerator.parameterize(string, '_')
5
+ Helpers.parameterize(string, '_')
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+ module Jekyll
3
+ module AttendeasePlugin
4
+ class Helpers
5
+ def self.parameterize(source, sep = '_')
6
+ return '' if source.nil?
7
+
8
+ string = Helpers.convert_to_ascii(source.downcase)
9
+
10
+ unless sep.nil? || sep.empty?
11
+ # Turn unwanted chars into the separator
12
+ string.gsub!(/[^a-z0-9]+/, sep)
13
+
14
+ re_sep = Regexp.escape(sep)
15
+ # No more than one of the separator in a row.
16
+ string.gsub!(/#{re_sep}{2,}/, sep)
17
+ # Remove leading/trailing separator.
18
+ string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
19
+ end
20
+ string
21
+ end
22
+
23
+ def self.convert_to_ascii(s)
24
+ undefined = ''
25
+ fallback = {'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A',
26
+ 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E',
27
+ 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I',
28
+ 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
29
+ 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U',
30
+ 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'à' => 'a', 'á' => 'a',
31
+ 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae',
32
+ 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
33
+ 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ñ' => 'n',
34
+ 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o',
35
+ 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u',
36
+ 'ý' => 'y', 'ÿ' => 'y' }
37
+ s.encode('ASCII',
38
+ fallback: lambda { |c| fallback.key?(c) ? fallback[c] : undefined })
39
+ end
40
+ end
41
+ end
42
+ end
@@ -24,7 +24,7 @@ module Jekyll
24
24
  # sessions
25
25
  dir = site.config['attendease']['schedule_path_name']
26
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']))
27
+ site.pages << RedirectPage.new(site, site.source, File.join(dir, o['code']), File.join('/', dir, 'sessions', o['slug']))
28
28
  end
29
29
  end
30
30
  end # end generate
@@ -27,18 +27,18 @@ module Jekyll
27
27
  @venues = JSON.parse(File.read("#{attendease_data_path}/venues.json")).sort{|v1, v2| v1['name'] <=> v2['name']}
28
28
 
29
29
  @presenters.each do |presenter|
30
- presenter['slug'] = EventDataGenerator.parameterize("#{presenter['first_name']} #{presenter['last_name']}", '_') + '.html'
30
+ presenter['slug'] = Helpers.parameterize("#{presenter['first_name']} #{presenter['last_name']}") + '.html'
31
31
  end
32
32
 
33
33
  @venues.each do |venue|
34
- venue['slug'] = EventDataGenerator.parameterize(venue['name'], '_') + '.html'
34
+ venue['slug'] = Helpers.parameterize(venue['name']) + '.html'
35
35
  end
36
36
 
37
37
  sessions.each do |session|
38
38
  if site.config['attendease']['session_slug_uses_code']
39
39
  session['slug'] = session['code'] + '.html'
40
40
  else
41
- session['slug'] = EventDataGenerator.parameterize(session['name'], '_') + '.html'
41
+ session['slug'] = Helpers.parameterize(session['name']) + '.html'
42
42
  end
43
43
  end
44
44
 
@@ -49,41 +49,47 @@ module Jekyll
49
49
  # /schedule pages.
50
50
  dir = site.config['attendease']['schedule_path_name']
51
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
52
+ unless dir.nil?
53
+ if (site.config['attendease'] && site.config['attendease']['show_day_index'])
54
+ site.pages << ScheduleIndexPage.new(site, site.source, File.join(dir), @event['dates'])
55
+ else
56
+ site.pages << ScheduleDayPage.new(site, site.source, File.join(dir), @event['dates'].first, @sessions, @event['dates'])
57
+ end
57
58
 
58
- site.pages << ScheduleSessionsPage.new(site, site.source, File.join(dir, 'sessions'), @sessions, @event['dates'])
59
+ site.pages << ScheduleSessionsPage.new(site, site.source, File.join(dir, 'sessions'), @sessions, @event['dates'])
59
60
 
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
61
+ @event['dates'].each do |day|
62
+ site.pages << ScheduleDayPage.new(site, site.source, File.join(dir, day['date']), day, @sessions, @event['dates'])
63
+ end
63
64
 
64
- @sessions.each do |session|
65
- site.pages << ScheduleSessionPage.new(site, site.source, File.join(dir, 'sessions'), session)
65
+ @sessions.each do |session|
66
+ site.pages << ScheduleSessionPage.new(site, site.source, File.join(dir, 'sessions'), session)
67
+ end
66
68
  end
67
69
 
68
70
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69
71
  # /presenters pages.
70
72
  dir = site.config['attendease']['presenters_path_name']
71
73
 
72
- @presenters.each do |presenter|
73
- site.pages << PresenterPage.new(site, site.source, dir, presenter, @sessions)
74
- end
74
+ unless dir.nil?
75
+ @presenters.each do |presenter|
76
+ site.pages << PresenterPage.new(site, site.source, dir, presenter, @sessions)
77
+ end
75
78
 
76
- site.pages << PresentersIndexPage.new(site, site.source, File.join(dir), @presenters)
79
+ site.pages << PresentersIndexPage.new(site, site.source, File.join(dir), @presenters)
80
+ end
77
81
 
78
82
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79
83
  # /venue pages.
80
84
  dir = site.config['attendease']['venues_path_name']
81
85
 
82
- @venues.each do |venue|
83
- site.pages << VenuePage.new(site, site.source, dir, venue)
84
- end
86
+ unless dir.nil?
87
+ @venues.each do |venue|
88
+ site.pages << VenuePage.new(site, site.source, dir, venue)
89
+ end
85
90
 
86
- site.pages << VenuesIndexPage.new(site, site.source, File.join(dir), @venues)
91
+ site.pages << VenuesIndexPage.new(site, site.source, File.join(dir), @venues)
92
+ end
87
93
  end
88
94
  end
89
95
 
@@ -122,7 +128,7 @@ module Jekyll
122
128
  item_names = []
123
129
  if !filter['items'].nil?
124
130
  filter['items'].each do |item|
125
- filter_tags << EventDataGenerator.parameterize('attendease-filter-' + filter['name'] + "-" + item['name'])
131
+ filter_tags << Helpers.parameterize('attendease-filter-' + filter['name'] + "-" + item['name'], '-')
126
132
  end
127
133
  end
128
134
  end
@@ -24,10 +24,12 @@ module Jekyll
24
24
  # /sponsors pages.
25
25
  dir = site.config['attendease']['sponsors_path_name']
26
26
 
27
- site.pages << SponsorsIndexPage.new(site, site.source, File.join(dir), site.config['attendease']['sponsor_levels'])
27
+ unless dir.nil?
28
+ site.pages << SponsorsIndexPage.new(site, site.source, File.join(dir), site.config['attendease']['sponsor_levels'])
29
+ end
28
30
 
29
31
  #sponsors.each do |sponsor|
30
- # site.pages << SponsorPage.new(site, site.source, File.join(dir, EventData.parameterize(sponsor['name']) + '.html', '_'), sponsor)
32
+ # site.pages << SponsorPage.new(site, site.source, File.join(dir, Helpers.parameterize(sponsor['name']) + '.html', '_'), sponsor)
31
33
  #end
32
34
  end
33
35
  end
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  module AttendeasePlugin
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
6
6
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jekyll::AttendeasePlugin::Helpers do
4
+ context '#parameterize' do
5
+ it 'converts a typical filter item into a predictable CSS-friendly class name' do
6
+ expect(Jekyll::AttendeasePlugin::Helpers.parameterize('Super Hyper Advanced', '-')).to eq('super-hyper-advanced')
7
+ end
8
+
9
+ it 'converts a title to a snake-case style string' do
10
+ expect(Jekyll::AttendeasePlugin::Helpers.parameterize(' That quick brown fox? Jumps over the lazy dog...')).to eq('that_quick_brown_fox_jumps_over_the_lazy_dog')
11
+ end
12
+
13
+ it 'converts accented characters to an ASCII-equivalent' do
14
+ expect(Jekyll::AttendeasePlugin::Helpers.parameterize('Pepé Le Pew')).to eq('pepe_le_pew')
15
+ end
16
+
17
+ it 'will not repeat the separator' do
18
+ expect(Jekyll::AttendeasePlugin::Helpers.parameterize('What--the--hell?')).to eq('what_the_hell')
19
+ end
20
+
21
+ it 'will strip leading and trailing separators' do
22
+ expect(Jekyll::AttendeasePlugin::Helpers.parameterize('-, What--the--hell? ::')).to eq('what_the_hell')
23
+ end
24
+ end
25
+ end
@@ -7,7 +7,7 @@ RSpec.describe Jekyll::AttendeasePlugin::ScheduleGenerator do
7
7
  @date = @schedule_generator.event['dates'].first['date']
8
8
  @session_slug = @schedule_generator.sessions.first['slug']
9
9
  @presenter_slug = @schedule_generator.presenters.first['slug']
10
- @venue_slug = Jekyll::AttendeasePlugin::EventDataGenerator.parameterize(@schedule_generator.venues.first['name'], '_') + '.html'
10
+ @venue_slug = Jekyll::AttendeasePlugin::Helpers.parameterize(@schedule_generator.venues.first['name'], '_') + '.html'
11
11
  end
12
12
 
13
13
  it 'creates a presenters index page' do
@@ -83,7 +83,6 @@ RSpec.describe Jekyll::AttendeasePlugin::ScheduleGenerator do
83
83
  end
84
84
  end
85
85
 
86
-
87
86
  context 'in a site with attendease.show_day_index = true' do
88
87
  it 'creates the day index page' do
89
88
  site = build_site({ 'attendease' => { 'show_day_index' => true } })
@@ -100,5 +99,32 @@ RSpec.describe Jekyll::AttendeasePlugin::ScheduleGenerator do
100
99
  expect(File.exists?(File.join(@site.config['destination'], @site.config['attendease']['schedule_path_name'], 'sessions', session_slug))).to eq(true)
101
100
  end
102
101
  end
102
+
103
+ context 'in a site with the page paths set to nil' do
104
+ it 'no schedule folder exists' do
105
+ @site = build_site({ 'attendease' => { 'schedule_path_name' => nil } })
106
+
107
+ expect(File.exists?(File.join(@site.config['destination'], 'schedule'))).to eq(false)
108
+ end
109
+
110
+ it 'no presenters folder exists' do
111
+ @site = build_site({ 'attendease' => { 'presenters_path_name' => nil } })
112
+
113
+ expect(File.exists?(File.join(@site.config['destination'], 'presenters'))).to eq(false)
114
+ end
115
+
116
+ it 'no venues folder exists' do
117
+ @site = build_site({ 'attendease' => { 'venues_path_name' => nil } })
118
+
119
+ expect(File.exists?(File.join(@site.config['destination'], 'venues'))).to eq(false)
120
+ end
121
+
122
+ it 'no sponsors folder exists' do
123
+ @site = build_site({ 'attendease' => { 'sponsors_path_name' => nil } })
124
+
125
+ expect(File.exists?(File.join(@site.config['destination'], 'sponsors'))).to eq(false)
126
+ end
127
+ end
128
+
103
129
  end
104
130
 
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Wood
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-09 00:00:00.000000000 Z
13
+ date: 2014-07-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -133,6 +133,7 @@ files:
133
133
  - lib/jekyll/attendease_plugin/event_data_generator.rb
134
134
  - lib/jekyll/attendease_plugin/event_layout_generator.rb
135
135
  - lib/jekyll/attendease_plugin/filters.rb
136
+ - lib/jekyll/attendease_plugin/helpers.rb
136
137
  - lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator.rb
137
138
  - lib/jekyll/attendease_plugin/presenter_page.rb
138
139
  - lib/jekyll/attendease_plugin/presenters_index_page.rb
@@ -164,6 +165,7 @@ files:
164
165
  - spec/lib/jekyll/attendease_plugin/event_data_generator_spec.rb
165
166
  - spec/lib/jekyll/attendease_plugin/event_layout_generator_spec.rb
166
167
  - spec/lib/jekyll/attendease_plugin/filters_spec.rb
168
+ - spec/lib/jekyll/attendease_plugin/helpers_spec.rb
167
169
  - spec/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator_spec.rb
168
170
  - spec/lib/jekyll/attendease_plugin/schedule_generator_spec.rb
169
171
  - spec/lib/jekyll/attendease_plugin/sponsor_generator_spec.rb
@@ -198,6 +200,7 @@ test_files:
198
200
  - spec/lib/jekyll/attendease_plugin/event_data_generator_spec.rb
199
201
  - spec/lib/jekyll/attendease_plugin/event_layout_generator_spec.rb
200
202
  - spec/lib/jekyll/attendease_plugin/filters_spec.rb
203
+ - spec/lib/jekyll/attendease_plugin/helpers_spec.rb
201
204
  - spec/lib/jekyll/attendease_plugin/pre_zero_point_six_link_redirect_generator_spec.rb
202
205
  - spec/lib/jekyll/attendease_plugin/schedule_generator_spec.rb
203
206
  - spec/lib/jekyll/attendease_plugin/sponsor_generator_spec.rb