middleman-simple-thumbnailer 1.2.0 → 1.2.1
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/README.md +9 -1
- data/features/caching_thumbnails_in_development.feature +1 -1
- data/features/generate_image_thumbnails_relative_assets.feature +32 -0
- data/features/support/image_thumbnails_steps.rb +3 -3
- data/fixtures/basic-app-relative-assets/config.rb +2 -0
- data/fixtures/basic-app-relative-assets/source/images/original.jpg +0 -0
- data/fixtures/basic-app-relative-assets/source/page-with-images-to-resize.html.erb +16 -0
- data/fixtures/basic-app-relative-assets/source/page-with-untouched-image.html.erb +9 -0
- data/lib/middleman-simple-thumbnailer/extension.rb +16 -13
- data/lib/middleman-simple-thumbnailer/version.rb +1 -1
- data/middleman-simple-thumbnailer.gemspec +4 -4
- metadata +21 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5f9fba464c6115cd6443277d404334f4362f9b8
|
4
|
+
data.tar.gz: 7e667fae2a59f05459919daed248e6c9ea440238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f06323a24426b629c6c6a786f1d2eba8fd6a6ec1fbd387b783427dfd95efa507ee1f7f66ee803d9674fe16eb057fdbb160fa771998cad5e2566b56473cc0976
|
7
|
+
data.tar.gz: 49ad31bf2a908ff68167e39f4789c1695fab81793895a44a34ccb1ad9d7738ba791e0035c7a9c8ab97ce0250bb6bea667b8b68a53f4f5f29b9fed25c69d624a2
|
data/README.md
CHANGED
@@ -34,11 +34,19 @@ You can also use the `image_path` helper the same way in place where you need on
|
|
34
34
|
This extension use ImageMagick (via mini_magick) to resize the images.
|
35
35
|
The `resize_to` format is therefore the one defined ny ImageMagick. The documentation can be found [there](http://www.imagemagick.org/script/command-line-processing.php#geometry).
|
36
36
|
|
37
|
+
Known limitation
|
38
|
+
----------------
|
39
|
+
|
40
|
+
In this current implementation, this extension is unable to update the [sitemap](https://middlemanapp.com/advanced/sitemap/). Some extensions (like [middleman-s3_sync](https://github.com/fredjean/middleman-s3_sync)) uses the content of the sitemap to do their work. Therefore, the generated resized images will not be seen by such extensions, even if they are corectly generated.
|
41
|
+
|
42
|
+
This issue [#13](https://github.com/kubenstein/middleman-simple-thumbnailer/issues/13) has been opened to describe the problem and discuss the possible solutions to this limitation.
|
43
|
+
|
37
44
|
Build/Development modes
|
38
45
|
-----
|
39
46
|
During development thumbnails will be created on fly and presented as a base64 strings.
|
40
47
|
During build thumbnails will be created as normal files and stored in same dir as their originals.
|
48
|
+
|
41
49
|
|
42
50
|
LICENSE
|
43
51
|
-----
|
44
|
-
MIT
|
52
|
+
MIT
|
@@ -6,7 +6,7 @@ Feature: Caching thumbnails in development
|
|
6
6
|
When I go to "/page-with-images-to-resize.html"
|
7
7
|
Then the cache directory should exist with the following files
|
8
8
|
| images/original.10x10gt.eb4e78fd2554225b2.jpg |
|
9
|
-
| images/original.5x5.eb4e78fd2554225b2.jpg
|
9
|
+
| images/original.5x5.eb4e78fd2554225b2.jpg |
|
10
10
|
|
11
11
|
Scenario: Cached thumbnails are used, if present
|
12
12
|
Given the Server is running at "cached-thumbnails"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: Generate image thumbnails
|
2
|
+
|
3
|
+
Scenario: Preserve default image_tag behaviour if no resize_to param is given
|
4
|
+
Given the Server is running at "basic-app-relative-assets"
|
5
|
+
When I go to "/page-with-untouched-image.html"
|
6
|
+
Then I should see '<img src="images/original.jpg" alt="Original" />'
|
7
|
+
|
8
|
+
Scenario: Preserve default image_tag behaviour after build if no resize_to param was given
|
9
|
+
Given a fixture app "basic-app-relative-assets"
|
10
|
+
And a successfully built app at "basic-app-relative-assets"
|
11
|
+
When I cd to "build"
|
12
|
+
Then the file "page-with-untouched-image.html" should contain '<img src="images/original.jpg" alt="Original" />'
|
13
|
+
|
14
|
+
Scenario: Generate base64 thumbnail of image with resize_to param given
|
15
|
+
Given the Server is running at "basic-app-relative-assets"
|
16
|
+
When I go to "/page-with-images-to-resize.html"
|
17
|
+
Then I should see base64ed thumbnails of the images
|
18
|
+
|
19
|
+
Scenario: After build server resized images
|
20
|
+
Given a fixture app "basic-app-relative-assets"
|
21
|
+
And a successfully built app at "basic-app-relative-assets"
|
22
|
+
When I cd to "build"
|
23
|
+
Then the following images should exist:
|
24
|
+
| filename | dimensions |
|
25
|
+
| images/original.10x10.jpg | 10x5 |
|
26
|
+
| images/original.5x5.jpg | 5x2 |
|
27
|
+
| images/original.20x20gt.jpg | 20x9 |
|
28
|
+
| images/original.15x15gt.jpg | 15x7 |
|
29
|
+
And the file "page-with-images-to-resize.html" should contain '<img src="images/original.10x10.jpg" class="image-resized-to10x10" alt="Original.10x10" />'
|
30
|
+
And the file "page-with-images-to-resize.html" should contain '<source srcset="images/original.20x20gt.jpg" media="(min-width: 900px)">'
|
31
|
+
And the file "page-with-images-to-resize.html" should contain '<img src="images/original.5x5.jpg" class="image-resized-to5x5" alt="Original.5x5" />'
|
32
|
+
And the file "page-with-images-to-resize.html" should contain '<source srcset="images/original.15x15gt.jpg" media="(min-width: 900px)">'
|
@@ -35,9 +35,9 @@ end
|
|
35
35
|
|
36
36
|
Then(/^the cache directory should exist (?:at "([^"]+)" )?with the following files$/) do |cache_dir, files|
|
37
37
|
cache_dir ||= MiddlemanSimpleThumbnailer::Extension.config.cache_dir
|
38
|
-
|
38
|
+
expect(cache_dir).to be_an_existing_directory
|
39
39
|
cd cache_dir
|
40
|
-
files.raw.map{|file_row| file_row[0]}.each { |f| expect(f).to
|
40
|
+
files.raw.map{|file_row| file_row[0]}.each { |f| expect(f).to be_an_existing_file }
|
41
41
|
end
|
42
42
|
|
43
43
|
Then(/^I should see base64ed data of the cached thumbnails with image path$/) do
|
@@ -68,7 +68,7 @@ end
|
|
68
68
|
|
69
69
|
Then(/^the following images should exist:$/) do |table|
|
70
70
|
table.hashes.each do |row|
|
71
|
-
|
71
|
+
cd('.') do
|
72
72
|
image = MiniMagick::Image.open(row["filename"])
|
73
73
|
expect(image.dimensions).to eq row["dimensions"].split("x").map(&:to_i)
|
74
74
|
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Hello World</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<picture>
|
8
|
+
<source srcset="<%= image_path 'original.jpg', resize_to: '20x20>'%>" media="(min-width: 900px)">
|
9
|
+
<%= image_tag 'original.jpg', resize_to: '10x10', class: 'image-resized-to10x10' %>
|
10
|
+
</picture>
|
11
|
+
<picture>
|
12
|
+
<source srcset="<%= image_path 'original.jpg', resize_to: '15x15>'%>" media="(min-width: 900px)">
|
13
|
+
<%= image_tag 'original.jpg', resize_to: '5x5', class: 'image-resized-to5x5' %>
|
14
|
+
</picture>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -34,28 +34,31 @@ module MiddlemanSimpleThumbnailer
|
|
34
34
|
|
35
35
|
helpers do
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
super(image_path(path, resize_to: resize_to), options)
|
40
|
-
else
|
41
|
-
super(path, options)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def image_path(path, options={})
|
46
|
-
resize_to = options.delete(:resize_to)
|
47
|
-
return super(path) unless resize_to
|
37
|
+
def resized_image_path(path, resize_to=nil)
|
38
|
+
return path unless resize_to
|
48
39
|
|
49
40
|
image = MiddlemanSimpleThumbnailer::Image.new(path, resize_to, app)
|
50
41
|
if app.development?
|
51
|
-
|
42
|
+
"data:#{image.mime_type};base64,#{image.base64_data}"
|
52
43
|
else
|
53
44
|
ext = app.extensions[:middleman_simple_thumbnailer]
|
54
45
|
ext.store_resized_image(path, resize_to)
|
55
|
-
|
46
|
+
image.resized_img_path
|
56
47
|
end
|
57
48
|
end
|
58
49
|
|
50
|
+
def image_tag(path, options={})
|
51
|
+
resize_to = options.delete(:resize_to)
|
52
|
+
new_path = resize_to ? resized_image_path(path, resize_to) : path
|
53
|
+
super(new_path, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def image_path(path, options={})
|
57
|
+
resize_to = options.delete(:resize_to)
|
58
|
+
new_path = resize_to ? resized_image_path(path, resize_to) : path
|
59
|
+
super(new_path)
|
60
|
+
end
|
61
|
+
|
59
62
|
end
|
60
63
|
|
61
64
|
end
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_runtime_dependency 'mini_magick', '~> 4'
|
21
21
|
|
22
22
|
s.add_development_dependency 'middleman-cli', '~> 4'
|
23
|
-
s.add_development_dependency 'rake', '~>
|
24
|
-
s.add_development_dependency 'aruba', '~>0.
|
25
|
-
s.add_development_dependency 'cucumber', '~>
|
26
|
-
s.add_development_dependency 'capybara', '~> 2.
|
23
|
+
s.add_development_dependency 'rake', '~> 12'
|
24
|
+
s.add_development_dependency 'aruba', '~> 0.14.2'
|
25
|
+
s.add_development_dependency 'cucumber', '~> 2.4'
|
26
|
+
s.add_development_dependency 'capybara', '~> 2.15'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-simple-thumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Niewczas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -58,56 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: aruba
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.14.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.14.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cucumber
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.4'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.4'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: capybara
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
103
|
+
version: '2.15'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2.
|
110
|
+
version: '2.15'
|
111
111
|
description: Middleman extension that allows you to create image thumbnails by providing
|
112
112
|
resize_to option to image_tag helper
|
113
113
|
email:
|
@@ -125,12 +125,17 @@ files:
|
|
125
125
|
- features/caching_thumbnails_in_development.feature
|
126
126
|
- features/generate_image_thumbnails.feature
|
127
127
|
- features/generate_image_thumbnails_image_path.feature
|
128
|
+
- features/generate_image_thumbnails_relative_assets.feature
|
128
129
|
- features/support/env.rb
|
129
130
|
- features/support/image_thumbnails_steps.rb
|
130
131
|
- fixtures/basic-app-image-path/config.rb
|
131
132
|
- fixtures/basic-app-image-path/source/images/original.jpg
|
132
133
|
- fixtures/basic-app-image-path/source/page-with-images-to-resize.html.erb
|
133
134
|
- fixtures/basic-app-image-path/source/page-with-untouched-image.html.erb
|
135
|
+
- fixtures/basic-app-relative-assets/config.rb
|
136
|
+
- fixtures/basic-app-relative-assets/source/images/original.jpg
|
137
|
+
- fixtures/basic-app-relative-assets/source/page-with-images-to-resize.html.erb
|
138
|
+
- fixtures/basic-app-relative-assets/source/page-with-untouched-image.html.erb
|
134
139
|
- fixtures/basic-app/config.rb
|
135
140
|
- fixtures/basic-app/source/images/original.jpg
|
136
141
|
- fixtures/basic-app/source/page-with-images-to-resize.html.erb
|
@@ -176,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
181
|
version: '0'
|
177
182
|
requirements: []
|
178
183
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.6.8
|
180
185
|
signing_key:
|
181
186
|
specification_version: 4
|
182
187
|
summary: Middleman extension that allows you to create image thumbnails by providing
|
@@ -185,12 +190,17 @@ test_files:
|
|
185
190
|
- features/caching_thumbnails_in_development.feature
|
186
191
|
- features/generate_image_thumbnails.feature
|
187
192
|
- features/generate_image_thumbnails_image_path.feature
|
193
|
+
- features/generate_image_thumbnails_relative_assets.feature
|
188
194
|
- features/support/env.rb
|
189
195
|
- features/support/image_thumbnails_steps.rb
|
190
196
|
- fixtures/basic-app-image-path/config.rb
|
191
197
|
- fixtures/basic-app-image-path/source/images/original.jpg
|
192
198
|
- fixtures/basic-app-image-path/source/page-with-images-to-resize.html.erb
|
193
199
|
- fixtures/basic-app-image-path/source/page-with-untouched-image.html.erb
|
200
|
+
- fixtures/basic-app-relative-assets/config.rb
|
201
|
+
- fixtures/basic-app-relative-assets/source/images/original.jpg
|
202
|
+
- fixtures/basic-app-relative-assets/source/page-with-images-to-resize.html.erb
|
203
|
+
- fixtures/basic-app-relative-assets/source/page-with-untouched-image.html.erb
|
194
204
|
- fixtures/basic-app/config.rb
|
195
205
|
- fixtures/basic-app/source/images/original.jpg
|
196
206
|
- fixtures/basic-app/source/page-with-images-to-resize.html.erb
|