1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/features/relative_assets.rb

30 lines
697 B
Ruby
Raw Normal View History

2009-09-29 17:30:01 -04:00
class Middleman::Base
if compass?
configure do
::Compass.configuration do |config|
config.relative_assets = true
end
end
end
helpers do
2009-10-01 14:26:46 -04:00
alias_method :pre_relative_asset_url, :asset_url
def asset_url(path, prefix="")
path = pre_relative_asset_url(path, prefix)
2009-09-29 17:30:01 -04:00
if path.include?("://")
2009-09-28 22:43:08 -04:00
path
2009-09-29 17:30:01 -04:00
else
request_path = request.path_info.dup
2009-10-01 14:26:46 -04:00
request_path << self.index_file if path.match(%r{/$})
2009-09-29 17:30:01 -04:00
request_path.gsub!(%r{^/}, '')
parts = request_path.split('/')
if parts.length > 1
"../" * (parts.length - 1) + path
else
path
end
2009-09-28 22:43:08 -04:00
end
end
end
end