diff options
Diffstat (limited to 'actionpack/lib/sprockets')
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 29 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 32 |
2 files changed, 35 insertions, 26 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index acf2f256c2..7594ee4296 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -17,9 +17,32 @@ namespace :assets do Rails.application.config.action_controller.perform_caching = true config = Rails.application.config - assets = config.assets.precompile.dup - assets << {:to => File.join(Rails.public_path, config.assets.prefix)} - Rails.application.assets.precompile(*assets) + env = Rails.application.assets + target = Rails.root.join("public#{config.assets.prefix}") + + if env.respond_to?(:each_logical_path) + config.assets.precompile.each do |path| + env.each_logical_path do |logical_path| + if path.is_a?(Regexp) + next unless path.match(logical_path) + else + next unless File.fnmatch(path.to_s, logical_path) + end + + if asset = env.find_asset(logical_path) + filename = target.join(asset.digest_path) + mkdir_p filename.dirname + asset.write_to(filename) + asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/ + end + end + end + else + # TODO: Remove this once we're depending on sprockets beta 15 + assets = config.assets.precompile.dup + assets << {:to => target} + env.precompile(*assets) + end end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 7200ab1ddd..53cc5ec019 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -26,15 +26,10 @@ module Sprockets sources.collect do |source| if debug && asset = asset_paths.asset_for(source, 'js') asset.to_a.map { |dep| - javascript_include_tag(dep, :debug => false, :body => true) - }.join("\n").html_safe + javascript_include_tag(dep, options.stringify_keys.merge!({ :debug => false, :body => true })) + } else - tag_options = { - 'type' => "text/javascript", - 'src' => asset_path(source, 'js', body) - }.merge(options.stringify_keys) - - content_tag 'script', "", tag_options + super(source.to_s, { 'src' => asset_path(source, 'js', body) }.merge!(options.stringify_keys)) end end.join("\n").html_safe end @@ -47,17 +42,10 @@ module Sprockets sources.collect do |source| if debug && asset = asset_paths.asset_for(source, 'css') asset.to_a.map { |dep| - stylesheet_link_tag(dep, :debug => false, :body => true) - }.join("\n").html_safe + stylesheet_link_tag(dep, options.stringify_keys.merge!({ :debug => false, :body => true })) + } else - tag_options = { - 'rel' => "stylesheet", - 'type' => "text/css", - 'media' => "screen", - 'href' => asset_path(source, 'css', body, :request) - }.merge(options.stringify_keys) - - tag 'link', tag_options + super(source.to_s, { 'href' => asset_path(source, 'css', body, :request) }.merge!(options.stringify_keys)) end end.join("\n").html_safe end @@ -70,12 +58,10 @@ module Sprockets private def debug_assets? - begin + Rails.application.config.assets.allow_debugging && + (Rails.application.config.assets.debug || params[:debug_assets] == '1' || - params[:debug_assets] == 'true' - rescue NoMethodError - false - end || Rails.application.config.assets.debug + params[:debug_assets] == 'true') end # Override to specify an alternative prefix for asset path generation. |