middleman-images 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +29 -0
- data/CHANGELOG.md +32 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +194 -0
- data/LICENSE +20 -0
- data/README.md +142 -0
- data/Rakefile +18 -0
- data/features/building.feature +79 -0
- data/features/ignore_original.feature +78 -0
- data/features/image_path.feature +67 -0
- data/features/optimization.feature +57 -0
- data/features/relative_path.feature +40 -0
- data/features/resize.feature +29 -0
- data/features/support/env.rb +4 -0
- data/features/support/middleman_images_steps.rb +31 -0
- data/fixtures/image/source/images/fox.jpg +0 -0
- data/gemfiles/Gemfile.middleman-4.1 +27 -0
- data/gemfiles/Gemfile.middleman-4.1.lock +196 -0
- data/gemfiles/Gemfile.middleman-4.2 +27 -0
- data/gemfiles/Gemfile.middleman-4.2.lock +196 -0
- data/gemfiles/Gemfile.middleman-4.3 +27 -0
- data/gemfiles/Gemfile.middleman-4.3.lock +194 -0
- data/gemfiles/Gemfile.middleman-5.0-rc +27 -0
- data/gemfiles/Gemfile.middleman-5.0-rc.lock +199 -0
- data/lib/middleman-images.rb +8 -0
- data/lib/middleman-images/extension.rb +89 -0
- data/lib/middleman-images/image.rb +68 -0
- data/lib/middleman-images/manipulator.rb +49 -0
- data/lib/middleman-images/version.rb +3 -0
- data/middleman-images.gemspec +23 -0
- metadata +98 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
middleman-images (0.1.0)
|
5
|
+
middleman-core (>= 4.1.14)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (5.0.7.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
aruba (0.14.14)
|
18
|
+
childprocess (>= 0.6.3, < 4.0.0)
|
19
|
+
contracts (~> 0.9)
|
20
|
+
cucumber (>= 1.3.19)
|
21
|
+
ffi (~> 1.9)
|
22
|
+
rspec-expectations (>= 2.99)
|
23
|
+
thor (>= 0.19, < 2.0)
|
24
|
+
backports (3.15.0)
|
25
|
+
builder (3.2.4)
|
26
|
+
capybara (3.31.0)
|
27
|
+
addressable
|
28
|
+
mini_mime (>= 0.1.3)
|
29
|
+
nokogiri (~> 1.8)
|
30
|
+
rack (>= 1.6.0)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
regexp_parser (~> 1.5)
|
33
|
+
xpath (~> 3.2)
|
34
|
+
childprocess (3.0.0)
|
35
|
+
coffee-script (2.4.1)
|
36
|
+
coffee-script-source
|
37
|
+
execjs
|
38
|
+
coffee-script-source (1.12.2)
|
39
|
+
concurrent-ruby (1.1.5)
|
40
|
+
contracts (0.13.0)
|
41
|
+
cucumber (3.1.2)
|
42
|
+
builder (>= 2.1.2)
|
43
|
+
cucumber-core (~> 3.2.0)
|
44
|
+
cucumber-expressions (~> 6.0.1)
|
45
|
+
cucumber-wire (~> 0.0.1)
|
46
|
+
diff-lcs (~> 1.3)
|
47
|
+
gherkin (~> 5.1.0)
|
48
|
+
multi_json (>= 1.7.5, < 2.0)
|
49
|
+
multi_test (>= 0.1.2)
|
50
|
+
cucumber-core (3.2.1)
|
51
|
+
backports (>= 3.8.0)
|
52
|
+
cucumber-tag_expressions (~> 1.1.0)
|
53
|
+
gherkin (~> 5.0)
|
54
|
+
cucumber-expressions (6.0.1)
|
55
|
+
cucumber-tag_expressions (1.1.1)
|
56
|
+
cucumber-wire (0.0.1)
|
57
|
+
diff-lcs (1.3)
|
58
|
+
dotenv (2.7.5)
|
59
|
+
erubis (2.7.0)
|
60
|
+
execjs (2.7.0)
|
61
|
+
exifr (1.3.6)
|
62
|
+
fast_blank (1.0.0)
|
63
|
+
fastimage (2.1.7)
|
64
|
+
ffi (1.12.2)
|
65
|
+
fspath (3.1.2)
|
66
|
+
gherkin (5.1.0)
|
67
|
+
haml (5.1.2)
|
68
|
+
temple (>= 0.8.0)
|
69
|
+
tilt
|
70
|
+
hamster (3.0.0)
|
71
|
+
concurrent-ruby (~> 1.0)
|
72
|
+
hashie (3.6.0)
|
73
|
+
i18n (0.9.5)
|
74
|
+
concurrent-ruby (~> 1.0)
|
75
|
+
image_optim (0.26.5)
|
76
|
+
exifr (~> 1.2, >= 1.2.2)
|
77
|
+
fspath (~> 3.0)
|
78
|
+
image_size (>= 1.5, < 3)
|
79
|
+
in_threads (~> 1.3)
|
80
|
+
progress (~> 3.0, >= 3.0.1)
|
81
|
+
image_optim_pack (0.6.0)
|
82
|
+
fspath (>= 2.1, < 4)
|
83
|
+
image_optim (~> 0.19)
|
84
|
+
image_size (2.0.2)
|
85
|
+
in_threads (1.5.4)
|
86
|
+
kramdown (1.17.0)
|
87
|
+
listen (3.0.8)
|
88
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
89
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
90
|
+
memoist (0.16.2)
|
91
|
+
middleman (4.3.5)
|
92
|
+
coffee-script (~> 2.2)
|
93
|
+
haml (>= 4.0.5)
|
94
|
+
kramdown (~> 1.2)
|
95
|
+
middleman-cli (= 4.3.5)
|
96
|
+
middleman-core (= 4.3.5)
|
97
|
+
middleman-cli (4.3.5)
|
98
|
+
thor (>= 0.17.0, < 2.0)
|
99
|
+
middleman-core (4.3.5)
|
100
|
+
activesupport (>= 4.2, < 5.1)
|
101
|
+
addressable (~> 2.3)
|
102
|
+
backports (~> 3.6)
|
103
|
+
bundler
|
104
|
+
contracts (~> 0.13.0)
|
105
|
+
dotenv
|
106
|
+
erubis
|
107
|
+
execjs (~> 2.0)
|
108
|
+
fast_blank
|
109
|
+
fastimage (~> 2.0)
|
110
|
+
hamster (~> 3.0)
|
111
|
+
hashie (~> 3.4)
|
112
|
+
i18n (~> 0.9.0)
|
113
|
+
listen (~> 3.0.0)
|
114
|
+
memoist (~> 0.14)
|
115
|
+
padrino-helpers (~> 0.13.0)
|
116
|
+
parallel
|
117
|
+
rack (>= 1.4.5, < 3)
|
118
|
+
sassc (~> 2.0)
|
119
|
+
servolux
|
120
|
+
tilt (~> 2.0.9)
|
121
|
+
uglifier (~> 3.0)
|
122
|
+
mini_magick (4.10.1)
|
123
|
+
mini_mime (1.0.2)
|
124
|
+
mini_portile2 (2.4.0)
|
125
|
+
minitest (5.14.0)
|
126
|
+
multi_json (1.14.1)
|
127
|
+
multi_test (0.1.2)
|
128
|
+
nokogiri (1.10.7)
|
129
|
+
mini_portile2 (~> 2.4.0)
|
130
|
+
padrino-helpers (0.13.3.4)
|
131
|
+
i18n (~> 0.6, >= 0.6.7)
|
132
|
+
padrino-support (= 0.13.3.4)
|
133
|
+
tilt (>= 1.4.1, < 3)
|
134
|
+
padrino-support (0.13.3.4)
|
135
|
+
activesupport (>= 3.1)
|
136
|
+
parallel (1.19.1)
|
137
|
+
progress (3.5.2)
|
138
|
+
public_suffix (4.0.3)
|
139
|
+
rack (2.1.2)
|
140
|
+
rack-test (1.1.0)
|
141
|
+
rack (>= 1.0, < 3)
|
142
|
+
rake (13.0.1)
|
143
|
+
rb-fsevent (0.10.3)
|
144
|
+
rb-inotify (0.10.1)
|
145
|
+
ffi (~> 1.0)
|
146
|
+
rdoc (6.2.1)
|
147
|
+
regexp_parser (1.6.0)
|
148
|
+
rspec (3.9.0)
|
149
|
+
rspec-core (~> 3.9.0)
|
150
|
+
rspec-expectations (~> 3.9.0)
|
151
|
+
rspec-mocks (~> 3.9.0)
|
152
|
+
rspec-core (3.9.1)
|
153
|
+
rspec-support (~> 3.9.1)
|
154
|
+
rspec-expectations (3.9.0)
|
155
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
156
|
+
rspec-support (~> 3.9.0)
|
157
|
+
rspec-mocks (3.9.1)
|
158
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
159
|
+
rspec-support (~> 3.9.0)
|
160
|
+
rspec-support (3.9.2)
|
161
|
+
sassc (2.2.1)
|
162
|
+
ffi (~> 1.9)
|
163
|
+
servolux (0.13.0)
|
164
|
+
temple (0.8.2)
|
165
|
+
thor (1.0.1)
|
166
|
+
thread_safe (0.3.6)
|
167
|
+
tilt (2.0.10)
|
168
|
+
tzinfo (1.2.6)
|
169
|
+
thread_safe (~> 0.1)
|
170
|
+
uglifier (3.2.0)
|
171
|
+
execjs (>= 0.3.0, < 3)
|
172
|
+
xpath (3.2.0)
|
173
|
+
nokogiri (~> 1.8)
|
174
|
+
yard (0.9.24)
|
175
|
+
|
176
|
+
PLATFORMS
|
177
|
+
ruby
|
178
|
+
|
179
|
+
DEPENDENCIES
|
180
|
+
aruba
|
181
|
+
capybara
|
182
|
+
cucumber
|
183
|
+
image_optim
|
184
|
+
image_optim_pack (= 0.6.0)
|
185
|
+
middleman (~> 4.3.0)
|
186
|
+
middleman-images!
|
187
|
+
mini_magick
|
188
|
+
rake
|
189
|
+
rdoc
|
190
|
+
rspec
|
191
|
+
yard
|
192
|
+
|
193
|
+
BUNDLED WITH
|
194
|
+
2.1.4
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# If you do not have OpenSSL installed, update
|
2
|
+
# the following line to use "http://" instead
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in middleman-images.gemspec
|
6
|
+
gemspec path: '..'
|
7
|
+
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'middleman', '~> 5.0.0.rc'
|
11
|
+
gem 'rake'
|
12
|
+
gem 'rdoc'
|
13
|
+
gem 'yard'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'cucumber'
|
18
|
+
gem 'capybara'
|
19
|
+
gem 'aruba'
|
20
|
+
gem 'rspec'
|
21
|
+
|
22
|
+
gem 'image_optim'
|
23
|
+
gem 'mini_magick'
|
24
|
+
|
25
|
+
# Version is locked to make sure asset_hash tests are not broken by updated optimizations.
|
26
|
+
gem 'image_optim_pack', '=0.6.0'
|
27
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
middleman-images (0.1.0)
|
5
|
+
middleman-core (>= 4.1.14)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (5.2.4.1)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
aruba (0.14.14)
|
18
|
+
childprocess (>= 0.6.3, < 4.0.0)
|
19
|
+
contracts (~> 0.9)
|
20
|
+
cucumber (>= 1.3.19)
|
21
|
+
ffi (~> 1.9)
|
22
|
+
rspec-expectations (>= 2.99)
|
23
|
+
thor (>= 0.19, < 2.0)
|
24
|
+
backports (3.15.0)
|
25
|
+
builder (3.2.4)
|
26
|
+
capybara (3.31.0)
|
27
|
+
addressable
|
28
|
+
mini_mime (>= 0.1.3)
|
29
|
+
nokogiri (~> 1.8)
|
30
|
+
rack (>= 1.6.0)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
regexp_parser (~> 1.5)
|
33
|
+
xpath (~> 3.2)
|
34
|
+
childprocess (3.0.0)
|
35
|
+
coffee-script (2.4.1)
|
36
|
+
coffee-script-source
|
37
|
+
execjs
|
38
|
+
coffee-script-source (1.12.2)
|
39
|
+
concurrent-ruby (1.1.5)
|
40
|
+
contracts (0.16.0)
|
41
|
+
cucumber (3.1.2)
|
42
|
+
builder (>= 2.1.2)
|
43
|
+
cucumber-core (~> 3.2.0)
|
44
|
+
cucumber-expressions (~> 6.0.1)
|
45
|
+
cucumber-wire (~> 0.0.1)
|
46
|
+
diff-lcs (~> 1.3)
|
47
|
+
gherkin (~> 5.1.0)
|
48
|
+
multi_json (>= 1.7.5, < 2.0)
|
49
|
+
multi_test (>= 0.1.2)
|
50
|
+
cucumber-core (3.2.1)
|
51
|
+
backports (>= 3.8.0)
|
52
|
+
cucumber-tag_expressions (~> 1.1.0)
|
53
|
+
gherkin (~> 5.0)
|
54
|
+
cucumber-expressions (6.0.1)
|
55
|
+
cucumber-tag_expressions (1.1.1)
|
56
|
+
cucumber-wire (0.0.1)
|
57
|
+
diff-lcs (1.3)
|
58
|
+
dotenv (2.7.5)
|
59
|
+
erubis (2.7.0)
|
60
|
+
execjs (2.7.0)
|
61
|
+
exifr (1.3.6)
|
62
|
+
fastimage (2.1.7)
|
63
|
+
ffi (1.12.2)
|
64
|
+
fspath (3.1.2)
|
65
|
+
gherkin (5.1.0)
|
66
|
+
haml (5.1.2)
|
67
|
+
temple (>= 0.8.0)
|
68
|
+
tilt
|
69
|
+
hamster (3.0.0)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
hashie (3.6.0)
|
72
|
+
i18n (0.9.5)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
image_optim (0.26.5)
|
75
|
+
exifr (~> 1.2, >= 1.2.2)
|
76
|
+
fspath (~> 3.0)
|
77
|
+
image_size (>= 1.5, < 3)
|
78
|
+
in_threads (~> 1.3)
|
79
|
+
progress (~> 3.0, >= 3.0.1)
|
80
|
+
image_optim_pack (0.6.0)
|
81
|
+
fspath (>= 2.1, < 4)
|
82
|
+
image_optim (~> 0.19)
|
83
|
+
image_size (2.0.2)
|
84
|
+
in_threads (1.5.4)
|
85
|
+
kramdown (1.17.0)
|
86
|
+
lazy_priority_queue (0.1.1)
|
87
|
+
listen (3.2.1)
|
88
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
89
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
90
|
+
memoist (0.16.2)
|
91
|
+
middleman (5.0.0.rc.1)
|
92
|
+
coffee-script (~> 2.2)
|
93
|
+
haml (>= 4.0.5)
|
94
|
+
kramdown (~> 1.2)
|
95
|
+
middleman-cli (= 5.0.0.rc.1)
|
96
|
+
middleman-core (= 5.0.0.rc.1)
|
97
|
+
middleman-cli (5.0.0.rc.1)
|
98
|
+
thor (>= 0.17.0, < 2.0)
|
99
|
+
middleman-core (5.0.0.rc.1)
|
100
|
+
activesupport (~> 5.2)
|
101
|
+
addressable (~> 2.3)
|
102
|
+
backports (~> 3.11)
|
103
|
+
bundler
|
104
|
+
contracts (~> 0.16.0)
|
105
|
+
dotenv
|
106
|
+
erubis
|
107
|
+
execjs (~> 2.0)
|
108
|
+
fastimage (~> 2.0)
|
109
|
+
hamster (~> 3.0)
|
110
|
+
hashie (~> 3.4)
|
111
|
+
i18n (~> 0.9.0)
|
112
|
+
listen (~> 3.0)
|
113
|
+
memoist (~> 0.14)
|
114
|
+
oj (~> 3.7)
|
115
|
+
padrino-helpers (~> 0.14.4)
|
116
|
+
parallel
|
117
|
+
rack (>= 1.4.5, < 3)
|
118
|
+
rgl (~> 0.5.3)
|
119
|
+
sassc (~> 2.0)
|
120
|
+
servolux
|
121
|
+
tilt (~> 2.0.9)
|
122
|
+
uglifier (~> 4.1)
|
123
|
+
mini_magick (4.10.1)
|
124
|
+
mini_mime (1.0.2)
|
125
|
+
mini_portile2 (2.4.0)
|
126
|
+
minitest (5.14.0)
|
127
|
+
multi_json (1.14.1)
|
128
|
+
multi_test (0.1.2)
|
129
|
+
nokogiri (1.10.7)
|
130
|
+
mini_portile2 (~> 2.4.0)
|
131
|
+
oj (3.10.2)
|
132
|
+
padrino-helpers (0.14.4)
|
133
|
+
i18n (~> 0.6, >= 0.6.7)
|
134
|
+
padrino-support (= 0.14.4)
|
135
|
+
tilt (>= 1.4.1, < 3)
|
136
|
+
padrino-support (0.14.4)
|
137
|
+
parallel (1.19.1)
|
138
|
+
progress (3.5.2)
|
139
|
+
public_suffix (4.0.3)
|
140
|
+
rack (2.1.2)
|
141
|
+
rack-test (1.1.0)
|
142
|
+
rack (>= 1.0, < 3)
|
143
|
+
rake (13.0.1)
|
144
|
+
rb-fsevent (0.10.3)
|
145
|
+
rb-inotify (0.10.1)
|
146
|
+
ffi (~> 1.0)
|
147
|
+
rdoc (6.2.1)
|
148
|
+
regexp_parser (1.6.0)
|
149
|
+
rgl (0.5.6)
|
150
|
+
lazy_priority_queue (~> 0.1.0)
|
151
|
+
stream (~> 0.5.2)
|
152
|
+
rspec (3.9.0)
|
153
|
+
rspec-core (~> 3.9.0)
|
154
|
+
rspec-expectations (~> 3.9.0)
|
155
|
+
rspec-mocks (~> 3.9.0)
|
156
|
+
rspec-core (3.9.1)
|
157
|
+
rspec-support (~> 3.9.1)
|
158
|
+
rspec-expectations (3.9.0)
|
159
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
160
|
+
rspec-support (~> 3.9.0)
|
161
|
+
rspec-mocks (3.9.1)
|
162
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
163
|
+
rspec-support (~> 3.9.0)
|
164
|
+
rspec-support (3.9.2)
|
165
|
+
sassc (2.2.1)
|
166
|
+
ffi (~> 1.9)
|
167
|
+
servolux (0.13.0)
|
168
|
+
stream (0.5.2)
|
169
|
+
temple (0.8.2)
|
170
|
+
thor (1.0.1)
|
171
|
+
thread_safe (0.3.6)
|
172
|
+
tilt (2.0.10)
|
173
|
+
tzinfo (1.2.6)
|
174
|
+
thread_safe (~> 0.1)
|
175
|
+
uglifier (4.2.0)
|
176
|
+
execjs (>= 0.3.0, < 3)
|
177
|
+
xpath (3.2.0)
|
178
|
+
nokogiri (~> 1.8)
|
179
|
+
yard (0.9.24)
|
180
|
+
|
181
|
+
PLATFORMS
|
182
|
+
ruby
|
183
|
+
|
184
|
+
DEPENDENCIES
|
185
|
+
aruba
|
186
|
+
capybara
|
187
|
+
cucumber
|
188
|
+
image_optim
|
189
|
+
image_optim_pack (= 0.6.0)
|
190
|
+
middleman (~> 5.0.0.rc)
|
191
|
+
middleman-images!
|
192
|
+
mini_magick
|
193
|
+
rake
|
194
|
+
rdoc
|
195
|
+
rspec
|
196
|
+
yard
|
197
|
+
|
198
|
+
BUNDLED WITH
|
199
|
+
2.1.4
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'middleman-core'
|
2
|
+
require 'pathname'
|
3
|
+
require 'padrino-helpers'
|
4
|
+
|
5
|
+
module Middleman
|
6
|
+
module Images
|
7
|
+
class Extension < ::Middleman::Extension
|
8
|
+
option :optimize, false, 'Whether to optimize images by default'
|
9
|
+
option :image_optim, {}, 'Default options for image_optim'
|
10
|
+
option :ignore_original, false, 'Whether to ignore original images in build'
|
11
|
+
option :cache_dir, 'cache', 'Specification of cache folder'
|
12
|
+
|
13
|
+
helpers do
|
14
|
+
def image_tag(url, options = {})
|
15
|
+
process_options = options.slice(:resize, :optimize)
|
16
|
+
options = { src: image_path(url, process_options) }.update(options.except(:resize, :optimize))
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def image_path(url, process_options = {})
|
21
|
+
url = extensions[:images].image(url, process_options)
|
22
|
+
super url
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def template_context
|
27
|
+
@template_context ||= app.template_context_class.new(app, {}, {})
|
28
|
+
end
|
29
|
+
|
30
|
+
def process(source, process_options)
|
31
|
+
destination_path(source, process_options).tap do |dest_url|
|
32
|
+
unless app.sitemap.find_resource_by_path(dest_url)
|
33
|
+
image = Image.new(app, source.source_file, dest_url, process_options.merge(cache_dir: options[:cache_dir]))
|
34
|
+
manipulator.add image
|
35
|
+
app.sitemap.register_resource_list_manipulator(:images, manipulator, 40) unless app.build?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def image(url, process_options)
|
41
|
+
source = app.sitemap.find_resource_by_path(absolute_image_path(url))
|
42
|
+
return url if source.nil?
|
43
|
+
|
44
|
+
process_options[:image_optim] = options[:image_optim]
|
45
|
+
process_options[:optimize] = options[:optimize] unless process_options.key?(:optimize)
|
46
|
+
|
47
|
+
if process_options[:resize] || process_options[:optimize]
|
48
|
+
url = process(source, process_options)
|
49
|
+
else
|
50
|
+
manipulator.preserve_original source
|
51
|
+
app.sitemap.register_resource_list_manipulator(:images, manipulator, 40) unless app.build?
|
52
|
+
end
|
53
|
+
url
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(app, options_hash = {}, &block)
|
57
|
+
super
|
58
|
+
@manipulator = Manipulator.new(@app, options[:ignore_original])
|
59
|
+
end
|
60
|
+
|
61
|
+
def before_build(builder)
|
62
|
+
# trigger our image_tag helper
|
63
|
+
rack = builder.instance_variable_get(:@rack)
|
64
|
+
|
65
|
+
builder.app.logger.info "== Images: Looking for images to process"
|
66
|
+
builder.app.sitemap.resources.each do |resource|
|
67
|
+
rack.get(CGI.escape(resource.request_path)) unless resource.binary?
|
68
|
+
end
|
69
|
+
builder.app.sitemap.register_resource_list_manipulator(:images, manipulator, 40)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
attr_reader :manipulator
|
75
|
+
|
76
|
+
def destination_path(source, options)
|
77
|
+
destination = source.normalized_path.sub(/#{source.ext}$/, '')
|
78
|
+
destination += '-' + template_context.escape_html(options[:resize]) if options[:resize]
|
79
|
+
destination += '-opt' if options[:optimize]
|
80
|
+
destination + source.ext
|
81
|
+
end
|
82
|
+
|
83
|
+
def absolute_image_path(url)
|
84
|
+
absolute_path = url.start_with?('/') || url.start_with?(app.config[:images_dir])
|
85
|
+
absolute_path ? url : app.config[:images_dir] + '/' + url
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|