fix basic asset host
This commit is contained in:
parent
a5e0dd49a9
commit
186651c5b5
|
@ -1,22 +1,32 @@
|
|||
module Middleman::Features::AssetHost
|
||||
class << self
|
||||
def registered(app)
|
||||
app.set :asset_host, nil
|
||||
|
||||
app.compass_config do |config|
|
||||
if app.asset_host.is_a?(Proc)
|
||||
config.asset_host(&app.asset_host)
|
||||
if self.asset_host.is_a?(Proc)
|
||||
config.asset_host(&self.asset_host)
|
||||
end
|
||||
end
|
||||
|
||||
app.register_asset_handler :asset_host do |path, prefix|
|
||||
original_output = self.before_asset_handler(:asset_host, path, prefix)
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def asset_url(path, prefix="")
|
||||
original_output = super
|
||||
|
||||
valid_extensions = %w(.png .gif .jpg .jpeg .js .css)
|
||||
|
||||
asset_prefix = self.asset_host.call(original_output)
|
||||
asset_prefix = if self.asset_host.is_a?(Proc)
|
||||
self.asset_host.call(original_output)
|
||||
elsif self.asset_host.is_a?(String)
|
||||
self.asset_host
|
||||
end
|
||||
|
||||
File.join(asset_prefix, original_output)
|
||||
end
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue