From 8b84a4b0e56b3daf82238f57da2124c6dd192f29 Mon Sep 17 00:00:00 2001 From: Martin Rehfeld Date: Thu, 11 Sep 2008 12:08:48 +0200 Subject: [PATCH] possible fix for AssetTagHelper --- .../lib/action_view/helpers/asset_tag_helper.rb | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index a926599..8ada357 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -249,7 +249,7 @@ module ActionView joined_javascript_name = (cache == true ? "all" : cache) + ".js" joined_javascript_path = File.join(JAVASCRIPTS_DIR, joined_javascript_name) - write_asset_file_contents(joined_javascript_path, compute_javascript_paths(sources, recursive)) unless File.exists?(joined_javascript_path) + write_asset_file_contents(joined_javascript_path, compute_javascript_paths_for_local_filesystem(sources, recursive)) unless File.exists?(joined_javascript_path) javascript_src_tag(joined_javascript_name, options) else expand_javascript_sources(sources, recursive).collect { |source| javascript_src_tag(source, options) }.join("\n") @@ -389,7 +389,7 @@ module ActionView joined_stylesheet_name = (cache == true ? "all" : cache) + ".css" joined_stylesheet_path = File.join(STYLESHEETS_DIR, joined_stylesheet_name) - write_asset_file_contents(joined_stylesheet_path, compute_stylesheet_paths(sources, recursive)) unless File.exists?(joined_stylesheet_path) + write_asset_file_contents(joined_stylesheet_path, compute_stylesheet_paths_for_local_filesystem(sources, recursive)) unless File.exists?(joined_stylesheet_path) stylesheet_tag(joined_stylesheet_name, options) else expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join("\n") @@ -470,7 +470,7 @@ module ActionView # Prefix with /dir/ if lacking a leading +/+. Account for relative URL # roots. Rewrite the asset path for cache-busting asset ids. Include # asset host, if configured, with the correct request protocol. - def compute_public_path(source, dir, ext = nil, include_host = true) + def compute_public_path(source, dir, ext = nil, include_host = true, filesystem_path = false) has_request = @controller.respond_to?(:request) cache_key = @@ -493,7 +493,7 @@ module ActionView source else source = "/#{dir}/#{source}" unless source[0] == ?/ - if has_request + if has_request && !filesystem_path unless source =~ %r{^#{ActionController::Base.relative_url_root}/} source = "#{ActionController::Base.relative_url_root}#{source}" end @@ -575,10 +575,18 @@ module ActionView expand_javascript_sources(*args).collect { |source| compute_public_path(source, 'javascripts', 'js', false) } end + def compute_javascript_paths_for_local_filesystem(*args) + expand_javascript_sources(*args).collect { |source| compute_public_path(source, 'javascripts', 'js', false, true) } + end + def compute_stylesheet_paths(*args) expand_stylesheet_sources(*args).collect { |source| compute_public_path(source, 'stylesheets', 'css', false) } end + def compute_stylesheet_paths_for_local_filesystem(*args) + expand_stylesheet_sources(*args).collect { |source| compute_public_path(source, 'stylesheets', 'css', false, true) } + end + def expand_javascript_sources(sources, recursive = false) if sources.include?(:all) all_javascript_files = collect_asset_files(JAVASCRIPTS_DIR, ('**' if recursive), '*.js') -- 1.5.5.3