middleman-automatic-clowncar 4.0.2 → 4.0.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d761b96d5bf6a8657cc99f709bd1724df3c7bf675dba371003df2ef0d77257de
|
4
|
+
data.tar.gz: 5a7e76e82aa1d3afd78632ea06945f92fc3564f269d1e8a899e8853698050f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14bcffaac1275723bdef8b4f7f6d430727b06723429768662c1d7c2c3745aa0c2ef2ef4857ad8819cfdcbb0f5b9d40a03e0acd22bd65d6be796784b86e696502
|
7
|
+
data.tar.gz: ea815b597181a54ec3ff929c486e3bfd3b98f55ee37c22590cd198e61bfc83638c45292c7842984985e543cfb345b5f565e1e62165d31b8068a2e06881c16aa9
|
@@ -175,6 +175,6 @@ Feature: Generating SVG clowncars during preview mode
|
|
175
175
|
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
176
176
|
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
177
177
|
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%20and%20(max-width:600px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
178
|
-
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(/photos/test-image/../test-image.jpg);%7D%7D"
|
178
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/../test-image.jpg);%7D%7D"
|
179
179
|
|
180
180
|
|
@@ -75,7 +75,6 @@ module Middleman
|
|
75
75
|
if uri.host
|
76
76
|
path
|
77
77
|
else
|
78
|
-
|
79
78
|
svg_path = File.join(File.dirname(name),File.basename(name,".*"), path)
|
80
79
|
|
81
80
|
if is_relative
|
@@ -158,8 +157,6 @@ module Middleman
|
|
158
157
|
|
159
158
|
|
160
159
|
def generate_svg(name, is_relative, options)
|
161
|
-
#puts "name for generate_svg = #{name}"
|
162
|
-
#puts "options for generate_svg = #{options}"
|
163
160
|
sizes, width, height = get_image_sizes(name, options)
|
164
161
|
|
165
162
|
fallback_host = false
|
@@ -168,8 +165,10 @@ module Middleman
|
|
168
165
|
if is_relative_url?(test_path)
|
169
166
|
if options.has_key?(:host)
|
170
167
|
fallback_host = options[:host]
|
171
|
-
elsif app.config[:asset_host]
|
168
|
+
elsif app.config[:asset_host] # this is for middleman 2 & 3, (and maybe early 4?)
|
172
169
|
fallback_host = app.config[:asset_host]
|
170
|
+
elsif app.extensions[:asset_host] # this is for middleman 4+
|
171
|
+
fallback_host = app.extensions[:asset_host].options.host
|
173
172
|
else
|
174
173
|
warn "WARNING: Inline clowncar images require absolute paths. Please set a :host value"
|
175
174
|
end
|
@@ -195,6 +194,22 @@ module Middleman
|
|
195
194
|
Extension.options_hash[:sizes]
|
196
195
|
end
|
197
196
|
|
197
|
+
def automatic_clowncar_escape(str)
|
198
|
+
alpha = "a-zA-Z"
|
199
|
+
alnum = "#{alpha}\\d"
|
200
|
+
unreserved = "\\-_.!~*'()#{alnum}"
|
201
|
+
reserved = ";/?:@&=+$,\\[\\]"
|
202
|
+
unsafe = Regexp.new("[^#{unreserved}#{reserved}]")
|
203
|
+
str.gsub(unsafe) do
|
204
|
+
us = $&
|
205
|
+
tmp = ''
|
206
|
+
us.each_byte do |uc|
|
207
|
+
tmp << sprintf('%%%02X', uc)
|
208
|
+
end
|
209
|
+
tmp
|
210
|
+
end.force_encoding(Encoding::US_ASCII)
|
211
|
+
end
|
212
|
+
|
198
213
|
def automatic_clowncar_tag(name, options={})
|
199
214
|
internal = ""
|
200
215
|
|
@@ -220,7 +235,7 @@ module Middleman
|
|
220
235
|
%Q{<object type="image/svg+xml" style="#{object_style}" data-aspect-ratio="#{width.to_f/height.to_f}" data="#{url}">#{internal}</object>}
|
221
236
|
else
|
222
237
|
data = extensions[:automatic_clowncar].generate_svg(name, true, options)
|
223
|
-
%Q{<object type="image/svg+xml" style="#{object_style}" data-aspect-ratio="#{width.to_f/height.to_f}" data="data:image/svg+xml,#{
|
238
|
+
%Q{<object type="image/svg+xml" style="#{object_style}" data-aspect-ratio="#{width.to_f/height.to_f}" data="data:image/svg+xml,#{automatic_clowncar_escape(data)}">#{internal}</object>}
|
224
239
|
end
|
225
240
|
end
|
226
241
|
|