locomotivecms 3.3.0.rc1 → 3.3.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/locomotive/editable_text.rb +9 -1
- data/app/services/locomotive/page_parsing_service.rb +10 -0
- data/lib/locomotive/carrierwave/asset.rb +1 -1
- data/lib/locomotive/steam/middlewares/cache.rb +2 -1
- data/lib/locomotive/version.rb +1 -1
- data/spec/requests/locomotive/steam/cache_spec.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e9f4f8edfefcd83de371071e2fa02fd7d64e1b1
|
|
4
|
+
data.tar.gz: b8f8065113b1588275132a2dc46f7cf7bc878437
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be0f754bc93350ecc01ab1bfdc312095b809a1ec02d9583c2c894165a213dc548c08fb5b23e07f6d095d8aef384112d528e3fc6a9cd38c3c328df957d27ce854
|
|
7
|
+
data.tar.gz: 1778764e6e160a64b4464afa58db5f93b97d2195d60c1af5b34ef67174a297b3809033d05e9ea71a0110037250196e7d2526309b2b3c93e35a641be34b592fc7
|
|
@@ -14,10 +14,18 @@ module Locomotive
|
|
|
14
14
|
|
|
15
15
|
## methods ##
|
|
16
16
|
|
|
17
|
+
# Change the content of the editable element if the value is a new version.
|
|
18
|
+
# This method has been overridden for 2 reasons:
|
|
19
|
+
# - we have to register the current locale (localized site)
|
|
20
|
+
# - the default_content attribute has to be turned off
|
|
21
|
+
#
|
|
22
|
+
# Called by:
|
|
23
|
+
# - the API: page with a YAML header defining the initial content for this editable element
|
|
24
|
+
# - the UI: if the content is the same as the default one or the previous one, don't do anything.
|
|
17
25
|
def content=(value)
|
|
18
26
|
return if value == self.content
|
|
19
27
|
self.add_current_locale
|
|
20
|
-
self.default_content = false
|
|
28
|
+
self.default_content = false
|
|
21
29
|
super
|
|
22
30
|
end
|
|
23
31
|
|
|
@@ -153,9 +153,19 @@ module Locomotive
|
|
|
153
153
|
|
|
154
154
|
def add_or_modify_editable_element(page, attributes)
|
|
155
155
|
if element = page.editable_elements.by_block_and_slug(attributes[:block], attributes[:slug]).first
|
|
156
|
+
# context: the editable element has been created from the page YAML header
|
|
157
|
+
existing_content = element._type.nil? && !element.content.blank?
|
|
158
|
+
|
|
156
159
|
# FIXME: we don't want to deal here with the generic Locomotive::EditableElement class
|
|
157
160
|
element = page.editable_elements.with_same_class!(element, "Locomotive::#{attributes[:type].to_s.classify}".constantize)
|
|
158
161
|
element.attributes = attributes
|
|
162
|
+
|
|
163
|
+
# we know now this was an editable_text element. If it already had
|
|
164
|
+
# a content, then it shouldn't be flagged as default_content.
|
|
165
|
+
if element.respond_to?(:default_content?) && existing_content
|
|
166
|
+
element.default_content = false
|
|
167
|
+
end
|
|
168
|
+
|
|
159
169
|
element
|
|
160
170
|
else
|
|
161
171
|
klass = "Locomotive::#{attributes[:type].to_s.classify}".constantize
|
|
@@ -34,7 +34,7 @@ module Locomotive
|
|
|
34
34
|
def set_content_type_of_model(*args)
|
|
35
35
|
content_type = file.content_type
|
|
36
36
|
|
|
37
|
-
if content_type.blank? ||
|
|
37
|
+
if content_type.blank? || ['application/octet-stream', 'text/x-csrc'].include?(content_type)
|
|
38
38
|
content_type = File.mime_type?(original_filename)
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -37,7 +37,8 @@ module Locomotive
|
|
|
37
37
|
def marshal(response)
|
|
38
38
|
code, headers, body = response
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
# only keep string value headers
|
|
41
|
+
_headers = headers.reject { |key, val| !val.respond_to?(:to_str) }
|
|
41
42
|
|
|
42
43
|
Marshal.dump([code, _headers, body])
|
|
43
44
|
end
|
data/lib/locomotive/version.rb
CHANGED
|
@@ -8,7 +8,7 @@ describe Locomotive::Steam::Middlewares::Cache do
|
|
|
8
8
|
let(:page) { instance_double('CachedPage', _id: '0042', cache_enabled: page_cache, redirect_url: nil) }
|
|
9
9
|
let(:app) { ->(env) { [200, env, 'app'] } }
|
|
10
10
|
let(:middleware) { described_class.new(app) }
|
|
11
|
-
let(:steam_env) { { 'REQUEST_METHOD' => 'GET', 'steam.site' => site, 'steam.page' => page, 'steam.live_editing' => false, 'PATH_INFO' => 'foo', 'QUERY_STRING' => 'a=1&c=3' } }
|
|
11
|
+
let(:steam_env) { { 'Content-Type' => 'text/html', 'REQUEST_METHOD' => 'GET', 'steam.site' => site, 'steam.page' => page, 'steam.live_editing' => false, 'PATH_INFO' => 'foo', 'QUERY_STRING' => 'a=1&c=3' } }
|
|
12
12
|
|
|
13
13
|
describe '#call' do
|
|
14
14
|
|
|
@@ -29,6 +29,7 @@ describe Locomotive::Steam::Middlewares::Cache do
|
|
|
29
29
|
middleware.call(env_for('foo', steam_env)) # warm up the cache
|
|
30
30
|
expect(middleware.app).not_to receive(:call)
|
|
31
31
|
expect(subject.first).to eq 200
|
|
32
|
+
expect(subject[1]['Content-Type']).to eq 'text/html'
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
end
|
|
@@ -39,7 +40,7 @@ describe Locomotive::Steam::Middlewares::Cache do
|
|
|
39
40
|
|
|
40
41
|
subject { middleware.send(:cache_key, steam_env) }
|
|
41
42
|
|
|
42
|
-
it { expect(subject).to eq '
|
|
43
|
+
it { expect(subject).to eq '6f10bd02e43a99e1bef1223da0e266ec' }
|
|
43
44
|
|
|
44
45
|
end
|
|
45
46
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: locomotivecms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.0.
|
|
4
|
+
version: 3.3.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Didier Lafforgue
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-03-
|
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|