Skip to content

Commit

Permalink
Merge pull request #59 from wadetandy/master
Browse files Browse the repository at this point in the history
Fix bug where assets could not be found by relative path
  • Loading branch information
ixti committed Oct 25, 2013
2 parents a9e859a + a783e7c commit b286c0b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/jekyll/assets_plugin/patches/context_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def jekyll_assets


def asset_path pathname, *args
jekyll_assets << resolve(pathname.to_s[/^[^#?]+/]).to_s
site.asset_path pathname, *args
asset = resolve(pathname.to_s[/^[^#?]+/]).to_s
jekyll_assets << asset
(site.asset_path asset, *args) + (pathname.to_s[/[#?].+/] || '')
rescue Sprockets::FileNotFound
raise Environment::AssetNotFound, pathname
end
Expand Down
12 changes: 12 additions & 0 deletions spec/fixtures/_assets/lib/relative.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* copy of vapor css framework to test relative asset inclusion*/

@font-face {
font-family: 'Vapor';
src: url(font_path('../fonts/vapor.eot'));
src: url(font_path('../fonts/vapor.eot?#iefix')) format("embedded-opentype"),
url(font_path('../fonts/vapor.woff')) format("woff"),
url(font_path('../fonts/vapor.ttf')) format("truetype"),
url(font_path('../fonts/vapor.svg#iefix')) format("svg");
font-weight: normal;
font-style: normal;
}
7 changes: 7 additions & 0 deletions spec/lib/jekyll/assets_plugin/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module Jekyll::AssetsPlugin
css.should =~ %r{fonts/vapor-[a-f0-9]{32}\.eot\?#iefix}
css.should =~ %r{fonts/vapor-[a-f0-9]{32}\.svg#iefix}
end

it "should properly handle relative paths" do
css = @site.assets["lib/relative.css"].to_s
css.should =~ %r{/assets/fonts/vapor-[a-f0-9]{32}\.eot\?#iefix}
css.should =~ %r{/assets/fonts/vapor-[a-f0-9]{32}\.svg#iefix}
puts css
end
end
end
end

0 comments on commit b286c0b

Please sign in to comment.