locomotivecms_steam 1.2.0.rc1 → 1.2.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/locomotive/steam/liquid/filters/resize.rb +33 -2
- data/lib/locomotive/steam/liquid/tags/editable/file.rb +1 -1
- data/lib/locomotive/steam/services/asset_host_service.rb +1 -1
- data/lib/locomotive/steam/services/image_resizer_service.rb +4 -2
- data/lib/locomotive/steam/version.rb +1 -1
- data/spec/unit/liquid/filters/resize_spec.rb +46 -0
- data/spec/unit/services/asset_host_service_spec.rb +7 -0
- data/spec/unit/services/image_resizer_service_spec.rb +9 -0
- 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: 9a6e18bc9462639abb5ca0ad612c9e25891657dc
|
4
|
+
data.tar.gz: 4671db28b74b0241d7c31fdb6573aa93f0e10350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 237e6723009705ffb9ea1295ea8976074cbaa79ebe5a47f866896f2e34f2af9563640e53951b97d7540b0e0ffb9d2a86b74bc93bab7df02f317ec869a691feb8
|
7
|
+
data.tar.gz: 0847e3956476840614b275101f659ca01ca6a708568f25a66bca0db5cb023c9d1bab620c22e3c66f2806676b74a6cc294d104ebcbfc97a5a82fc34503c37ed44
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.2.0.
|
4
|
+
locomotivecms_steam (1.2.0.rc2)
|
5
5
|
RedCloth (~> 4.3.2)
|
6
6
|
autoprefixer-rails (~> 6.3.3.1)
|
7
7
|
chronic (~> 0.10.2)
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
remote: https://rubygems.org/
|
31
31
|
specs:
|
32
32
|
RedCloth (4.3.2)
|
33
|
-
activesupport (4.2.7)
|
33
|
+
activesupport (4.2.7.1)
|
34
34
|
i18n (~> 0.7)
|
35
35
|
json (~> 1.7, >= 1.7.7)
|
36
36
|
minitest (~> 5.1)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
bson (4.1.1)
|
44
44
|
byebug (8.2.5)
|
45
45
|
chronic (0.10.2)
|
46
|
-
chunky_png (1.3.
|
46
|
+
chunky_png (1.3.7)
|
47
47
|
codeclimate-test-reporter (0.4.8)
|
48
48
|
simplecov (>= 0.7.1, < 1.0.0)
|
49
49
|
coderay (1.1.1)
|
@@ -4,8 +4,39 @@ module Locomotive
|
|
4
4
|
module Filters
|
5
5
|
module Resize
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
# Optional args include:
|
8
|
+
# quality: <number> compress image
|
9
|
+
# auto_orient: <true|false> fix EXIF orientation issues
|
10
|
+
# strip: <true|false> remove extra possibly unnecessary metadata
|
11
|
+
# progressive: <true|false> make JPEG progressive
|
12
|
+
# optimize: <number> shortcut to quality: and also applies strip and progressive
|
13
|
+
# filters: <string> access to any ImageMagick arguments
|
14
|
+
def resize(input, resize_string, *args)
|
15
|
+
args ||= {}
|
16
|
+
options = []
|
17
|
+
|
18
|
+
args.flatten.each do |arg|
|
19
|
+
arg.each do |k, v|
|
20
|
+
options << case k.to_sym
|
21
|
+
when :quality
|
22
|
+
"-quality #{v}"
|
23
|
+
when :optimize # Shortcut helper to set quality, progressive and strip
|
24
|
+
"-quality #{v} -strip -interlace Plane"
|
25
|
+
when :auto_orient
|
26
|
+
"-auto-orient" if v
|
27
|
+
when :strip
|
28
|
+
"-strip" if v
|
29
|
+
when :progressive
|
30
|
+
"-interlace Plane" if v
|
31
|
+
when :filters
|
32
|
+
v
|
33
|
+
else
|
34
|
+
next
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@context.registers[:services].image_resizer.resize(input, resize_string, options.join(' '))
|
9
40
|
end
|
10
41
|
|
11
42
|
end
|
@@ -59,7 +59,7 @@ module Locomotive
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# in the live editing mode, tag all the images with their editable path (block + slug)
|
62
|
-
if editable?(context)
|
62
|
+
if editable?(context) && !url.blank?
|
63
63
|
url = url + (url.include?('?') ? '&' : '?') + 'editable-path=' + @path
|
64
64
|
end
|
65
65
|
|
@@ -5,11 +5,13 @@ module Locomotive
|
|
5
5
|
|
6
6
|
attr_accessor_initialize :resizer, :asset_path
|
7
7
|
|
8
|
-
def resize(source, geometry)
|
8
|
+
def resize(source, geometry, convert = "")
|
9
9
|
return get_url_or_path(source) if disabled? || geometry.blank?
|
10
10
|
|
11
11
|
if file = fetch_file(source)
|
12
|
-
file.thumb(geometry)
|
12
|
+
transformed_file = file.thumb(geometry)
|
13
|
+
transformed_file = transformed_file.convert(convert) if !convert.blank?
|
14
|
+
transformed_file.url
|
13
15
|
else
|
14
16
|
Locomotive::Common::Logger.error "Unable to resize on the fly: #{source.inspect}"
|
15
17
|
nil
|
@@ -48,6 +48,52 @@ describe Locomotive::Steam::Liquid::Filters::Resize do
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
+
describe 'additional filters' do
|
52
|
+
let(:geometry) { '30x40#' }
|
53
|
+
subject {}
|
54
|
+
|
55
|
+
before do
|
56
|
+
@context.registers[:services].image_resizer = instance_spy('ImageResizerService')
|
57
|
+
@image_resizer = @context.registers[:services].image_resizer
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'handles quality' do
|
61
|
+
resize(input, geometry, { 'quality' => 70 })
|
62
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-quality 70')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'handles auto_orient' do
|
66
|
+
resize(input, geometry, { 'auto_orient' => true })
|
67
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-auto-orient')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "doesn't auto_orient if false" do
|
71
|
+
resize(input, geometry, { 'auto_orient' => false })
|
72
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'handles optimize' do
|
76
|
+
resize(input, geometry, { 'optimize' => 75 })
|
77
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-quality 75 -strip -interlace Plane')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'handles multiple and custom filters' do
|
81
|
+
resize(input, geometry, { 'quality' => 60, 'filters' => '-sepia-tone 80%' })
|
82
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-quality 60 -sepia-tone 80%')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'handles progressive display' do
|
86
|
+
resize(input, geometry, { 'progressive' => true })
|
87
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-interlace Plane')
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'handles strip' do
|
91
|
+
resize(input, geometry, { 'strip' => true })
|
92
|
+
expect(@image_resizer).to have_received(:resize).with(input, geometry, '-strip')
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
51
97
|
end
|
52
98
|
|
53
99
|
end
|
@@ -68,6 +68,15 @@ describe Locomotive::Steam::ImageResizerService do
|
|
68
68
|
|
69
69
|
end
|
70
70
|
|
71
|
+
describe 'additional filters' do
|
72
|
+
let(:input) { '/sites/42/theme/images/banner.png' }
|
73
|
+
let (:filters) { [{"quality" => 70, "auto_orient" => true, "filters" => "-swirl 180"}] }
|
74
|
+
|
75
|
+
subject { service.resize(input, geometry, filters) }
|
76
|
+
|
77
|
+
it { is_expected.to match /\/steam\/dynamic\/.*\/banner.png/ }
|
78
|
+
end
|
79
|
+
|
71
80
|
end
|
72
81
|
|
73
82
|
end
|
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.2.0.
|
4
|
+
version: 1.2.0.rc2
|
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: 2016-
|
14
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|