locomotivecms_steam 1.0.0.rc4 → 1.0.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +3 -3
- data/lib/locomotive/steam/decorators/i18n_decorator.rb +8 -0
- data/lib/locomotive/steam/decorators/template_decorator.rb +5 -1
- data/lib/locomotive/steam/services/image_resizer_service.rb +2 -0
- data/lib/locomotive/steam/services/theme_asset_url_service.rb +1 -1
- data/lib/locomotive/steam/version.rb +1 -1
- data/spec/unit/decorators/i18n_decorator_spec.rb +34 -3
- data/spec/unit/decorators/template_decorator_spec.rb +9 -1
- 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: 73dc9ea0190083dd20c33f5e820da421b36d11b4
|
4
|
+
data.tar.gz: 5e74931081e00c151d857c449f0c14c3219e0f67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e2759d7ab8798c17f8a4a40b0779228410c8b0f0fb96b4aad83dd7589a2059e1baae8dae58be3f448ccd07ca2933e1ddd2a8a1e918924f3fb44a730825a4f9
|
7
|
+
data.tar.gz: 7b443e9021b581bd62cee286dd74bb02ee966086064313866f1379055069d23a30f5b198de07aa9da308772eb89003f0e5ae6f6eef07b317c4e2bcbed6d728c8
|
data/.travis.yml
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.rc6)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
6
|
chronic (~> 0.10.2)
|
7
7
|
coffee-script (~> 2.4.1)
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
mime-types (2.6.1)
|
121
121
|
mimetype-fu (0.1.2)
|
122
122
|
mini_portile (0.6.2)
|
123
|
-
minitest (5.8.
|
123
|
+
minitest (5.8.3)
|
124
124
|
moneta (0.8.0)
|
125
125
|
mongo (2.1.2)
|
126
126
|
bson (~> 3.0)
|
@@ -128,7 +128,7 @@ GEM
|
|
128
128
|
multi_json (1.11.1)
|
129
129
|
multi_xml (0.5.5)
|
130
130
|
netrc (0.10.3)
|
131
|
-
nokogiri (1.6.6.
|
131
|
+
nokogiri (1.6.6.4)
|
132
132
|
mini_portile (~> 0.6.0)
|
133
133
|
nokogumbo (1.4.1)
|
134
134
|
nokogiri
|
@@ -51,6 +51,14 @@ module Locomotive
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def __with_default_locale__(&block)
|
55
|
+
if self.__default_locale__
|
56
|
+
__with_locale__(self.__default_locale__, &block)
|
57
|
+
else
|
58
|
+
yield
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
54
62
|
def __freeze_locale__
|
55
63
|
@__frozen_locale__ = true
|
56
64
|
end
|
@@ -11,12 +11,16 @@ module Locomotive
|
|
11
11
|
if respond_to?(:template_path) && template_path
|
12
12
|
source_from_template_file
|
13
13
|
else
|
14
|
-
self.source
|
14
|
+
self.source.blank? ? source_in_default_locale : self.source
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
def source_in_default_locale
|
21
|
+
self.__with_default_locale__ { self.source }
|
22
|
+
end
|
23
|
+
|
20
24
|
def source_from_template_file
|
21
25
|
source = File.read(template_path).force_encoding('utf-8')
|
22
26
|
|
@@ -13,7 +13,7 @@ module Locomotive
|
|
13
13
|
# build the url of the theme asset based on the persistence layer
|
14
14
|
_url = repository.url_for(path)
|
15
15
|
|
16
|
-
# get a timestamp only the source url
|
16
|
+
# get a timestamp only if the source url doesn't include a query string
|
17
17
|
timestamp = query_string.blank? ? checksums[path] : nil
|
18
18
|
|
19
19
|
# prefix by a asset host if given
|
@@ -46,9 +46,40 @@ describe Locomotive::Steam::Decorators::I18nDecorator do
|
|
46
46
|
|
47
47
|
describe 'using the default locale' do
|
48
48
|
|
49
|
-
let(:
|
50
|
-
|
51
|
-
|
49
|
+
let(:default_locale) { 'en' }
|
50
|
+
|
51
|
+
context 'unknown locale' do
|
52
|
+
|
53
|
+
let(:locale) { 'de' }
|
54
|
+
|
55
|
+
it { expect(decorated.title).to eq 'Hello world!' }
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'existing locale' do
|
60
|
+
|
61
|
+
let(:locale) { 'fr' }
|
62
|
+
|
63
|
+
it 'uses the default locale and get back to the previous one' do
|
64
|
+
decorated.__with_default_locale__ do
|
65
|
+
expect(decorated.title).to eq 'Hello world!'
|
66
|
+
end
|
67
|
+
expect(decorated.__locale__).to eq :fr
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'default_locale is nil' do
|
71
|
+
|
72
|
+
let(:default_locale) { nil }
|
73
|
+
|
74
|
+
it 'yields the block if no default locale' do
|
75
|
+
decorated.__with_default_locale__ do
|
76
|
+
expect(decorated.title).to eq 'Bonjour monde'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
52
83
|
|
53
84
|
end
|
54
85
|
|
@@ -5,7 +5,7 @@ describe Locomotive::Steam::Decorators::TemplateDecorator do
|
|
5
5
|
let(:template_path) { 'template.liquid' }
|
6
6
|
let(:page) { instance_double('Page', localized_attributes: [], template_path: template_path) }
|
7
7
|
let(:locale) { 'fr' }
|
8
|
-
let(:default_locale) {
|
8
|
+
let(:default_locale) { 'en' }
|
9
9
|
let(:decorated) { described_class.new(page, locale, default_locale) }
|
10
10
|
|
11
11
|
describe '#liquid_source' do
|
@@ -18,6 +18,14 @@ describe Locomotive::Steam::Decorators::TemplateDecorator do
|
|
18
18
|
|
19
19
|
it { is_expected.to eq 'Lorem ipsum' }
|
20
20
|
|
21
|
+
context 'Raw template' do
|
22
|
+
|
23
|
+
let(:page) { instance_double('Page', localized_attributes: [:source], source: { en: 'Lorem ipsum [EN]', fr: '' }) }
|
24
|
+
|
25
|
+
it { is_expected.to eq 'Lorem ipsum [EN]' }
|
26
|
+
|
27
|
+
end
|
28
|
+
|
21
29
|
context 'HAML file' do
|
22
30
|
|
23
31
|
let(:template_path) { 'template.liquid.haml' }
|
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.rc6
|
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-11-
|
14
|
+
date: 2015-11-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|