0
@@ -151,7 +151,7 @@ module ActionView
0
# javascript_path "http://www.railsapplication.com/js/xmlhr" # => http://www.railsapplication.com/js/xmlhr.js
0
# javascript_path "http://www.railsapplication.com/js/xmlhr.js" # => http://www.railsapplication.com/js/xmlhr.js
0
def javascript_path(source)
0
- JavaScriptTag.
create(self, @controller, source).public_path
0
+ JavaScriptTag.
new(self, @controller, source).public_path
0
alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route
0
@@ -314,7 +314,7 @@ module ActionView
0
# stylesheet_path "http://www.railsapplication.com/css/style" # => http://www.railsapplication.com/css/style.css
0
# stylesheet_path "http://www.railsapplication.com/css/style.js" # => http://www.railsapplication.com/css/style.css
0
def stylesheet_path(source)
0
- StylesheetTag.
create(self, @controller, source).public_path
0
+ StylesheetTag.
new(self, @controller, source).public_path
0
alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route
0
@@ -411,7 +411,7 @@ module ActionView
0
# image_path("/icons/edit.png") # => /icons/edit.png
0
# image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png
0
- ImageTag.
create(self, @controller, source).public_path
0
+ ImageTag.
new(self, @controller, source).public_path
0
alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
0
@@ -527,20 +527,6 @@ module ActionView
0
- def self.create(template, controller, source, include_host = true)
0
- CacheGuard.synchronize do
0
- key = if controller.respond_to?(:request)
0
- [self, controller.request.protocol,
0
- ActionController::Base.asset_host,
0
- ActionController::Base.relative_url_root,
0
- [self, ActionController::Base.asset_host, source, include_host]
0
- Cache[key] ||= new(template, controller, source, include_host).freeze
0
ProtocolRegexp = %r{^[-a-z]+://}.freeze
0
def initialize(template, controller, source, include_host = true)
0
@@ -551,8 +537,16 @@ module ActionView
0
@controller = controller
0
@include_host = include_host
0
+ @cache_key = if controller.respond_to?(:request)
0
+ [controller.request.protocol,
0
+ ActionController::Base.asset_host,
0
+ ActionController::Base.relative_url_root,
0
+ [ActionController::Base.asset_host, source, include_host]
0
compute_public_path(@source)
0
@@ -585,20 +579,32 @@ module ActionView
0
# roots. Rewrite the asset path for cache-busting asset ids. Include
0
# asset host, if configured, with the correct request protocol.
0
def compute_public_path(source)
0
- source += ".#{extension}" if missing_extension?(source)
0
- unless source =~ ProtocolRegexp
0
- source = "/#{directory}/#{source}" unless source[0] == ?/
0
- source = rewrite_asset_path(source)
0
- source = prepend_relative_url_root(source)
0
+ if source =~ ProtocolRegexp
0
+ source += ".#{extension}" if missing_extension?(source)
0
+ source = prepend_asset_host(source)
0
+ CacheGuard.synchronize do
0
+ Cache[@cache_key] ||= begin
0
+ source += ".#{extension}" if missing_extension?(source) || file_exists_with_extension?(source)
0
+ source = "/#{directory}/#{source}" unless source[0] == ?/
0
+ source = rewrite_asset_path(source)
0
+ source = prepend_relative_url_root(source)
0
+ source = prepend_asset_host(source)
0
- source = prepend_asset_host(source)
0
def missing_extension?(source)
0
- extension &&
(File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, directory, "#{source}.#{extension}")))0
+ extension &&
File.extname(source).blank?0
+ def file_exists_with_extension?(source)
0
+ extension && File.exist?(File.join(ASSETS_DIR, directory, "#{source}.#{extension}"))
0
def prepend_relative_url_root(source)
0
relative_url_root = ActionController::Base.relative_url_root
0
if request? && @include_host && source !~ %r{^#{relative_url_root}/}
0
@@ -735,7 +741,7 @@ module ActionView
0
- expand_sources.collect { |source| tag_class.
create(@template, @controller, source, false) }
0
+ expand_sources.collect { |source| tag_class.
new(@template, @controller, source, false) }