locomotivecms_steam 1.0.0.rc2 → 1.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +10 -10
- data/lib/locomotive/steam/entities/editable_element.rb +1 -0
- data/lib/locomotive/steam/liquid/tags/inherited_block.rb +13 -1
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +4 -1
- data/lib/locomotive/steam/repositories/content_entry_repository.rb +52 -11
- data/lib/locomotive/steam/repositories/content_type_field_repository.rb +4 -0
- data/lib/locomotive/steam/version.rb +1 -1
- data/locomotivecms_steam.gemspec +1 -1
- data/spec/unit/entities/editable_element_spec.rb +10 -0
- data/spec/unit/liquid/tags/editable/text_spec.rb +1 -1
- data/spec/unit/liquid/tags/inherited_block_spec.rb +8 -0
- data/spec/unit/repositories/content_entry_repository_spec.rb +4 -4
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7df606052bd99feb2e413424aee474abc2c38de
|
4
|
+
data.tar.gz: e2f3eacbb044cf3920178315a475d2c8e0fe0a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0652e4cdc58c66a22ba3e018265f85114ca14e41bb75429ce91e8ee95dc96cdfbbefba72707c53f701df9c5a99b7104fc38afe6ac063b79e86ebbf5b82c41a44
|
7
|
+
data.tar.gz: 00fa87eb476049549c909406eaff59e4759e415fb87868a60d54c4a3181e1cef8a3bcb351d53719559d840b0eee2c809a732b7e3a7d0ab34cdaee2860235bd8b
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.0.0.
|
4
|
+
locomotivecms_steam (1.0.0.rc3)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
6
|
chronic (~> 0.10.2)
|
7
7
|
coffee-script (~> 2.4.1)
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
haml (~> 4.0.6)
|
11
11
|
httparty (~> 0.13.6)
|
12
12
|
kramdown (~> 1.8.0)
|
13
|
-
locomotivecms-solid (~> 4.0.
|
13
|
+
locomotivecms-solid (~> 4.0.1)
|
14
14
|
locomotivecms_common (~> 0.0.5)
|
15
15
|
mime-types (~> 2.6.1)
|
16
16
|
mimetype-fu (~> 0.1.2)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
remote: https://rubygems.org/
|
29
29
|
specs:
|
30
30
|
RedCloth (4.2.9)
|
31
|
-
activesupport (4.2.
|
31
|
+
activesupport (4.2.5)
|
32
32
|
i18n (~> 0.7)
|
33
33
|
json (~> 1.7, >= 1.7.7)
|
34
34
|
minitest (~> 5.1)
|
@@ -40,14 +40,14 @@ GEM
|
|
40
40
|
byebug (4.0.5)
|
41
41
|
columnize (= 0.9.0)
|
42
42
|
chronic (0.10.2)
|
43
|
-
chunky_png (1.3.
|
43
|
+
chunky_png (1.3.5)
|
44
44
|
codeclimate-test-reporter (0.4.7)
|
45
45
|
simplecov (>= 0.7.1, < 1.0.0)
|
46
46
|
coderay (1.1.0)
|
47
47
|
coffee-script (2.4.1)
|
48
48
|
coffee-script-source
|
49
49
|
execjs
|
50
|
-
coffee-script-source (1.
|
50
|
+
coffee-script-source (1.10.0)
|
51
51
|
colorize (0.7.7)
|
52
52
|
columnize (0.9.0)
|
53
53
|
commonjs (0.2.7)
|
@@ -106,9 +106,9 @@ GEM
|
|
106
106
|
kramdown (1.8.0)
|
107
107
|
less (2.6.0)
|
108
108
|
commonjs (~> 0.2.7)
|
109
|
-
locomotivecms-liquid (4.0.0
|
110
|
-
locomotivecms-solid (4.0.
|
111
|
-
locomotivecms-liquid (~> 4.0.0
|
109
|
+
locomotivecms-liquid (4.0.0)
|
110
|
+
locomotivecms-solid (4.0.1)
|
111
|
+
locomotivecms-liquid (~> 4.0.0)
|
112
112
|
locomotivecms_common (0.0.5)
|
113
113
|
activesupport (~> 4.2.1)
|
114
114
|
attr_extras (~> 4.4.0)
|
@@ -119,7 +119,7 @@ GEM
|
|
119
119
|
mime-types (2.6.1)
|
120
120
|
mimetype-fu (0.1.2)
|
121
121
|
mini_portile (0.6.2)
|
122
|
-
minitest (5.8.
|
122
|
+
minitest (5.8.2)
|
123
123
|
moneta (0.8.0)
|
124
124
|
moped (2.0.6)
|
125
125
|
bson (~> 3.0)
|
@@ -144,7 +144,7 @@ GEM
|
|
144
144
|
pry (~> 0.10)
|
145
145
|
puma (2.12.3)
|
146
146
|
rack (1.6.1)
|
147
|
-
rack-cache (1.5.
|
147
|
+
rack-cache (1.5.1)
|
148
148
|
rack (>= 0.4)
|
149
149
|
rack-mini-profiler (0.9.7)
|
150
150
|
rack (>= 1.1.3)
|
@@ -18,7 +18,7 @@ module Locomotive
|
|
18
18
|
def initialize(tag_name, markup, options)
|
19
19
|
super
|
20
20
|
|
21
|
-
@attributes = { short_name: false, priority: 0 }
|
21
|
+
@attributes = { short_name: false, priority: 0, anchor: true }
|
22
22
|
markup.scan(::Liquid::TagAttributes) do |key, value|
|
23
23
|
@attributes[key.to_sym] = ::Liquid::Expression.parse(value)
|
24
24
|
end
|
@@ -34,6 +34,14 @@ module Locomotive
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def render(context)
|
38
|
+
(if live_editing?(context) && (@attributes[:anchor] || @attributes[:anchor].nil?)
|
39
|
+
%{<span class="locomotive-block-anchor" data-element-id="#{@name}" style="visibility: hidden"></span>}
|
40
|
+
else
|
41
|
+
''
|
42
|
+
end) + super
|
43
|
+
end
|
44
|
+
|
37
45
|
protected
|
38
46
|
|
39
47
|
def contains_super?(nodes)
|
@@ -60,6 +68,10 @@ module Locomotive
|
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
71
|
+
def live_editing?(context)
|
72
|
+
!!context.registers[:live_editing]
|
73
|
+
end
|
74
|
+
|
63
75
|
end
|
64
76
|
|
65
77
|
::Liquid::Template.register_tag('block'.freeze, InheritedBlock)
|
@@ -46,8 +46,11 @@ module Locomotive
|
|
46
46
|
_key = key.to_s == '_permalink' ? '_slug' : key.to_s
|
47
47
|
|
48
48
|
hash[_key] = (case value
|
49
|
-
|
49
|
+
# regexp inside a string
|
50
50
|
when /^\/[^\/]*\/$/ then Regexp.new(value[1..-2])
|
51
|
+
# content entry drop? Use the source (entity) instead
|
52
|
+
when Locomotive::Steam::Liquid::Drops::ContentEntry
|
53
|
+
value.send(:_source)
|
51
54
|
else
|
52
55
|
value
|
53
56
|
end)
|
@@ -130,22 +130,32 @@ module Locomotive
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def prepare_conditions(*conditions)
|
133
|
-
_conditions = conditions.first.try(:with_indifferent_access)
|
133
|
+
# _conditions = conditions.first.try(:with_indifferent_access)
|
134
134
|
|
135
|
-
|
135
|
+
_conditions = Conditions.new(conditions.first, self.content_type.fields).prepare
|
136
136
|
|
137
137
|
super({ _visible: true }, _conditions)
|
138
138
|
end
|
139
139
|
|
140
|
-
#
|
141
|
-
def
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
140
|
+
# # belongs_to fields? if so, make sure we use the _id and we deal with the ID, not the object itself
|
141
|
+
# def prepare_conditions_for_belongs_to_fields(conditions)
|
142
|
+
# self.content_type.fields.belongs_to.each do |field|
|
143
|
+
# if value = conditions[name = field.name.to_s]
|
144
|
+
# conditions.delete(name)
|
145
|
+
# conditions[name + '_id'] = value.try(:_id)
|
146
|
+
# end
|
147
|
+
# end
|
148
|
+
# end
|
149
|
+
|
150
|
+
# # select fields? if so, use the _id of the option instead of the option name
|
151
|
+
# def prepare_conditions_for_select_fields(conditions)
|
152
|
+
# self.content_type.fields.selects.each do |field|
|
153
|
+
# if value = conditions[name = field.name.to_s]
|
154
|
+
# conditions.delete(name)
|
155
|
+
# conditions[name + '_id'] = field.select_options.by_name(value).try(:_id)
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
# end
|
149
159
|
|
150
160
|
def add_localized_fields_to_mapper(mapper)
|
151
161
|
unless self.content_type.localized_names.blank?
|
@@ -194,6 +204,37 @@ module Locomotive
|
|
194
204
|
end
|
195
205
|
end
|
196
206
|
|
207
|
+
class Conditions
|
208
|
+
|
209
|
+
def initialize(conditions = {}, fields)
|
210
|
+
@conditions, @fields = conditions.try(:with_indifferent_access) || {}, fields
|
211
|
+
end
|
212
|
+
|
213
|
+
def prepare
|
214
|
+
return {} if @conditions.blank?
|
215
|
+
|
216
|
+
_prepare(@fields.selects) do |field, value|
|
217
|
+
field.select_options.by_name(value).try(:_id)
|
218
|
+
end
|
219
|
+
|
220
|
+
_prepare(@fields.belongs_to) { |field, value| value.try(:_id) }
|
221
|
+
|
222
|
+
@conditions
|
223
|
+
end
|
224
|
+
|
225
|
+
protected
|
226
|
+
|
227
|
+
def _prepare(fields, &block)
|
228
|
+
fields.each do |field|
|
229
|
+
if value = @conditions[name = field.name.to_s]
|
230
|
+
@conditions.delete(name)
|
231
|
+
@conditions[name + '_id'] = yield(field, value)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
197
238
|
end
|
198
239
|
|
199
240
|
end
|
data/locomotivecms_steam.gemspec
CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
|
|
44
44
|
spec.add_dependency 'mimetype-fu', '~> 0.1.2'
|
45
45
|
spec.add_dependency 'mime-types', '~> 2.6.1'
|
46
46
|
|
47
|
-
spec.add_dependency 'locomotivecms-solid', '~> 4.0.
|
47
|
+
spec.add_dependency 'locomotivecms-solid', '~> 4.0.1'
|
48
48
|
spec.add_dependency 'locomotivecms_common', '~> 0.0.5'
|
49
49
|
|
50
50
|
spec.required_ruby_version = '>= 2.0'
|
@@ -141,7 +141,7 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
|
|
141
141
|
|
142
142
|
context 'with inside blocks' do
|
143
143
|
|
144
|
-
let(:source) { '{% block wrapper %}{% block sidebar %}{% editable_text title %}Hello world{% endeditable_text %}{% endblock %}{% endblock %}' }
|
144
|
+
let(:source) { '{% block wrapper, anchor: false %}{% block sidebar, anchor: false %}{% editable_text title %}Hello world{% endeditable_text %}{% endblock %}{% endblock %}' }
|
145
145
|
it { is_expected.to eq '<span class="locomotive-editable-text" id="locomotive-editable-text-wrapper-sidebar-title" data-element-id="42">Hello world</span>' }
|
146
146
|
|
147
147
|
end
|
@@ -43,4 +43,12 @@ describe Locomotive::Steam::Liquid::Tags::InheritedBlock do
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
+
describe 'live editing on' do
|
47
|
+
|
48
|
+
let(:context) { ::Liquid::Context.new({}, {}, { live_editing: true }) }
|
49
|
+
|
50
|
+
it { expect(template.render(context)).to eq 'My product: <span class="locomotive-block-anchor" data-element-id="product" style="visibility: hidden"></span>Skis' }
|
51
|
+
|
52
|
+
end
|
53
|
+
|
46
54
|
end
|
@@ -4,7 +4,7 @@ require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb'
|
|
4
4
|
|
5
5
|
describe Locomotive::Steam::ContentEntryRepository do
|
6
6
|
|
7
|
-
let(:_fields) { instance_double('Fields', selects: []) }
|
7
|
+
let(:_fields) { instance_double('Fields', selects: [], belongs_to: []) }
|
8
8
|
let(:type) { build_content_type('Articles', label_field_name: :title, localized_names: [:title], fields: _fields, fields_by_name: { title: instance_double('Field', name: :title, type: :string) }) }
|
9
9
|
let(:entries) { [{ content_type_id: 1, _position: 0, _label: 'Update #1', title: { fr: 'Mise a jour #1' }, text: { en: 'added some free stuff', fr: 'phrase FR' }, date: '2009/05/12', category: 'General' }] }
|
10
10
|
let(:locale) { :en }
|
@@ -248,7 +248,7 @@ describe Locomotive::Steam::ContentEntryRepository do
|
|
248
248
|
let(:other_type) { build_content_type('Authors', _id: 2, label_field_name: :name, fields: _fields, fields_by_name: { name: instance_double('Field', name: :name, type: :string) }) }
|
249
249
|
let(:other_entries) { [{ content_type_id: 2, _id: 'john-doe', name: 'John Doe' }] }
|
250
250
|
|
251
|
-
let(:type_repository) { instance_double('ArticleBelongsToRepository', selects: []) }
|
251
|
+
let(:type_repository) { instance_double('ArticleBelongsToRepository', selects: [], belongs_to: []) }
|
252
252
|
|
253
253
|
before do
|
254
254
|
allow(type).to receive(:fields).and_return(type_repository)
|
@@ -281,7 +281,7 @@ describe Locomotive::Steam::ContentEntryRepository do
|
|
281
281
|
]
|
282
282
|
}
|
283
283
|
|
284
|
-
let(:type_repository) { instance_double('AuthorRepository', selects: []) }
|
284
|
+
let(:type_repository) { instance_double('AuthorRepository', selects: [], belongs_to: []) }
|
285
285
|
|
286
286
|
before do
|
287
287
|
allow(type).to receive(:fields).and_return(type_repository)
|
@@ -314,7 +314,7 @@ describe Locomotive::Steam::ContentEntryRepository do
|
|
314
314
|
]
|
315
315
|
}
|
316
316
|
|
317
|
-
let(:type_repository) { instance_double('AuthorRepository', selects: []) }
|
317
|
+
let(:type_repository) { instance_double('AuthorRepository', selects: [], belongs_to: []) }
|
318
318
|
|
319
319
|
before do
|
320
320
|
allow(type).to receive(:fields).and_return(type_repository)
|
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.0.0.
|
4
|
+
version: 1.0.0.rc3
|
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: 2015-
|
14
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -341,14 +341,14 @@ dependencies:
|
|
341
341
|
requirements:
|
342
342
|
- - "~>"
|
343
343
|
- !ruby/object:Gem::Version
|
344
|
-
version: 4.0.
|
344
|
+
version: 4.0.1
|
345
345
|
type: :runtime
|
346
346
|
prerelease: false
|
347
347
|
version_requirements: !ruby/object:Gem::Requirement
|
348
348
|
requirements:
|
349
349
|
- - "~>"
|
350
350
|
- !ruby/object:Gem::Version
|
351
|
-
version: 4.0.
|
351
|
+
version: 4.0.1
|
352
352
|
- !ruby/object:Gem::Dependency
|
353
353
|
name: locomotivecms_common
|
354
354
|
requirement: !ruby/object:Gem::Requirement
|
@@ -698,6 +698,7 @@ files:
|
|
698
698
|
- spec/unit/entities/content_entry_spec.rb
|
699
699
|
- spec/unit/entities/content_type_field_spec.rb
|
700
700
|
- spec/unit/entities/content_type_spec.rb
|
701
|
+
- spec/unit/entities/editable_element_spec.rb
|
701
702
|
- spec/unit/entities/page_spec.rb
|
702
703
|
- spec/unit/entities/site_spec.rb
|
703
704
|
- spec/unit/entities/snippet_spec.rb
|
@@ -791,7 +792,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
791
792
|
version: 1.3.1
|
792
793
|
requirements: []
|
793
794
|
rubyforge_project:
|
794
|
-
rubygems_version: 2.
|
795
|
+
rubygems_version: 2.5.0
|
795
796
|
signing_key:
|
796
797
|
specification_version: 4
|
797
798
|
summary: The LocomotiveCMS Steam is the rendering stack used by both Wagon and Engine
|
@@ -937,6 +938,7 @@ test_files:
|
|
937
938
|
- spec/unit/entities/content_entry_spec.rb
|
938
939
|
- spec/unit/entities/content_type_field_spec.rb
|
939
940
|
- spec/unit/entities/content_type_spec.rb
|
941
|
+
- spec/unit/entities/editable_element_spec.rb
|
940
942
|
- spec/unit/entities/page_spec.rb
|
941
943
|
- spec/unit/entities/site_spec.rb
|
942
944
|
- spec/unit/entities/snippet_spec.rb
|