jekyll-attendease 0.9.2 → 0.9.3

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
- SHA256:
3
- metadata.gz: f496291ebc4d6359cac73f3a3eee3c84768744594126c8d80ae394d797190ffa
4
- data.tar.gz: 86a4d88e946251c8def7844b9404284f423d3ca199de33c030fac53b62792f9d
2
+ SHA1:
3
+ metadata.gz: f34a3a54e23f0d3b76b52f58ab12428d001bb44f
4
+ data.tar.gz: 7ccb50dc81a6afa20724df44d60fdf2481603a66
5
5
  SHA512:
6
- metadata.gz: 87d208fcee1792a570b9c1d09ba825d8fe01ec552d0fd7ec4afb7bca9328a791c1e22a1fe8d358bff272de8ffef1ca01fcf25319d1f69fa3ca4d832cec103e1e
7
- data.tar.gz: b98b38e79b3e73a194794507febc8297e256e266bcea91da418c9ca76a519c2e2fc88097040fa63069ec13cacd49560ead3ae5a58736f65c961b931389870647
6
+ metadata.gz: e2eafd219f7d4901da9cc9da5927385ee45ae83a298c920fb3b07285f5247d086e4ff5ae51e96e9c0b656bf2a53be4985a0ff3da5586a32b9679c450f474979e
7
+ data.tar.gz: 34457707f96c7b80acab36729f5ffc9a0b8b6203a16e4cf0cf5ba13e05aa539bb31c64136e92ee74650ad27eb583187cb6d57883bbe19c6feb852b057242e4df
@@ -17,4 +17,3 @@ attendease:
17
17
  has_rooms: false
18
18
  has_filters: false
19
19
  has_venues: false
20
- has_mappable: false
@@ -2,6 +2,7 @@ module Jekyll
2
2
  module AttendeasePlugin
3
3
  class SitePagesGenerator < Generator
4
4
  safe true
5
+ PLACEHOLDER_REGEX = /\{\{/.freeze
5
6
 
6
7
  # site.config:
7
8
  # Is where you can find the configs generated for your site
@@ -25,14 +26,19 @@ module Jekyll
25
26
  if site.config.event?
26
27
  keys.each do |key|
27
28
  i[key].each do |k, v|
28
- if v.is_a?(String) && v.match(/\{\{/)
29
+ if placeholder?(v)
29
30
  # maintain the {{ t.foo }} variables
30
31
  v.gsub!(/(\{\{\s*t\.[a-z_.]+\s*\}\})/, '{% raw %}\1{% endraw %}')
31
- i[key][k] = Liquid::Template.parse(v).render('event' => site.data['event'], 'mappable' => site.data['mappable'])
32
+ i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])
32
33
  end
33
34
  end
34
35
  end
36
+
37
+ unless site.data['mappable'].nil? || site.data['mappable'].empty?
38
+ perform_substitution!(i, 'mappable' => site.data['mappable'])
39
+ end
35
40
  end
41
+
36
42
  zones[i['zone']] = [] if zones[i['zone']].nil?
37
43
  zones[i['zone']] << i
38
44
  end
@@ -57,6 +63,36 @@ module Jekyll
57
63
  end
58
64
  end
59
65
  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
60
96
  end
61
97
  end
62
98
  end
@@ -1,5 +1,6 @@
1
1
  module Jekyll
2
2
  module AttendeasePlugin
3
- VERSION = '0.9.2'
3
+ VERSION = '0.9.3'
4
4
  end
5
5
  end
6
+
@@ -23,6 +23,14 @@ RSpec.describe Jekyll::AttendeasePlugin::SitePagesGenerator do
23
23
  expect(File.exists?(file)).to eq(true)
24
24
  expect(File.file?(file)).to eq(true)
25
25
  end
26
+
27
+ it 'parses mappable placeholders' do
28
+ slug = page['slug']
29
+ file = File.join(site.config['destination'], slug, 'index.json')
30
+ json = JSON.parse(File.read(file))
31
+ expect(json['dropzone1'][0]['content']['text']).to eq('Hello world')
32
+ expect(json['dropzone1'][0]['preferences']['foo']).to eq('Hello world')
33
+ end
26
34
  end
27
35
 
28
36
  context 'page with XSS' do
@@ -83,6 +83,7 @@ RSpec.configure do |config|
83
83
  'has_rooms' => true,
84
84
  'has_filters' => true,
85
85
  'has_venues' => true,
86
+ 'has_mappable' => true,
86
87
  'environment' => 'test',
87
88
  'locale' => 'en',
88
89
  'source_id' => 'foobar',
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.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Wood
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-03-20 00:00:00.000000000 Z
15
+ date: 2020-04-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: httparty
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubyforge_project:
242
- rubygems_version: 2.7.7
242
+ rubygems_version: 2.6.14.4
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Attendease event helper for Jekyll