locomotivecms_steam 1.5.1 → 1.5.2

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
  SHA256:
3
- metadata.gz: b39383656db0b143ed8aa7df54aa656ed34d7104ea4b201a5be7ad87bc6c5005
4
- data.tar.gz: 83e94cde0a6206f0cab0c2908cf1159a1c389cc55f4534c8883d0843b22ececa
3
+ metadata.gz: 8dcf9666c7fcd392c8570476374e32a3db2492bc9a56449e0faa0667a87dcb5d
4
+ data.tar.gz: e92dbc7da55147cba7c476fa088ee28fda6e7da0aadcad796d97e20f70de13f0
5
5
  SHA512:
6
- metadata.gz: c04b7ed843d8c66d1eff244521db444db057ccf40a67b71fff9cced61d5107a2d63c6417856a77af1f48d42a223d9af92ae567a65940a0705c216e6e506c9c97
7
- data.tar.gz: fa161306ac9c4752c2693cffca31d737bc4a622055a104ae226c7f44bd0ace67ab69f1201690bfcb23aea7ea436452257d2d35deeb7ddcba18839fe5169dd250
6
+ metadata.gz: 6a5d931f8f0fe0007a45422a0d256dd93de213f450246c103a682f95829a5c75b4f9c4069142e3e166736a87a9b1f03bda40a1035165b5bfbc024017b8303b82
7
+ data.tar.gz: f5cedd73e0abb3a7f7b9309a778b3e9ee5bacaa9eb54cbe3adaef787322ad829bd9cef78769804bd553a0844fc994d94f346f8835a66cafefec8afa956e40641
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.5.1)
4
+ locomotivecms_steam (1.5.2)
5
5
  RedCloth (~> 4.3.2)
6
6
  autoprefixer-rails (~> 8.0.0)
7
7
  bcrypt (~> 3.1.11)
@@ -73,7 +73,7 @@ GEM
73
73
  term-ansicolor (~> 1.3)
74
74
  thor (>= 0.19.4, < 2.0)
75
75
  tins (~> 1.6)
76
- crass (1.0.5)
76
+ crass (1.0.6)
77
77
  diff-lcs (1.3)
78
78
  docile (1.3.2)
79
79
  dragonfly (1.2.0)
@@ -82,7 +82,7 @@ GEM
82
82
  rack (>= 1.3)
83
83
  duktape (2.0.1.1)
84
84
  execjs (2.7.0)
85
- ffi (1.11.3)
85
+ ffi (1.12.1)
86
86
  flamegraph (0.9.5)
87
87
  haml (5.0.4)
88
88
  temple (>= 0.8.0)
@@ -116,7 +116,7 @@ GEM
116
116
  mimetype-fu (0.1.2)
117
117
  mini_mime (1.0.2)
118
118
  mini_portile2 (2.4.0)
119
- minitest (5.13.0)
119
+ minitest (5.14.0)
120
120
  moneta (1.0.0)
121
121
  mongo (2.8.0)
122
122
  bson (>= 4.4.2, < 5.0.0)
@@ -131,7 +131,7 @@ GEM
131
131
  origin (2.3.1)
132
132
  pony (1.13.1)
133
133
  mail (>= 2.0)
134
- public_suffix (4.0.2)
134
+ public_suffix (4.0.3)
135
135
  puma (4.3.1)
136
136
  nio4r (~> 2.0)
137
137
  rack (2.0.8)
@@ -16,7 +16,7 @@ module Locomotive
16
16
 
17
17
  def parse_attributes(markup, default = {})
18
18
  @attributes = default || {}
19
- @raw_attributes = {}
19
+ @raw_attributes = @attributes.dup
20
20
 
21
21
  return if markup.blank?
22
22
 
@@ -24,13 +24,14 @@ module Locomotive
24
24
  _key = key.to_sym
25
25
 
26
26
  @attributes[_key] = block_given? ? yield(value) : ::Liquid::Expression.parse(value)
27
- @raw_attributes[_key] = value
27
+ @raw_attributes[_key] = @attributes[_key]
28
28
  end
29
29
  end
30
30
 
31
- def evaluate_attributes(context)
32
- @attributes = @attributes.transform_values do |attribute|
33
- context.evaluate(attribute)
31
+ def evaluate_attributes(context, lax: false)
32
+ @attributes = @raw_attributes.transform_values do |value|
33
+ _value = context.evaluate(value)
34
+ lax && _value.nil? ? value&.name : _value
34
35
  end
35
36
  end
36
37
 
@@ -22,7 +22,7 @@ module Locomotive
22
22
  end
23
23
 
24
24
  def render_path(context, &block)
25
- evaluate_attributes(context)
25
+ evaluate_attributes(context, lax: true)
26
26
 
27
27
  set_vars_from_context(context)
28
28
 
@@ -86,11 +86,11 @@ module Locomotive
86
86
  end
87
87
 
88
88
  def locale
89
- attributes[:locale] || raw_attributes[:locale] || @locale
89
+ attributes[:locale] || @locale
90
90
  end
91
91
 
92
92
  def template_slug
93
- attributes[:with] || raw_attributes[:with]
93
+ attributes[:with]
94
94
  end
95
95
 
96
96
  def set_vars_from_context(context)
@@ -18,6 +18,9 @@ module Locomotive
18
18
 
19
19
  parse_attributes(markup, fixed: false, inline_editing: true)
20
20
 
21
+ # we don't allow dynamic attributes
22
+ evaluate_attributes(::Liquid::Context.new, lax: true)
23
+
21
24
  set_label_and_slug
22
25
  else
23
26
  raise ::Liquid::SyntaxError.new("Valid syntax: #{tag_name} <slug>(, <options>)")
@@ -5,24 +5,14 @@ module Locomotive
5
5
 
6
6
  class Snippet < ::Liquid::Include
7
7
 
8
- attr_reader :template_name
9
-
10
- def initialize(tag_name, markup, options)
11
- super
12
-
13
- if markup =~ Syntax
14
- @template_name = $1
15
- end
16
- end
17
-
18
8
  def parse(tokens)
19
- ActiveSupport::Notifications.instrument('steam.parse.include', page: parse_context[:page], name: template_name)
20
-
21
9
  # look for editable elements (only used by the Engine)
22
10
  # In the next version of Locomotive (v5), we won't support the editable elements
23
- #
24
11
  # NOTE: it doesn't support dynamically choosen template
25
- #
12
+ template_name = template_name_expr.respond_to?(:name) ? template_name_expr.name : template_name_expr
13
+
14
+ ActiveSupport::Notifications.instrument('steam.parse.include', page: parse_context[:page], name: template_name)
15
+
26
16
  if parse_context[:snippet_finder] && snippet = parse_context[:snippet_finder].find(template_name)
27
17
  parse_context[:parser]._parse(snippet, parse_context.merge(snippet: template_name))
28
18
  end
@@ -37,9 +27,9 @@ module Locomotive
37
27
  rescue ::Liquid::ArgumentError
38
28
  # NOTE: Locomotive site developers should always use quotes (or doubles quotes) for the name of a snippet.
39
29
  # Unfortunately, a lot of sites don't use them. So here is a little patch to not break those sites.
40
- Locomotive::Common::Logger.warn("Use quotes if the name of your snippet (#{template_name}) is not dynamic.")
30
+ Locomotive::Common::Logger.warn("Use quotes if the name of your snippet (#{template_name_expr.name}) is not dynamic.")
41
31
 
42
- @template_name_expr = template_name
32
+ @template_name_expr = template_name_expr.name
43
33
 
44
34
  super
45
35
  end
@@ -19,8 +19,9 @@ module Locomotive
19
19
  include Concerns::Attributes
20
20
 
21
21
  # Regexps and Arrays are allowed
22
- ArrayFragment = /\[(\s*(#{::Liquid::QuotedFragment},\s*)*#{::Liquid::QuotedFragment}\s*)\]/o.freeze
23
- RegexpFragment = /\/([^\/]+)\/([imx]+)?/o.freeze
22
+ ArrayFragment = /\[(\s*(#{::Liquid::QuotedFragment},\s*)*#{::Liquid::QuotedFragment}\s*)\]/o.freeze
23
+ RegexpFragment = /\/([^\/]+)\/([imx]+)?/o.freeze
24
+ StrictRegexpFragment = /\A#{RegexpFragment}\z/o.freeze
24
25
 
25
26
  # a slight different from the Shopify implementation because we allow stuff like `started_at.le`
26
27
  TagAttributes = /([a-zA-Z_0-9\.]+)\s*\:\s*(#{ArrayFragment}|#{RegexpFragment}|#{::Liquid::QuotedFragment})/o.freeze
@@ -66,7 +67,7 @@ module Locomotive
66
67
 
67
68
  def parse_attribute(value)
68
69
  case value
69
- when RegexpFragment
70
+ when StrictRegexpFragment
70
71
  # let the cast_value attribute create the Regexp (done during the rendering phase)
71
72
  value
72
73
  when ArrayFragment
@@ -94,8 +95,8 @@ module Locomotive
94
95
 
95
96
  def cast_value(context, value)
96
97
  case value
97
- when Array then value.map { |_value| cast_value(context, _value) }
98
- when RegexpFragment then create_regexp($1, $2)
98
+ when Array then value.map { |_value| cast_value(context, _value) }
99
+ when StrictRegexpFragment then create_regexp($1, $2)
99
100
  else
100
101
  _value = context.evaluate(value)
101
102
  _value.respond_to?(:_id) ? _value.send(:_source) : _value
@@ -3,6 +3,6 @@
3
3
  # 1.0.0.alpha < 1.0.0.alpha1 < 1.0.0.beta < 1.0.0.beta2 < 1.0.0.beta11 < 1.0.0.rc1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.5.1'
6
+ VERSION = '1.5.2'
7
7
  end
8
8
  end
@@ -76,10 +76,11 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
76
76
 
77
77
  context 'with a defined label' do
78
78
 
79
- let(:source) { "{% editable_text 'first_column', label: 'Column #1' %}{% endeditable_text %}" }
79
+ let(:source) { "{% editable_text 'first_column', label: 'Column #1', format: raw %}{% endeditable_text %}" }
80
80
 
81
81
  it { is_expected.to include(slug: 'first_column') }
82
82
  it { is_expected.to include(label: 'Column #1') }
83
+ it { is_expected.to include(format: 'raw') }
83
84
 
84
85
  end
85
86
 
@@ -35,13 +35,14 @@ describe Locomotive::Steam::Liquid::Tags::PathTo do
35
35
 
36
36
  describe 'from a handle of a page' do
37
37
 
38
+ let(:locales) { ['en', 'fr', 'es']}
38
39
  let(:drop) { Locomotive::Steam::Liquid::Drops::Page.new(page) }
39
40
  let(:page) { liquid_instance_double('Index', title: 'Index', handle: 'index', fullpath: fullpath, localized_attributes: { fullpath: true }, templatized?: false) }
40
- let(:fullpath) { { en: 'index', fr: 'index' } }
41
+ let(:fullpath) { { en: 'index', fr: 'index', es: 'index' } }
41
42
  let(:source) { '{% path_to index %}' }
42
43
 
43
44
  before do
44
- expect(services.page_finder).to receive(:by_handle).with('index').and_return(page)
45
+ expect(services.page_finder).to receive(:by_handle).with('index').and_return(page).at_least(:once)
45
46
  allow(page).to receive(:to_liquid).and_return(drop)
46
47
  end
47
48
 
@@ -52,6 +53,14 @@ describe Locomotive::Steam::Liquid::Tags::PathTo do
52
53
  let(:source) { "{% path_to index, locale: 'fr' %}" }
53
54
  it { is_expected.to eq '/fr' }
54
55
 
56
+ context 'used as a variable' do
57
+
58
+ let(:assigns) { { 'locales' => locales } }
59
+ let(:source) { "{% for my_locale in locales %}{% path_to index, locale: my_locale %},{% endfor %}" }
60
+ it { is_expected.to eq '/,/fr,/es,' }
61
+
62
+ end
63
+
55
64
  end
56
65
 
57
66
  context 'the current locale in session is different from the requested locale' do
@@ -138,10 +138,11 @@ describe Locomotive::Steam::Liquid::Tags::WithScope do
138
138
 
139
139
  describe 'decode criteria with gt and lt' do
140
140
 
141
- let(:source) { "{% with_scope price.gt:42.0, price.lt:50, published_at.lte: '2019-09-10 00:00:00' %}{% assign conditions = with_scope %}{% endwith_scope %}" }
141
+ let(:source) { "{% with_scope price.gt:42.0, price.lt:50, published_at.lte: '2019-09-10 00:00:00', published_at.gte: '2019/09/09 00:00:00' %}{% assign conditions = with_scope %}{% endwith_scope %}" }
142
142
  it { expect(conditions['price.gt']).to eq 42.0 }
143
143
  it { expect(conditions['price.lt']).to eq 50 }
144
144
  it { expect(conditions['published_at.lte']).to eq '2019-09-10 00:00:00' }
145
+ it { expect(conditions['published_at.gte']).to eq '2019/09/09 00:00:00' }
145
146
 
146
147
  end
147
148
 
@@ -55,11 +55,11 @@ describe Locomotive::Steam::Middlewares::Cache do
55
55
 
56
56
  let(:response) { nil }
57
57
 
58
- before { expect(cache).to receive(:read).with('49876cf5daaa47d21daccd3b805b5b79').and_return(response) }
58
+ before { expect(cache).to receive(:read).with('2fae60bf8d7d9c0dce6cabcac8288267').and_return(response) }
59
59
 
60
60
  context 'the cache is empty' do
61
61
 
62
- before { expect(cache).to receive(:write).with('49876cf5daaa47d21daccd3b805b5b79', Marshal.dump([200, {}, ["Hello world!"]])) }
62
+ before { expect(cache).to receive(:write).with('2fae60bf8d7d9c0dce6cabcac8288267', Marshal.dump([200, {}, ["Hello world!"]])) }
63
63
 
64
64
  it 'tells the CDN to cache the page and also cache it internally' do
65
65
  is_expected.to eq ['max-age=0, s-maxage=3600, public, must-revalidate', 'Accept-Language']
@@ -69,7 +69,7 @@ describe Locomotive::Steam::Middlewares::Cache do
69
69
 
70
70
  subject { send_request[:env]['steam.cache_etag'] }
71
71
 
72
- it { is_expected.to eq '49876cf5daaa47d21daccd3b805b5b79' }
72
+ it { is_expected.to eq '2fae60bf8d7d9c0dce6cabcac8288267' }
73
73
 
74
74
  end
75
75
 
@@ -104,7 +104,7 @@ describe Locomotive::Steam::Middlewares::Cache do
104
104
 
105
105
  context 'based on the ETag' do
106
106
 
107
- let(:etag) { '49876cf5daaa47d21daccd3b805b5b79' }
107
+ let(:etag) { '2fae60bf8d7d9c0dce6cabcac8288267' }
108
108
 
109
109
  it 'returns a 304 (Not modified) without no cache headers' do
110
110
  expect(subject.first).to eq 304
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_steam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-01-05 00:00:00.000000000 Z
14
+ date: 2020-01-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake