lib/middleman/features/relative_assets.rb in middleman-0.9.17 vs lib/middleman/features/relative_assets.rb in middleman-0.9.18

- old
+ new

@@ -1,31 +1,25 @@ -class Middleman::Base - if compass? - configure do - ::Compass.configuration do |config| - config.relative_assets = true - end - end - end - - helpers do - alias_method :pre_relative_asset_url, :asset_url - def asset_url(path, prefix="") - path = pre_relative_asset_url(path, prefix) - if path.include?("://") - path +::Compass.configuration do |config| + config.relative_assets = true +end + +class << Middleman::Base + alias_method :pre_relative_asset_url, :asset_url + def asset_url(path, prefix="", request=nil) + path = pre_relative_asset_url(path, prefix, request) + if path.include?("://") + path + else + path = path[1,path.length-1] if path[0,1] == '/' + request_path = request.path_info.dup + request_path << self.class.index_file if path.match(%r{/$}) + request_path.gsub!(%r{^/}, '') + parts = request_path.split('/') + + if parts.length > 1 + "../" * (parts.length - 1) + path else - path = path[1,path.length-1] if path[0,1] == '/' - request_path = request.path_info.dup - request_path << options.index_file if path.match(%r{/$}) - request_path.gsub!(%r{^/}, '') - parts = request_path.split('/') - - if parts.length > 1 - "../" * (parts.length - 1) + path - else - path - end + path end end end end \ No newline at end of file