Merge pull request #1405 from dennisreimann/asset_hash-srcset
Asset hashing for image references in srcset
This commit is contained in:
commit
ab567b1cbd
5 changed files with 8 additions and 2 deletions
|
@ -8,6 +8,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
| favicon.ico |
|
||||
| images/100px-1242c368.png |
|
||||
| images/100px-5fd6fb90.jpg |
|
||||
| images/200px-c11eb203.jpg |
|
||||
| images/300px-59adce76.jpg |
|
||||
| images/100px-5fd6fb90.gif |
|
||||
| javascripts/application-1d8d5276.js |
|
||||
| stylesheets/site-50eaa978.css |
|
||||
|
@ -29,6 +31,9 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
And the file "index.html" should contain 'href="stylesheets/site-50eaa978.css"'
|
||||
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
||||
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
||||
And the file "index.html" should contain 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
||||
And the file "index.html" should contain 'src="images/100px-5fd6fb90.gif"'
|
||||
And the file "index.html" should contain 'src="images/100px-1242c368.png"'
|
||||
And the file "subdir/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
||||
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
||||
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
||||
|
@ -49,6 +54,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
And I should see 'href="stylesheets/site-50eaa978.css"'
|
||||
And I should see 'src="javascripts/application-1d8d5276.js"'
|
||||
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
||||
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
||||
When I go to "/subdir/"
|
||||
Then I should see 'href="../stylesheets/site-50eaa978.css"'
|
||||
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
||||
|
|
BIN
middleman-core/fixtures/asset-hash-app/source/images/200px.jpg
Normal file
BIN
middleman-core/fixtures/asset-hash-app/source/images/200px.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
middleman-core/fixtures/asset-hash-app/source/images/300px.jpg
Normal file
BIN
middleman-core/fixtures/asset-hash-app/source/images/300px.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -3,7 +3,7 @@
|
|||
<% end %>
|
||||
|
||||
<h2>Image url:</h2>
|
||||
<img src="<%= image_path('100px.jpg') %>">
|
||||
<img src="<%= image_path('100px.jpg') %>" srcset="<%= image_path('100px.jpg') %> 1x, <%= image_path('200px.jpg') %> 2x, <%= image_path('300px.jpg') %> 3x">
|
||||
|
||||
<h2>Ignored path:</h2>
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
|
|
|
@ -91,7 +91,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
dirpath = Pathname.new(File.dirname(path))
|
||||
|
||||
# TODO: This regex will change some paths in plan HTML (not in a tag) - is that OK?
|
||||
body.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{@exts_regex_text}))/) do |match|
|
||||
body.gsub(/([=\'\"\(,]\s*)([^\s\'\"\)]+(#{@exts_regex_text}))/) do |match|
|
||||
opening_character = $1
|
||||
asset_path = $2
|
||||
|
||||
|
|
Loading…
Reference in a new issue