This commit is contained in:
Thomas Reynolds 2015-12-15 09:58:22 -08:00
parent 6af784d5d5
commit 9e5b137ed8
4 changed files with 24 additions and 2 deletions

View file

@ -64,7 +64,7 @@ module Middleman::Cli
if builder.run! if builder.run!
clean_directories! if options['clean'] clean_directories! if options['clean']
shell.say "Project built successfully." shell.say 'Project built successfully.'
else else
msg = 'There were errors during this build' msg = 'There were errors during this build'
unless options['verbose'] unless options['verbose']

View file

@ -41,6 +41,11 @@ Feature: Relative Assets
And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff' And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf' And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg' And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg'
When I go to "/stylesheets/fonts2.css"
Then I should see 'url(../fonts/roboto/roboto-regular-webfont.eot'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg'
Scenario: Building css with the feature enabled Scenario: Building css with the feature enabled
Given a fixture app "relative-assets-app" Given a fixture app "relative-assets-app"

View file

@ -0,0 +1,10 @@
@font-face {
font-family: 'Roboto';
src: url(/fonts/roboto/roboto-regular-webfont.eot);
src: url(/fonts/roboto/roboto-regular-webfont.eot?#iefix) format('embedded-opentype'),
url(/fonts/roboto/roboto-regular-webfont.woff) format('woff'),
url(/fonts/roboto/roboto-regular-webfont.ttf) format('truetype'),
url(/fonts/roboto/roboto-regular-webfont.svg#robotoregular) format('svg');
font-weight: normal;
font-style: normal;
}

View file

@ -332,12 +332,19 @@ module Middleman
Contract String, String, ArrayOf[String], Proc => String Contract String, String, ArrayOf[String], Proc => String
def rewrite_paths(body, _path, exts, &_block) def rewrite_paths(body, _path, exts, &_block)
matcher = /([=\'\"\(,] *)([^\s\'\"\)>]+(#{Regexp.union(exts)}))/ matcher = /([=\'\"\(,]\s*)([^\s\'\"\)>]+(#{Regexp.union(exts)}))/
url_fn_prefix = 'url('
body.dup.gsub(matcher) do |match| body.dup.gsub(matcher) do |match|
opening_character = $1 opening_character = $1
asset_path = $2 asset_path = $2
if asset_path.start_with?(url_fn_prefix)
opening_character << url_fn_prefix
asset_path = asset_path[url_fn_prefix.length..-1]
end
begin begin
uri = ::Addressable::URI.parse(asset_path) uri = ::Addressable::URI.parse(asset_path)