2010-09-06 21:48:25 -04:00
|
|
|
module Middleman::Features::AssetHost
|
|
|
|
class << self
|
|
|
|
def registered(app)
|
|
|
|
app.after_feature_init do
|
|
|
|
if Middleman::Server.asset_host.is_a?(Proc)
|
|
|
|
::Compass.configuration.asset_host(&Middleman::Server.asset_host)
|
|
|
|
end
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
2010-02-02 20:03:43 -05:00
|
|
|
|
2010-09-06 21:48:25 -04:00
|
|
|
Middleman::Assets.register :asset_host do |path, prefix, request|
|
|
|
|
original_output = Middleman::Assets.before(:asset_host, path, prefix, request)
|
|
|
|
|
|
|
|
valid_extensions = %w(.png .gif .jpg .jpeg .js .css)
|
2010-09-04 23:26:48 -04:00
|
|
|
|
2010-09-06 21:48:25 -04:00
|
|
|
asset_prefix = Middleman::Server.asset_host.call(original_output)
|
2010-09-04 23:26:48 -04:00
|
|
|
|
2010-09-06 21:48:25 -04:00
|
|
|
File.join(asset_prefix, original_output)
|
|
|
|
end
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
2010-09-06 21:48:25 -04:00
|
|
|
alias :included :registered
|
2010-02-02 20:03:43 -05:00
|
|
|
end
|
2010-09-06 21:48:25 -04:00
|
|
|
end
|