locomotivecms_steam 1.2.0.beta1 → 1.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +36 -36
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +9 -1
- data/lib/locomotive/steam/decorators/page_decorator.rb +20 -0
- data/lib/locomotive/steam/decorators/template_decorator.rb +0 -1
- data/lib/locomotive/steam/entities/content_entry.rb +5 -4
- data/lib/locomotive/steam/entities/content_type.rb +5 -0
- data/lib/locomotive/steam/entities/page.rb +1 -2
- data/lib/locomotive/steam/liquid/drops/base.rb +17 -13
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +5 -1
- data/lib/locomotive/steam/liquid/drops/metafields.rb +8 -3
- data/lib/locomotive/steam/liquid/filters/misc.rb +1 -1
- data/lib/locomotive/steam/liquid/filters/resize.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +12 -1
- data/lib/locomotive/steam/middlewares/entry_submission.rb +23 -4
- data/lib/locomotive/steam/middlewares/page.rb +12 -2
- data/lib/locomotive/steam/middlewares/renderer.rb +7 -6
- data/lib/locomotive/steam/middlewares/sitemap.rb +11 -0
- data/lib/locomotive/steam/middlewares/thread_safe.rb +4 -0
- data/lib/locomotive/steam/models/i18n_field.rb +1 -1
- data/lib/locomotive/steam/repositories/content_type_field_repository.rb +3 -1
- data/lib/locomotive/steam/server.rb +0 -1
- data/lib/locomotive/steam/services/external_api_service.rb +8 -1
- data/lib/locomotive/steam/services/image_resizer_service.rb +1 -1
- data/lib/locomotive/steam/services/page_finder_service.rb +4 -0
- data/lib/locomotive/steam/version.rb +1 -1
- data/locomotivecms_steam.gemspec +4 -5
- data/spec/fixtures/default/app/views/pages/all.liquid.haml +4 -1
- data/spec/fixtures/default/app/views/pages/contact.liquid.haml +8 -1
- data/spec/fixtures/default/app/views/pages/events.liquid.haml +7 -0
- data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +2 -2
- data/spec/fixtures/default/data/updates.yml +4 -2
- data/spec/integration/server/contact_form_spec.rb +13 -0
- data/spec/integration/server/nav_spec.rb +4 -0
- data/spec/integration/server/sitemap_spec.rb +2 -2
- data/spec/support/helpers.rb +2 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/content_entry_spec.rb +17 -0
- data/spec/unit/decorators/page_decorator_spec.rb +36 -0
- data/spec/unit/decorators/template_decorator_spec.rb +1 -0
- data/spec/unit/entities/content_type_spec.rb +34 -0
- data/spec/unit/entities/page_spec.rb +0 -24
- data/spec/unit/liquid/drops/content_entry_spec.rb +10 -2
- data/spec/unit/liquid/drops/metafields_spec.rb +35 -6
- data/spec/unit/liquid/filters/resize_spec.rb +17 -0
- data/spec/unit/liquid/tags/with_scope_spec.rb +15 -0
- data/spec/unit/middlewares/page_spec.rb +63 -0
- data/spec/unit/middlewares/renderer_spec.rb +2 -4
- data/spec/unit/middlewares/sitemap_spec.rb +41 -1
- data/spec/unit/services/external_api_service_spec.rb +10 -0
- data/spec/unit/services/image_resizer_service_spec.rb +3 -3
- metadata +15 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb33db62c8a0c967f8dd571468e3c0a152db1672
|
4
|
+
data.tar.gz: 67c92ee1c3f7bdf143bc1b565a8864317fd406bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34e6da025b0744a580ca22fb69578e9418c55f983594d90b3943da2ad90bb1d40b510a449b6d04f3ded70e74dce10fc2aba251677c5ef61c2bf81c7ee72fb57
|
7
|
+
data.tar.gz: 666be2d79e33b713d4f3601a4adfaf35b09a4a45bcdfd292c03b5b81d7e5e76bcedd867a02d422b09738d6014283e727787a91c0fa2e817e828ef4b18813a4a6
|
data/Gemfile
CHANGED
@@ -11,8 +11,9 @@ group :development do
|
|
11
11
|
# gem 'thin'
|
12
12
|
gem 'puma'
|
13
13
|
gem 'yui-compressor', '~> 0.12.0'
|
14
|
+
gem 'haml', '~> 4.0.6'
|
14
15
|
|
15
|
-
gem 'rack-mini-profiler'
|
16
|
+
gem 'rack-mini-profiler', '~> 0.10.1'
|
16
17
|
gem 'flamegraph'
|
17
18
|
gem 'stackprof' # ruby 2.1+ only
|
18
19
|
gem 'memory_profiler'
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.2.0.
|
5
|
-
RedCloth (~> 4.2
|
4
|
+
locomotivecms_steam (1.2.0.rc1)
|
5
|
+
RedCloth (~> 4.3.2)
|
6
6
|
autoprefixer-rails (~> 6.3.3.1)
|
7
7
|
chronic (~> 0.10.2)
|
8
8
|
coffee-script (~> 2.4.1)
|
9
9
|
compass (~> 1.0.3)
|
10
10
|
dragonfly (~> 1.0.12)
|
11
11
|
duktape (~> 1.3.0.6)
|
12
|
-
haml (~> 4.0.6)
|
13
12
|
httparty (~> 0.13.6)
|
14
13
|
kramdown (~> 1.10.0)
|
15
14
|
locomotivecms-solid (~> 4.0.1)
|
@@ -18,7 +17,7 @@ PATH
|
|
18
17
|
mimetype-fu (~> 0.1.2)
|
19
18
|
moneta (~> 0.8.0)
|
20
19
|
morphine (~> 0.1.1)
|
21
|
-
nokogiri (~> 1.6.
|
20
|
+
nokogiri (~> 1.6.8)
|
22
21
|
pony (~> 1.11)
|
23
22
|
rack-cache (~> 1.6.1)
|
24
23
|
rack-rewrite (~> 1.5.1)
|
@@ -30,8 +29,8 @@ PATH
|
|
30
29
|
GEM
|
31
30
|
remote: https://rubygems.org/
|
32
31
|
specs:
|
33
|
-
RedCloth (4.2
|
34
|
-
activesupport (4.2.
|
32
|
+
RedCloth (4.3.2)
|
33
|
+
activesupport (4.2.7)
|
35
34
|
i18n (~> 0.7)
|
36
35
|
json (~> 1.7, >= 1.7.7)
|
37
36
|
minitest (~> 5.1)
|
@@ -44,7 +43,7 @@ GEM
|
|
44
43
|
bson (4.1.1)
|
45
44
|
byebug (8.2.5)
|
46
45
|
chronic (0.10.2)
|
47
|
-
chunky_png (1.3.
|
46
|
+
chunky_png (1.3.6)
|
48
47
|
codeclimate-test-reporter (0.4.8)
|
49
48
|
simplecov (>= 0.7.1, < 1.0.0)
|
50
49
|
coderay (1.1.1)
|
@@ -52,7 +51,7 @@ GEM
|
|
52
51
|
coffee-script-source
|
53
52
|
execjs
|
54
53
|
coffee-script-source (1.10.0)
|
55
|
-
colorize (0.
|
54
|
+
colorize (0.8.1)
|
56
55
|
compass (1.0.3)
|
57
56
|
chunky_png (~> 1.2)
|
58
57
|
compass-core (~> 1.0.2)
|
@@ -66,12 +65,12 @@ GEM
|
|
66
65
|
compass-import-once (1.0.5)
|
67
66
|
sass (>= 3.2, < 3.5)
|
68
67
|
concurrent-ruby (1.0.2)
|
69
|
-
coveralls (0.8.
|
70
|
-
json (
|
71
|
-
simplecov (~> 0.
|
68
|
+
coveralls (0.8.15)
|
69
|
+
json (>= 1.8, < 3)
|
70
|
+
simplecov (~> 0.12.0)
|
72
71
|
term-ansicolor (~> 1.3)
|
73
72
|
thor (~> 0.19.1)
|
74
|
-
tins (
|
73
|
+
tins (>= 1.6.0, < 2)
|
75
74
|
crass (1.0.2)
|
76
75
|
diff-lcs (1.2.5)
|
77
76
|
docile (1.1.5)
|
@@ -81,10 +80,8 @@ GEM
|
|
81
80
|
rack (>= 1.3.0)
|
82
81
|
duktape (1.3.0.6)
|
83
82
|
execjs (2.7.0)
|
84
|
-
|
85
|
-
|
86
|
-
flamegraph (0.1.0)
|
87
|
-
fast_stack
|
83
|
+
ffi (1.9.14)
|
84
|
+
flamegraph (0.9.5)
|
88
85
|
haml (4.0.7)
|
89
86
|
tilt
|
90
87
|
httparty (0.13.7)
|
@@ -93,7 +90,7 @@ GEM
|
|
93
90
|
i18n (0.7.0)
|
94
91
|
i18n-spec (0.6.0)
|
95
92
|
iso
|
96
|
-
iso (0.2.
|
93
|
+
iso (0.2.2)
|
97
94
|
i18n
|
98
95
|
json (1.8.3)
|
99
96
|
json_spec (1.1.4)
|
@@ -114,33 +111,35 @@ GEM
|
|
114
111
|
method_source (0.8.2)
|
115
112
|
mime-types (2.6.2)
|
116
113
|
mimetype-fu (0.1.2)
|
117
|
-
mini_portile2 (2.
|
114
|
+
mini_portile2 (2.1.0)
|
118
115
|
minitest (5.9.0)
|
119
116
|
moneta (0.8.0)
|
120
|
-
mongo (2.2.
|
117
|
+
mongo (2.2.7)
|
121
118
|
bson (~> 4.0)
|
122
119
|
morphine (0.1.1)
|
123
|
-
multi_json (1.12.
|
120
|
+
multi_json (1.12.1)
|
124
121
|
multi_xml (0.5.5)
|
125
|
-
nokogiri (1.6.
|
126
|
-
mini_portile2 (~> 2.
|
127
|
-
|
122
|
+
nokogiri (1.6.8)
|
123
|
+
mini_portile2 (~> 2.1.0)
|
124
|
+
pkg-config (~> 1.1.7)
|
125
|
+
nokogumbo (1.4.9)
|
128
126
|
nokogiri
|
129
|
-
origin (2.
|
127
|
+
origin (2.2.0)
|
128
|
+
pkg-config (1.1.7)
|
130
129
|
pony (1.11)
|
131
130
|
mail (>= 2.0)
|
132
|
-
pry (0.10.
|
131
|
+
pry (0.10.4)
|
133
132
|
coderay (~> 1.1.0)
|
134
133
|
method_source (~> 0.8.1)
|
135
134
|
slop (~> 3.4)
|
136
135
|
pry-byebug (3.3.0)
|
137
136
|
byebug (~> 8.0)
|
138
137
|
pry (~> 0.10)
|
139
|
-
puma (3.
|
140
|
-
rack (
|
138
|
+
puma (3.6.0)
|
139
|
+
rack (2.0.1)
|
141
140
|
rack-cache (1.6.1)
|
142
141
|
rack (>= 0.4)
|
143
|
-
rack-mini-profiler (0.
|
142
|
+
rack-mini-profiler (0.10.1)
|
144
143
|
rack (>= 1.2.0)
|
145
144
|
rack-rewrite (1.5.1)
|
146
145
|
rack-test (0.6.3)
|
@@ -169,9 +168,9 @@ GEM
|
|
169
168
|
nokogiri (>= 1.4.4)
|
170
169
|
nokogumbo (~> 1.4.1)
|
171
170
|
sass (3.4.22)
|
172
|
-
simplecov (0.
|
171
|
+
simplecov (0.12.0)
|
173
172
|
docile (~> 1.1.0)
|
174
|
-
json (
|
173
|
+
json (>= 1.8, < 3)
|
175
174
|
simplecov-html (~> 0.10.0)
|
176
175
|
simplecov-html (0.10.0)
|
177
176
|
slop (3.6.0)
|
@@ -179,14 +178,14 @@ GEM
|
|
179
178
|
concurrent-ruby (~> 1.0)
|
180
179
|
rack (> 1, < 3)
|
181
180
|
stackprof (0.2.9)
|
182
|
-
stringex (2.6.
|
181
|
+
stringex (2.6.1)
|
183
182
|
term-ansicolor (1.3.2)
|
184
183
|
tins (~> 1.0)
|
185
184
|
thor (0.19.1)
|
186
185
|
thread_safe (0.3.5)
|
187
|
-
tilt (2.0.
|
186
|
+
tilt (2.0.5)
|
188
187
|
timecop (0.8.1)
|
189
|
-
tins (1.
|
188
|
+
tins (1.12.0)
|
190
189
|
tzinfo (1.2.2)
|
191
190
|
thread_safe (~> 0.1)
|
192
191
|
yui-compressor (0.12.0)
|
@@ -199,15 +198,16 @@ DEPENDENCIES
|
|
199
198
|
codeclimate-test-reporter (~> 0.4.7)
|
200
199
|
coveralls (~> 0.8.1)
|
201
200
|
flamegraph
|
201
|
+
haml (~> 4.0.6)
|
202
202
|
i18n-spec (~> 0.6.0)
|
203
203
|
json_spec (~> 1.1.4)
|
204
204
|
locomotivecms_steam!
|
205
205
|
memory_profiler
|
206
|
-
mongo (~> 2.2.
|
207
|
-
origin (~> 2.
|
206
|
+
mongo (~> 2.2.7)
|
207
|
+
origin (~> 2.2.0)
|
208
208
|
pry-byebug (~> 3.3.0)
|
209
209
|
puma
|
210
|
-
rack-mini-profiler
|
210
|
+
rack-mini-profiler (~> 0.10.1)
|
211
211
|
rack-test (~> 0.6.3)
|
212
212
|
rake (~> 10.4.2)
|
213
213
|
rspec (~> 3.4.0)
|
@@ -31,7 +31,15 @@ module Locomotive
|
|
31
31
|
|
32
32
|
def modify_for_selects(attributes)
|
33
33
|
content_type.select_fields.each do |field|
|
34
|
-
|
34
|
+
if (option = attributes.delete(field.name.to_sym)).is_a?(Hash)
|
35
|
+
attributes[:"#{field.name}_id"] = option.inject({}) do |memo, (locale, name)|
|
36
|
+
field.select_options.scope.locale = locale
|
37
|
+
memo[locale] = field.select_options.by_name(name).try(:_id)
|
38
|
+
memo
|
39
|
+
end
|
40
|
+
else
|
41
|
+
attributes[:"#{field.name}_id"] = option
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'template_decorator'
|
2
|
+
|
3
|
+
module Locomotive
|
4
|
+
module Steam
|
5
|
+
module Decorators
|
6
|
+
|
7
|
+
class PageDecorator < TemplateDecorator
|
8
|
+
|
9
|
+
def redirect?
|
10
|
+
redirect.nil? ? redirect_url.present? : redirect
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
@@ -164,16 +164,17 @@ module Locomotive::Steam
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def _cast_select(field)
|
167
|
-
_cast_convertor(:"#{field.name}_id") do |value|
|
168
|
-
field.select_options.find(value).try(:name)
|
167
|
+
_cast_convertor(:"#{field.name}_id", true) do |value, locale|
|
168
|
+
name = field.select_options.find(value).try(:name)
|
169
|
+
locale.nil? ? name : name.try(:[], locale)
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
172
|
-
def _cast_convertor(name, &block)
|
173
|
+
def _cast_convertor(name, nil_locale = false, &block)
|
173
174
|
if (value = attributes[name]).respond_to?(:translations)
|
174
175
|
value.apply(&block)
|
175
176
|
else
|
176
|
-
yield(value)
|
177
|
+
nil_locale ? yield(value, nil) : yield(value)
|
177
178
|
end
|
178
179
|
end
|
179
180
|
|
@@ -30,9 +30,14 @@ module Locomotive::Steam
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def localized_names
|
33
|
+
# FIXME: select_fields ALWAYS returns I18nField even if the site is not localized
|
33
34
|
fields.localized_names + select_fields.map(&:name)
|
34
35
|
end
|
35
36
|
|
37
|
+
def localized?
|
38
|
+
!fields.localized_names.blank?
|
39
|
+
end
|
40
|
+
|
36
41
|
def persisted_field_names
|
37
42
|
[].tap do |names|
|
38
43
|
fields_by_name.each do |name, field|
|
@@ -21,7 +21,7 @@ module Locomotive::Steam
|
|
21
21
|
raw_template: nil,
|
22
22
|
source: nil,
|
23
23
|
editable_elements: {},
|
24
|
-
redirect:
|
24
|
+
redirect: nil,
|
25
25
|
redirect_url: {},
|
26
26
|
redirect_type: nil,
|
27
27
|
parent_id: nil,
|
@@ -33,7 +33,6 @@ module Locomotive::Steam
|
|
33
33
|
def listed?; !!listed; end
|
34
34
|
def published?; !!published; end
|
35
35
|
def templatized?; !!templatized; end
|
36
|
-
def redirect?; redirect.nil? ? redirect_url.present? : redirect; end
|
37
36
|
|
38
37
|
def content_type_id
|
39
38
|
self.target_klass_name =~ Locomotive::Steam::CONTENT_ENTRY_ENGINE_CLASS_NAME
|
@@ -14,30 +14,34 @@ module Locomotive
|
|
14
14
|
(@_source.respond_to?(:id) ? @_source.id : nil) || 'new'
|
15
15
|
end
|
16
16
|
|
17
|
+
def as_json(options = nil)
|
18
|
+
@_source.as_json(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
17
23
|
# converts an array of records to an array of liquid drops
|
18
|
-
def
|
24
|
+
def liquify(*records, &block)
|
19
25
|
i = -1
|
20
26
|
records =
|
21
27
|
records.inject [] do |all, r|
|
22
|
-
i+=1
|
28
|
+
i += 1
|
23
29
|
attrs = (block && block.arity == 1) ? [r] : [r, i]
|
24
|
-
all << (block ? block.call(*attrs) : r.to_liquid)
|
30
|
+
all << (block ? block.call(*attrs) : r.to_liquid).tap do |_r|
|
31
|
+
# For unknown reasons, Liquid doesn't always set the context
|
32
|
+
#
|
33
|
+
# Example:
|
34
|
+
# {{ site.index.children | map: 'title' | join: " - " }}
|
35
|
+
# was not working before
|
36
|
+
#
|
37
|
+
_r.context = @context if _r.respond_to?(:context=)
|
38
|
+
end
|
25
39
|
all
|
26
40
|
end
|
27
41
|
records.compact!
|
28
42
|
records
|
29
43
|
end
|
30
44
|
|
31
|
-
def as_json(options = nil)
|
32
|
-
@_source.as_json(options)
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def liquify(*records, &block)
|
38
|
-
self.class.liquify(*records, &block)
|
39
|
-
end
|
40
|
-
|
41
45
|
def _source
|
42
46
|
@_source
|
43
47
|
end
|
@@ -22,7 +22,7 @@ module Locomotive
|
|
22
22
|
|
23
23
|
def find_value(name)
|
24
24
|
if field = fields[name]
|
25
|
-
safe_value(t(values[name], field['localized']))
|
25
|
+
safe_value(t(values[name], field['localized']), field['type'])
|
26
26
|
else
|
27
27
|
Locomotive::Common::Logger.warn "[Liquid template] unknown site metafield \"#{name}\" under #{@namespace['name']}"
|
28
28
|
nil
|
@@ -66,8 +66,13 @@ module Locomotive
|
|
66
66
|
value[key]
|
67
67
|
end
|
68
68
|
|
69
|
-
def safe_value(value)
|
70
|
-
|
69
|
+
def safe_value(value, type = 'string')
|
70
|
+
case type
|
71
|
+
when 'boolean'
|
72
|
+
['1', 'true', true].include?(value) ? true : false
|
73
|
+
else
|
74
|
+
value.blank? ? nil : value
|
75
|
+
end
|
71
76
|
end
|
72
77
|
|
73
78
|
end
|
@@ -20,6 +20,12 @@ module Locomotive
|
|
20
20
|
|
21
21
|
SYMBOL_OPERATORS_REGEXP = /(\w+\.(#{OPERATORS.join('|')})){1}\s*\:/o
|
22
22
|
|
23
|
+
REGEX_OPTIONS = {
|
24
|
+
'i' => Regexp::IGNORECASE,
|
25
|
+
'm' => Regexp::MULTILINE,
|
26
|
+
'x' => Regexp::EXTENDED
|
27
|
+
}
|
28
|
+
|
23
29
|
# register the tag
|
24
30
|
tag_name :with_scope
|
25
31
|
|
@@ -54,7 +60,12 @@ module Locomotive
|
|
54
60
|
def cast_value(value)
|
55
61
|
case value
|
56
62
|
when Array then value.map { |_value| cast_value(_value) }
|
57
|
-
when /^\/[^\/]
|
63
|
+
when /^\/([^\/]*)\/([imx]+)?$/
|
64
|
+
_value, options_str = $1, $2
|
65
|
+
options = options_str.blank? ? nil : options_str.split('').uniq.inject(0) do |_options, letter|
|
66
|
+
_options |= REGEX_OPTIONS[letter]
|
67
|
+
end
|
68
|
+
Regexp.new(_value, options)
|
58
69
|
else
|
59
70
|
value.respond_to?(:_id) ? value.send(:_source) : value
|
60
71
|
end
|