aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-24 08:15:56 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-24 08:15:56 +0000
commit871b87a3238293082aae43870d2a97c61dc6ab21 (patch)
tree9dfa5168165420b482a39c57135174fc167396eb
parent4b33306c704d6429e42e317802c92bc57f0de61c (diff)
downloadrails-871b87a3238293082aae43870d2a97c61dc6ab21.tar.gz
rails-871b87a3238293082aae43870d2a97c61dc6ab21.tar.bz2
rails-871b87a3238293082aae43870d2a97c61dc6ab21.zip
Cache file existence checks and the list of all stylesheet sources. Manually escape tag attributes.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7609 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 4742b54eb9..060fb5a2ce 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -288,7 +288,8 @@ module ActionView
joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
joined_stylesheet_path = File.join(STYLESHEETS_DIR, joined_stylesheet_name)
- if !File.exists?(joined_stylesheet_path)
+ @@file_exist_cache ||= {}
+ if !(@@file_exist_cache[joined_stylesheet_name] ||= File.exist?(joined_stylesheet_path))
File.open(joined_stylesheet_path, "w+") do |cache|
stylesheet_paths = expand_stylesheet_sources(sources).collect do |source|
compute_public_path(source, 'stylesheets', 'css', false)
@@ -296,19 +297,21 @@ module ActionView
cache.write(join_asset_file_contents(stylesheet_paths))
end
+
+ @@file_exist_cache[joined_stylesheet_name] = true
end
tag("link", {
"rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen",
- "href" => stylesheet_path(joined_stylesheet_name)
- }.merge(options))
+ "href" => html_escape(stylesheet_path(joined_stylesheet_name))
+ }.merge(options), false, true)
else
options.delete("cache")
expand_stylesheet_sources(sources).collect do |source|
tag("link", {
- "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => stylesheet_path(source)
- }.merge(options))
+ "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => html_escape(stylesheet_path(source))
+ }.merge(options), false, true)
end.join("\n")
end
end
@@ -449,14 +452,14 @@ module ActionView
def expand_stylesheet_sources(sources)
if sources.first == :all
- sources = Dir[File.join(STYLESHEETS_DIR, '*.css')].collect { |file| File.basename(file).split(".", 1).first }.sort
+ @@all_stylesheet_sources ||= Dir[File.join(STYLESHEETS_DIR, '*.css')].collect { |file| File.basename(file).split(".", 1).first }.sort
else
sources
end
end
def join_asset_file_contents(paths)
- paths.collect { |path| File.read(File.join(ASSETS_DIR, path.split("?").first)) }.join("\n\n")
+ paths.collect { |path| File.read(File.join(ASSETS_DIR, path.split("?").first)) }.join("\n\n")
end
end
end