locomotivecms_steam 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -41
- data/lib/locomotive/steam/liquid/tags/concerns/attributes.rb +11 -98
- data/lib/locomotive/steam/liquid/tags/concerns/path.rb +6 -25
- data/lib/locomotive/steam/liquid/tags/consume.rb +3 -3
- data/lib/locomotive/steam/liquid/tags/inherited_block.rb +4 -3
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +25 -17
- data/lib/locomotive/steam/version.rb +1 -1
- data/locomotivecms_steam.gemspec +1 -3
- data/spec/unit/liquid/tags/paginate_spec.rb +1 -1
- data/spec/unit/liquid/tags/with_scope_spec.rb +1 -51
- data/spec/unit/middlewares/cache_spec.rb +4 -4
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df479f835f1f7233945c2da8f3df5e3bfa5186b225ded85197363c63b0c7c5b
|
4
|
+
data.tar.gz: d653e2259dccaa5e8d643c9019f7315bad2fdeb7b759d14997dd5ca87b554ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5269811d92d7853e44cfd9f481f1bf303e11cd5d99652dda98c02e46ec20f28b43f34a419594c3bdc87c8fba3130316c1c79b4528eb3782710522e8974c324ea
|
7
|
+
data.tar.gz: 5faee657e95f13b8a5ab305b149a8739c41c5e698f58715c299363f332a56974bc3011785b21b01fe0552ce64bc907bea25ca200e13acc3616b3e96d02ef7e7b
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.6.
|
4
|
+
locomotivecms_steam (1.6.1)
|
5
5
|
RedCloth (~> 4.3.2)
|
6
6
|
autoprefixer-rails (~> 8.0.0)
|
7
7
|
bcrypt (~> 3.1.11)
|
@@ -20,7 +20,6 @@ PATH
|
|
20
20
|
morphine (~> 0.1.1)
|
21
21
|
multi_json (~> 1.15.0)
|
22
22
|
nokogiri (>= 1.11, < 1.14)
|
23
|
-
parser (~> 2.7)
|
24
23
|
pony (~> 1.12)
|
25
24
|
rack-cache (~> 1.7.0)
|
26
25
|
rack-rewrite (~> 1.5.1)
|
@@ -29,28 +28,18 @@ PATH
|
|
29
28
|
sass (~> 3.4.25)
|
30
29
|
sprockets (~> 3.7.1)
|
31
30
|
uglifier (~> 4.1.3)
|
32
|
-
unparser (~> 0.4)
|
33
31
|
|
34
32
|
GEM
|
35
33
|
remote: https://rubygems.org/
|
36
34
|
specs:
|
37
35
|
RedCloth (4.3.2)
|
38
|
-
abstract_type (0.0.7)
|
39
36
|
activesupport (5.2.8.1)
|
40
37
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
41
38
|
i18n (>= 0.7, < 2)
|
42
39
|
minitest (~> 5.1)
|
43
40
|
tzinfo (~> 1.1)
|
44
|
-
adamantium (0.2.0)
|
45
|
-
ice_nine (~> 0.11.0)
|
46
|
-
memoizable (~> 0.4.0)
|
47
41
|
addressable (2.8.1)
|
48
42
|
public_suffix (>= 2.0.2, < 6.0)
|
49
|
-
anima (0.3.2)
|
50
|
-
abstract_type (~> 0.0.7)
|
51
|
-
adamantium (~> 0.2)
|
52
|
-
equalizer (~> 0.0.11)
|
53
|
-
ast (2.4.2)
|
54
43
|
attr_extras (5.2.0)
|
55
44
|
autoprefixer-rails (8.0.0)
|
56
45
|
execjs
|
@@ -75,9 +64,6 @@ GEM
|
|
75
64
|
sass (>= 3.3.0, < 3.5)
|
76
65
|
compass-import-once (1.0.5)
|
77
66
|
sass (>= 3.2, < 3.5)
|
78
|
-
concord (0.1.6)
|
79
|
-
adamantium (~> 0.2.0)
|
80
|
-
equalizer (~> 0.0.9)
|
81
67
|
concurrent-ruby (1.1.10)
|
82
68
|
coveralls (0.8.23)
|
83
69
|
json (>= 1.8, < 3)
|
@@ -93,7 +79,6 @@ GEM
|
|
93
79
|
multi_json (~> 1.0)
|
94
80
|
rack (>= 1.3)
|
95
81
|
duktape (2.0.1.1)
|
96
|
-
equalizer (0.0.11)
|
97
82
|
execjs (2.8.1)
|
98
83
|
ffi (1.15.5)
|
99
84
|
flamegraph (0.9.5)
|
@@ -107,7 +92,6 @@ GEM
|
|
107
92
|
concurrent-ruby (~> 1.0)
|
108
93
|
i18n-spec (0.6.0)
|
109
94
|
iso
|
110
|
-
ice_nine (0.11.2)
|
111
95
|
iso (0.4.0)
|
112
96
|
i18n
|
113
97
|
json (2.6.2)
|
@@ -124,8 +108,6 @@ GEM
|
|
124
108
|
stringex (~> 2.8.2)
|
125
109
|
mail (2.7.1)
|
126
110
|
mini_mime (>= 0.1.1)
|
127
|
-
memoizable (0.4.2)
|
128
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
129
111
|
memory_profiler (1.0.0)
|
130
112
|
mime-types (3.3.1)
|
131
113
|
mime-types-data (~> 3.2015)
|
@@ -138,13 +120,6 @@ GEM
|
|
138
120
|
mongo (2.13.3)
|
139
121
|
bson (>= 4.8.2, < 5.0.0)
|
140
122
|
morphine (0.1.1)
|
141
|
-
mprelude (0.1.0)
|
142
|
-
abstract_type (~> 0.0.7)
|
143
|
-
adamantium (~> 0.2.0)
|
144
|
-
concord (~> 0.1.5)
|
145
|
-
equalizer (~> 0.0.9)
|
146
|
-
ice_nine (~> 0.11.1)
|
147
|
-
procto (~> 0.0.2)
|
148
123
|
multi_json (1.15.0)
|
149
124
|
multi_xml (0.6.0)
|
150
125
|
nio4r (2.5.8)
|
@@ -154,11 +129,8 @@ GEM
|
|
154
129
|
nokogumbo (2.0.5)
|
155
130
|
nokogiri (~> 1.8, >= 1.8.4)
|
156
131
|
origin (2.3.1)
|
157
|
-
parser (2.7.2.0)
|
158
|
-
ast (~> 2.4.1)
|
159
132
|
pony (1.13.1)
|
160
133
|
mail (>= 2.0)
|
161
|
-
procto (0.0.3)
|
162
134
|
public_suffix (5.0.0)
|
163
135
|
puma (5.6.5)
|
164
136
|
nio4r (~> 2.0)
|
@@ -220,20 +192,9 @@ GEM
|
|
220
192
|
thread_safe (~> 0.1)
|
221
193
|
uglifier (4.1.20)
|
222
194
|
execjs (>= 0.3.0, < 3)
|
223
|
-
unparser (0.5.5)
|
224
|
-
abstract_type (~> 0.0.7)
|
225
|
-
adamantium (~> 0.2.0)
|
226
|
-
anima (~> 0.3.1)
|
227
|
-
concord (~> 0.1.5)
|
228
|
-
diff-lcs (~> 1.3)
|
229
|
-
equalizer (~> 0.0.9)
|
230
|
-
mprelude (~> 0.1.0)
|
231
|
-
parser (>= 2.6.5)
|
232
|
-
procto (~> 0.0.2)
|
233
195
|
|
234
196
|
PLATFORMS
|
235
197
|
ruby
|
236
|
-
x86_64-darwin-20
|
237
198
|
|
238
199
|
DEPENDENCIES
|
239
200
|
coveralls (~> 0.8.1)
|
@@ -255,4 +216,4 @@ DEPENDENCIES
|
|
255
216
|
timecop (~> 0.9.1)
|
256
217
|
|
257
218
|
BUNDLED WITH
|
258
|
-
2.
|
219
|
+
2.1.4
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'parser/current'
|
2
|
-
require 'unparser'
|
3
|
-
|
4
1
|
module Locomotive
|
5
2
|
module Steam
|
6
3
|
module Liquid
|
@@ -13,52 +10,28 @@ module Locomotive
|
|
13
10
|
|
14
11
|
module Attributes
|
15
12
|
|
16
|
-
SyntaxWithoutComa = /^ *([a-zA-Z0-9_.]*:.*)$/
|
17
|
-
SyntaxWithComa = /^[a-zA-Z0-9 _"']*, *(.*)$/
|
18
|
-
|
19
13
|
attr_reader :attributes, :raw_attributes
|
20
14
|
|
21
15
|
private
|
22
16
|
|
23
17
|
def parse_attributes(markup, default = {})
|
24
|
-
@
|
25
|
-
|
26
|
-
if markup =~ SyntaxWithoutComa
|
27
|
-
attribute_markup = $1
|
28
|
-
elsif markup =~ SyntaxWithComa
|
29
|
-
attribute_markup = $1
|
30
|
-
end
|
31
|
-
unless attribute_markup.blank?
|
32
|
-
@raw_attributes.merge!(AttributeParser.parse(attribute_markup))
|
33
|
-
end
|
34
|
-
@raw_attributes
|
35
|
-
end
|
18
|
+
@attributes = default || {}
|
19
|
+
@raw_attributes = @attributes.dup
|
36
20
|
|
37
|
-
|
38
|
-
vals.map { value.is_a?(::Liquid::VariableLookup) ? context.evaluate(value) : value }
|
39
|
-
end
|
21
|
+
return if markup.blank?
|
40
22
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
23
|
+
markup.scan(tag_attributes_regexp) do |key, value|
|
24
|
+
_key = key.to_sym
|
44
25
|
|
45
|
-
|
46
|
-
|
47
|
-
raw_attributes.each do |key, value|
|
48
|
-
hash[evaluate_value(context, key, lax: lax)] = evaluate_value(context, value, lax: lax)
|
49
|
-
end
|
26
|
+
@attributes[_key] = block_given? ? yield(value) : ::Liquid::Expression.parse(value)
|
27
|
+
@raw_attributes[_key] = @attributes[_key]
|
50
28
|
end
|
51
29
|
end
|
52
30
|
|
53
|
-
def
|
54
|
-
|
55
|
-
when ::Liquid::VariableLookup
|
31
|
+
def evaluate_attributes(context, lax: false)
|
32
|
+
@attributes = @raw_attributes.transform_values do |value|
|
56
33
|
_value = context.evaluate(value)
|
57
34
|
lax && _value.nil? ? value&.name : _value
|
58
|
-
when Array then value.map { |_value| evaluate_value(context, _value) }
|
59
|
-
when Hash then value.transform_values { |_value| evaluate_value(context, _value) }
|
60
|
-
else
|
61
|
-
value
|
62
35
|
end
|
63
36
|
end
|
64
37
|
|
@@ -66,70 +39,10 @@ module Locomotive
|
|
66
39
|
::Liquid::TagAttributes
|
67
40
|
end
|
68
41
|
|
69
|
-
class AttributeParser
|
70
|
-
class << self
|
71
|
-
def parse(markup)
|
72
|
-
handle_hash(Parser::CurrentRuby.parse("{#{markup}}"), )
|
73
|
-
end
|
74
|
-
|
75
|
-
def handle(node)
|
76
|
-
handler = "handle_#{node.type}"
|
77
|
-
unless respond_to?(handler)
|
78
|
-
raise ::Liquid::SyntaxError.new(
|
79
|
-
"Fail to parse attributes. Unknown expression type: #{node.type.inspect}")
|
80
|
-
end
|
81
|
-
public_send handler, node
|
82
|
-
end
|
83
|
-
|
84
|
-
def handle_hash(node)
|
85
|
-
res = {}
|
86
|
-
node.children.each do | n |
|
87
|
-
res[handle(n.children[0])] = handle(n.children[1])
|
88
|
-
end
|
89
|
-
res
|
90
|
-
end
|
91
|
-
|
92
|
-
def handle_sym(node)
|
93
|
-
node.children[0]
|
94
|
-
end
|
95
|
-
|
96
|
-
def handle_int(node)
|
97
|
-
node.children[0]
|
98
|
-
end
|
99
|
-
|
100
|
-
def handle_str(node)
|
101
|
-
node.children[0]
|
102
|
-
end
|
103
|
-
|
104
|
-
def handle_regexp(node)
|
105
|
-
Unparser.unparse(node)
|
106
|
-
end
|
107
|
-
|
108
|
-
def handle_send(node)
|
109
|
-
::Liquid::Expression.parse(Unparser.unparse(node))
|
110
|
-
end
|
111
|
-
|
112
|
-
def handle_true(node)
|
113
|
-
true
|
114
|
-
end
|
115
|
-
|
116
|
-
def handle_false(node)
|
117
|
-
false
|
118
|
-
end
|
119
|
-
|
120
|
-
def handle_float(node)
|
121
|
-
node.children[0]
|
122
|
-
end
|
123
|
-
|
124
|
-
def handle_array(node)
|
125
|
-
node.children.map{|n| handle(n)}
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
42
|
end
|
43
|
+
|
131
44
|
end
|
132
45
|
end
|
133
46
|
end
|
134
47
|
end
|
135
|
-
end
|
48
|
+
end
|
@@ -7,7 +7,7 @@ module Locomotive
|
|
7
7
|
|
8
8
|
Syntax = /(#{::Liquid::QuotedFragment}+)(\s*,.+)?/o
|
9
9
|
|
10
|
-
attr_reader :handle
|
10
|
+
attr_reader :handle
|
11
11
|
|
12
12
|
def initialize(tag_name, markup, options)
|
13
13
|
super
|
@@ -15,13 +15,6 @@ module Locomotive
|
|
15
15
|
if markup =~ Syntax
|
16
16
|
@handle, _attributes = $1, $2
|
17
17
|
|
18
|
-
# this is a hack for sites which don't follow the new syntax.
|
19
|
-
# We need this hack because the value pass by with can contain "-"
|
20
|
-
# for example : "link_to another_song, with: a-song-template"
|
21
|
-
# This will be evaluated as multiple variable by the ruby AST parser
|
22
|
-
# So we need to convert it to "link_to another_song, with: 'a-song-template'"
|
23
|
-
parse_compatible_attributes(_attributes)
|
24
|
-
|
25
18
|
parse_attributes(_attributes)
|
26
19
|
else
|
27
20
|
self.wrong_syntax!
|
@@ -29,14 +22,14 @@ module Locomotive
|
|
29
22
|
end
|
30
23
|
|
31
24
|
def render_path(context, &block)
|
32
|
-
evaluate_attributes(context)
|
25
|
+
evaluate_attributes(context, lax: true)
|
33
26
|
|
34
27
|
set_vars_from_context(context)
|
35
28
|
|
36
29
|
handle = @context[@handle] || @handle
|
37
30
|
|
38
31
|
# is external url?
|
39
|
-
if handle
|
32
|
+
if handle =~ Locomotive::Steam::IsHTTP
|
40
33
|
handle
|
41
34
|
elsif page = self.retrieve_page_drop_from_handle(handle) # return a drop or model?
|
42
35
|
# make sure we've got the page/content entry (if templatized)
|
@@ -53,18 +46,6 @@ module Locomotive
|
|
53
46
|
|
54
47
|
protected
|
55
48
|
|
56
|
-
def parse_compatible_attributes(_attributes)
|
57
|
-
if _attributes
|
58
|
-
_compatible_attributes = _attributes.dup
|
59
|
-
%w(with locale).each do |name|
|
60
|
-
_compatible_attributes.gsub!(/#{name}: ([\w-]+)/, name + ': "\1"')
|
61
|
-
end
|
62
|
-
@compatible_attributes = parse_attributes(_compatible_attributes)
|
63
|
-
else
|
64
|
-
@compatible_attributes = {}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
49
|
def services
|
69
50
|
@context.registers[:services]
|
70
51
|
end
|
@@ -105,11 +86,11 @@ module Locomotive
|
|
105
86
|
end
|
106
87
|
|
107
88
|
def locale
|
108
|
-
attributes[:locale] ||
|
89
|
+
attributes[:locale] || @locale
|
109
90
|
end
|
110
91
|
|
111
92
|
def template_slug
|
112
|
-
attributes[:with]
|
93
|
+
attributes[:with]
|
113
94
|
end
|
114
95
|
|
115
96
|
def set_vars_from_context(context)
|
@@ -123,4 +104,4 @@ module Locomotive
|
|
123
104
|
end
|
124
105
|
end
|
125
106
|
end
|
126
|
-
end
|
107
|
+
end
|
@@ -25,9 +25,9 @@ module Locomotive
|
|
25
25
|
super
|
26
26
|
|
27
27
|
if markup =~ Syntax
|
28
|
-
@variable_name, @url_expr,
|
28
|
+
@variable_name, @url_expr, attributes = $1.to_s, ::Liquid::Expression.parse($2), $3
|
29
29
|
|
30
|
-
parse_attributes(
|
30
|
+
parse_attributes(attributes)
|
31
31
|
else
|
32
32
|
raise ::Liquid::SyntaxError.new("Syntax Error in 'consume' - Valid syntax: consume <var> from \"<url>\" [username: value, password: value]")
|
33
33
|
end
|
@@ -99,4 +99,4 @@ module Locomotive
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
102
|
-
end
|
102
|
+
end
|
@@ -72,7 +72,7 @@ module Locomotive
|
|
72
72
|
page: parse_context[:page],
|
73
73
|
name: name,
|
74
74
|
found_super: self.contains_super?(nodelist)
|
75
|
-
}.merge(
|
75
|
+
}.merge(attributes))
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -85,7 +85,8 @@ module Locomotive
|
|
85
85
|
|
86
86
|
# the block drop is in charge of rendering "{{ block.super }}"
|
87
87
|
context['block'] = Drops::InheritedBlock.new(block)
|
88
|
-
|
88
|
+
|
89
|
+
anchor_html = if live_editing?(context) && (attributes[:anchor] || attributes[:anchor].nil?)
|
89
90
|
%{<span class="locomotive-block-anchor" data-element-id="#{name}" style="visibility: hidden"></span>}
|
90
91
|
else
|
91
92
|
''
|
@@ -154,4 +155,4 @@ module Locomotive
|
|
154
155
|
end
|
155
156
|
end
|
156
157
|
end
|
157
|
-
end
|
158
|
+
end
|
@@ -33,37 +33,28 @@ module Locomotive
|
|
33
33
|
'x' => Regexp::EXTENDED
|
34
34
|
}.freeze
|
35
35
|
|
36
|
-
OPERATORS = %w(all exists gt gte in lt lte ne nin size near within)
|
37
|
-
|
38
|
-
SYMBOL_OPERATORS_REGEXP = /(\w+\.(#{OPERATORS.join('|')})){1}\s*\:/o
|
39
|
-
|
40
36
|
attr_reader :attributes, :attributes_var_name
|
41
37
|
|
42
38
|
def initialize(tag_name, markup, options)
|
43
39
|
super
|
44
40
|
|
45
|
-
# convert symbol operators into valid ruby code
|
46
|
-
markup.gsub!(SYMBOL_OPERATORS_REGEXP, ':"\1" =>')
|
47
|
-
|
48
41
|
# simple hash?
|
49
42
|
parse_attributes(markup) { |value| parse_attribute(value) }
|
50
43
|
|
51
|
-
if
|
44
|
+
if attributes.empty? && markup =~ SingleVariable
|
52
45
|
# alright, maybe we'vot got a single variable built
|
53
46
|
# with the Action liquid tag instead?
|
54
47
|
@attributes_var_name = Regexp.last_match(1)
|
55
48
|
end
|
56
49
|
|
57
|
-
if
|
50
|
+
if attributes.empty? && attributes_var_name.blank?
|
58
51
|
raise ::Liquid::SyntaxError.new("Syntax Error in 'with_scope' - Valid syntax: with_scope <name_1>: <value_1>, ..., <name_n>: <value_n>")
|
59
52
|
end
|
60
53
|
end
|
61
54
|
|
62
55
|
def render(context)
|
63
56
|
context.stack do
|
64
|
-
|
65
|
-
@raw_attributes.transform_keys! { |key| key.to_s == '_permalink' ? '_slug' : key.to_s }
|
66
|
-
context['with_scope'] = evaluate_attributes(context)
|
57
|
+
context['with_scope'] = self.evaluate_attributes(context)
|
67
58
|
|
68
59
|
# for now, no content type is assigned to this with_scope
|
69
60
|
context['with_scope_content_type'] = false
|
@@ -77,7 +68,7 @@ module Locomotive
|
|
77
68
|
def parse_attribute(value)
|
78
69
|
case value
|
79
70
|
when StrictRegexpFragment
|
80
|
-
# let the
|
71
|
+
# let the cast_value attribute create the Regexp (done during the rendering phase)
|
81
72
|
value
|
82
73
|
when ArrayFragment
|
83
74
|
$1.split(',').map { |_value| parse_attribute(_value) }
|
@@ -86,11 +77,28 @@ module Locomotive
|
|
86
77
|
end
|
87
78
|
end
|
88
79
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
80
|
+
def evaluate_attributes(context)
|
81
|
+
@attributes = context[attributes_var_name] || {} if attributes_var_name.present?
|
82
|
+
|
83
|
+
HashWithIndifferentAccess.new.tap do |hash|
|
84
|
+
attributes.each do |key, value|
|
85
|
+
# _slug instead of _permalink
|
86
|
+
_key = key.to_s == '_permalink' ? '_slug' : key.to_s
|
87
|
+
|
88
|
+
# evaluate the value if possible before casting it
|
89
|
+
_value = value.is_a?(::Liquid::VariableLookup) ? context.evaluate(value) : value
|
90
|
+
|
91
|
+
hash[_key] = cast_value(context, _value)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def cast_value(context, value)
|
97
|
+
case value
|
98
|
+
when Array then value.map { |_value| cast_value(context, _value) }
|
92
99
|
when StrictRegexpFragment then create_regexp($1, $2)
|
93
100
|
else
|
101
|
+
_value = context.evaluate(value)
|
94
102
|
_value.respond_to?(:_id) ? _value.send(:_source) : _value
|
95
103
|
end
|
96
104
|
end
|
@@ -113,4 +121,4 @@ module Locomotive
|
|
113
121
|
end
|
114
122
|
end
|
115
123
|
end
|
116
|
-
end
|
124
|
+
end
|
data/locomotivecms_steam.gemspec
CHANGED
@@ -48,9 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_dependency 'mime-types', '~> 3.3.0'
|
49
49
|
spec.add_dependency 'duktape', '~> 2.0.1.1'
|
50
50
|
spec.add_dependency 'pony', '~> 1.12'
|
51
|
-
|
52
|
-
spec.add_dependency 'unparser', '~> 0.4'
|
53
|
-
|
51
|
+
|
54
52
|
spec.add_dependency 'locomotivecms_common', '~> 0.4.0'
|
55
53
|
|
56
54
|
spec.required_ruby_version = ['>= 2.5', '< 3']
|
@@ -31,7 +31,7 @@ EOF
|
|
31
31
|
|
32
32
|
let(:source) { '{% paginate projects by 2, window_size: 4 %}{% endpaginate %}' }
|
33
33
|
let(:block) { subject.root.nodelist.first }
|
34
|
-
it { expect(block.send(:
|
34
|
+
it { expect(block.send(:window_size)).to eq 4 }
|
35
35
|
|
36
36
|
end
|
37
37
|
|
@@ -62,57 +62,7 @@ describe Locomotive::Steam::Liquid::Tags::WithScope do
|
|
62
62
|
it { expect(conditions['hidden']).to eq false }
|
63
63
|
|
64
64
|
end
|
65
|
-
|
66
|
-
describe 'decode advanced options' do
|
67
|
-
let(:options) { "" }
|
68
|
-
let(:source) { "{% with_scope key: #{options} %}{% assign conditions = with_scope %}{% endwith_scope %}" }
|
69
|
-
context "Array" do
|
70
|
-
context "of Integer" do
|
71
|
-
let(:options) { "[1, 2, 3]" }
|
72
|
-
it { expect(conditions['key']).to eq [1, 2, 3] }
|
73
|
-
end
|
74
|
-
|
75
|
-
context "of String" do
|
76
|
-
let(:options) { "['a', 'b', 'c']" }
|
77
|
-
it { expect(conditions['key']).to eq ['a', 'b', 'c'] }
|
78
|
-
end
|
79
|
-
|
80
|
-
context "With variable" do
|
81
|
-
let(:assigns) { {'a' => 1, 'c' => 3} }
|
82
|
-
let(:options) { "[a, 2, c, 'd']" }
|
83
|
-
it { expect(conditions['key']).to eq [1, 2, 3, 'd'] }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context "Hash" do
|
88
|
-
context "With key value" do
|
89
|
-
let(:options) { "{a: 1, b: 2, c: 3, d: 'foo'}" }
|
90
|
-
it { expect(conditions['key'].keys).to eq(%w(a b c d)) }
|
91
|
-
it { expect(conditions['key']['a']).to eq 1 }
|
92
|
-
it { expect(conditions['key']['b']).to eq 2 }
|
93
|
-
it { expect(conditions['key']['c']).to eq 3 }
|
94
|
-
it { expect(conditions['key']['d']).to eq 'foo' }
|
95
|
-
end
|
96
|
-
|
97
|
-
context "With key variable" do
|
98
|
-
let(:assigns) { {'a' => 1, 'c' => 3} }
|
99
|
-
let(:options) { "{a: a, b: 2, c: c, d: 'foo'}" }
|
100
|
-
it { expect(conditions['key'].keys).to eq(%w(a b c d)) }
|
101
|
-
it { expect(conditions['key']['a']).to eq 1 }
|
102
|
-
it { expect(conditions['key']['b']).to eq 2 }
|
103
|
-
it { expect(conditions['key']['c']).to eq 3 }
|
104
|
-
it { expect(conditions['key']['d']).to eq 'foo' }
|
105
|
-
end
|
106
|
-
|
107
|
-
context "With params" do
|
108
|
-
let(:assigns) { { 'params' => Locomotive::Steam::Liquid::Drops::Params.new({ foo: 'bar' }) } }
|
109
|
-
let(:options) { "{'a': params.foo}" }
|
110
|
-
it { expect(conditions['key'].keys).to eq(%w(a)) }
|
111
|
-
it { expect(conditions['key']['a']).to eq 'bar' }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
65
|
+
|
116
66
|
describe 'decode regexps' do
|
117
67
|
|
118
68
|
let(:source) { "{% with_scope title: /Like this one|or this one/ %}{% assign conditions = with_scope %}{% endwith_scope %}" }
|
@@ -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('
|
58
|
+
before { expect(cache).to receive(:read).with('4fb84e6d3037dcd54979c3461c5a5ffd').and_return(response) }
|
59
59
|
|
60
60
|
context 'the cache is empty' do
|
61
61
|
|
62
|
-
before { expect(cache).to receive(:write).with('
|
62
|
+
before { expect(cache).to receive(:write).with('4fb84e6d3037dcd54979c3461c5a5ffd', 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 '
|
72
|
+
it { is_expected.to eq '4fb84e6d3037dcd54979c3461c5a5ffd' }
|
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) { '
|
107
|
+
let(:etag) { '4fb84e6d3037dcd54979c3461c5a5ffd' }
|
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.6.
|
4
|
+
version: 1.6.1
|
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: 2022-10-
|
14
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -417,34 +417,6 @@ dependencies:
|
|
417
417
|
- - "~>"
|
418
418
|
- !ruby/object:Gem::Version
|
419
419
|
version: '1.12'
|
420
|
-
- !ruby/object:Gem::Dependency
|
421
|
-
name: parser
|
422
|
-
requirement: !ruby/object:Gem::Requirement
|
423
|
-
requirements:
|
424
|
-
- - "~>"
|
425
|
-
- !ruby/object:Gem::Version
|
426
|
-
version: '2.7'
|
427
|
-
type: :runtime
|
428
|
-
prerelease: false
|
429
|
-
version_requirements: !ruby/object:Gem::Requirement
|
430
|
-
requirements:
|
431
|
-
- - "~>"
|
432
|
-
- !ruby/object:Gem::Version
|
433
|
-
version: '2.7'
|
434
|
-
- !ruby/object:Gem::Dependency
|
435
|
-
name: unparser
|
436
|
-
requirement: !ruby/object:Gem::Requirement
|
437
|
-
requirements:
|
438
|
-
- - "~>"
|
439
|
-
- !ruby/object:Gem::Version
|
440
|
-
version: '0.4'
|
441
|
-
type: :runtime
|
442
|
-
prerelease: false
|
443
|
-
version_requirements: !ruby/object:Gem::Requirement
|
444
|
-
requirements:
|
445
|
-
- - "~>"
|
446
|
-
- !ruby/object:Gem::Version
|
447
|
-
version: '0.4'
|
448
420
|
- !ruby/object:Gem::Dependency
|
449
421
|
name: locomotivecms_common
|
450
422
|
requirement: !ruby/object:Gem::Requirement
|