Add proc as a means of defining a rewriter ignore. Closes #1289
This commit is contained in:
parent
c53773a4a1
commit
3879be0f23
2 changed files with 24 additions and 4 deletions
|
@ -109,7 +109,12 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
Given a fixture app "asset-hash-app"
|
Given a fixture app "asset-hash-app"
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
"""
|
"""
|
||||||
activate :asset_hash, ignore: [%r(javascripts/*), 'images/*']
|
is_stylesheet = proc { |path| path.start_with? 'stylesheets' }
|
||||||
|
activate :asset_hash, ignore: [
|
||||||
|
%r(javascripts/*),
|
||||||
|
'images/*',
|
||||||
|
is_stylesheet
|
||||||
|
]
|
||||||
activate :relative_assets
|
activate :relative_assets
|
||||||
activate :directory_indexes
|
activate :directory_indexes
|
||||||
"""
|
"""
|
||||||
|
@ -123,7 +128,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| images/100px.jpg |
|
| images/100px.jpg |
|
||||||
| images/100px.gif |
|
| images/100px.gif |
|
||||||
| javascripts/application.js |
|
| javascripts/application.js |
|
||||||
| stylesheets/site-50eaa978.css |
|
| stylesheets/site.css |
|
||||||
| index.html |
|
| index.html |
|
||||||
| subdir/index.html |
|
| subdir/index.html |
|
||||||
| other/index.html |
|
| other/index.html |
|
||||||
|
@ -132,7 +137,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| images/100px-5fd6fb90.jpg |
|
| images/100px-5fd6fb90.jpg |
|
||||||
| images/100px-5fd6fb90.gif |
|
| images/100px-5fd6fb90.gif |
|
||||||
| javascripts/application-1d8d5276.js |
|
| javascripts/application-1d8d5276.js |
|
||||||
| stylesheets/site.css |
|
| stylesheets/site-50eaa978.css |
|
||||||
|
|
||||||
# @wip Currently broken, we should move all asset-host functionality out of Compass and into something more similar to asset_hash with Rack-based rewrites
|
# @wip Currently broken, we should move all asset-host functionality out of Compass and into something more similar to asset_hash with Rack-based rewrites
|
||||||
# Scenario: Enabling an asset host and referencing assets in CSS with URL fragments are rewritten correctly
|
# Scenario: Enabling an asset host and referencing assets in CSS with URL fragments are rewritten correctly
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Middleman
|
||||||
asset_path
|
asset_path
|
||||||
end
|
end
|
||||||
|
|
||||||
@ignore.none? { |r| full_asset_path.match(r) } && @proc.call(asset_path, dirpath)
|
@ignore.none? { |r| should_ignore?(r, full_asset_path) } && @proc.call(asset_path, dirpath)
|
||||||
end
|
end
|
||||||
|
|
||||||
status, headers, response = ::Rack::Response.new(
|
status, headers, response = ::Rack::Response.new(
|
||||||
|
@ -62,6 +62,21 @@ module Middleman
|
||||||
|
|
||||||
[status, headers, response]
|
[status, headers, response]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def should_ignore?(validator, value)
|
||||||
|
if validator.is_a? Regexp
|
||||||
|
# Treat as Regexp
|
||||||
|
value.match(validator)
|
||||||
|
elsif validator.respond_to? :call
|
||||||
|
# Treat as proc
|
||||||
|
validator.call(value)
|
||||||
|
elsif validator.is_a? String
|
||||||
|
# Treat as glob
|
||||||
|
File.fnmatch(value, validator)
|
||||||
|
else
|
||||||
|
# If some unknown thing, don't ignore
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue