mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Merge pull request #1381 from minusfive/asset-hash-json
Parse asset-hashes on JSON files
This commit is contained in:
commit
144660660f
4 changed files with 22 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
Feature: Assets get a file hash appended to their and references to them are updated
|
||||
Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
|
||||
Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
|
||||
Given a successfully built app at "asset-hash-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
|
@ -14,6 +14,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
| index.html |
|
||||
| subdir/index.html |
|
||||
| other/index.html |
|
||||
| api.json |
|
||||
| subdir/api.json |
|
||||
And the following files should not exist:
|
||||
| images/100px.png |
|
||||
| images/100px.jpg |
|
||||
|
@ -33,6 +35,12 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
And the file "other/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
||||
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
||||
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
||||
And the file "api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||
And the file "api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||
And the file "api.json" should contain 'images/100px-1242c368.png'
|
||||
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||
And the file "subdir/api.json" should contain 'images/100px-1242c368.png'
|
||||
|
||||
Scenario: Hashed assets work in preview server
|
||||
Given the Server is running at "asset-hash-app"
|
||||
|
@ -53,6 +61,14 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
||||
When I go to "/stylesheets/site-50eaa978.css"
|
||||
Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
|
||||
When I go to "/api.json"
|
||||
Then I should see 'images/100px-5fd6fb90.gif'
|
||||
And I should see 'images/100px-5fd6fb90.jpg'
|
||||
And I should see 'images/100px-1242c368.png'
|
||||
When I go to "/subdir/api.json"
|
||||
Then I should see 'images/100px-5fd6fb90.gif'
|
||||
And I should see 'images/100px-5fd6fb90.jpg'
|
||||
And I should see 'images/100px-1242c368.png'
|
||||
|
||||
Scenario: Enabling an asset host still produces hashed files and references
|
||||
Given the Server is running at "asset-hash-host-app"
|
||||
|
@ -127,6 +143,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|||
| index.html |
|
||||
| subdir/index.html |
|
||||
| other/index.html |
|
||||
| api.json |
|
||||
| subdir/api.json |
|
||||
And the following files should not exist:
|
||||
| images/100px-1242c368.png |
|
||||
| images/100px-5fd6fb90.jpg |
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
|
@ -0,0 +1 @@
|
|||
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
|
@ -75,7 +75,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
|
||||
path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
|
||||
|
||||
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
|
||||
if path =~ /(^\/$)|(\.(htm|html|php|css|js|json)$)/
|
||||
body = ::Middleman::Util.extract_response_text(response)
|
||||
if body
|
||||
status, headers, response = Rack::Response.new(rewrite_paths(body, path), status, headers).finish
|
||||
|
|
Loading…
Reference in a new issue