diff options
author | Chris Eppstein <chris@eppsteins.net> | 2011-06-27 13:48:36 -0700 |
---|---|---|
committer | Chris Eppstein <chris@eppsteins.net> | 2011-06-27 13:48:36 -0700 |
commit | 96137e8bd0a0094d26cc0cf6f86642487a60735f (patch) | |
tree | 377fc0a665c7c84c2c01f3d9cd0534dabc107d3a /actionpack/lib/action_view/helpers | |
parent | 266b80c7b28c7587ab1c75aae6e3288e2f6c1aba (diff) | |
download | rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.tar.gz rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.tar.bz2 rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.zip |
Add asset_url helper and refactor the asset paths so that asset hosts can be used during asset precompilation.
Conflicts:
actionpack/lib/action_view/asset_paths.rb
actionpack/lib/sprockets/helpers/rails_helper.rb
actionpack/test/template/sprockets_helper_test.rb
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb index e4662a2919..16d8f3f893 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb @@ -60,12 +60,16 @@ module ActionView private - def path_to_asset(source, include_host = true) - asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension, include_host) + def path_to_asset(source) + asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension) + end + + def path_to_asset_source(source) + asset_paths.compute_source_path(source, asset_name.to_s.pluralize, extension) end def compute_paths(*args) - expand_sources(*args).collect { |source| asset_paths.compute_public_path(source, asset_name.pluralize, extension, false) } + expand_sources(*args).collect { |source| path_to_asset_source(source) } end def expand_sources(sources, recursive) @@ -92,7 +96,7 @@ module ActionView def ensure_sources!(sources) sources.each do |source| - asset_file_path!(path_to_asset(source, false)) + asset_file_path!(path_to_asset_source(source)) end end @@ -123,19 +127,14 @@ module ActionView # Set mtime to the latest of the combined files to allow for # consistent ETag without a shared filesystem. - mt = asset_paths.map { |p| File.mtime(asset_file_path(p)) }.max + mt = asset_paths.map { |p| File.mtime(asset_file_path!(p)) }.max File.utime(mt, mt, joined_asset_path) end - def asset_file_path(path) - File.join(config.assets_dir, path.split('?').first) - end - - def asset_file_path!(path, error_if_file_is_uri = false) - if asset_paths.is_uri?(path) + def asset_file_path!(absolute_path, error_if_file_is_uri = false) + if asset_paths.is_uri?(absolute_path) raise(Errno::ENOENT, "Asset file #{path} is uri and cannot be merged into single file") if error_if_file_is_uri else - absolute_path = asset_file_path(path) raise(Errno::ENOENT, "Asset file not found at '#{absolute_path}'" ) unless File.exist?(absolute_path) return absolute_path end |