From dbf42e379becc5612a0efe3476a999a9d6d803f0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 6 Mar 2007 09:46:04 +0000 Subject: Prefer MIME constants to strings. Closes #7707. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6350 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/base.rb | 4 ++-- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 14 +++++++------- .../lib/action_view/helpers/java_script_macros_helper.rb | 12 ++++++------ actionpack/lib/action_view/helpers/javascript_helper.rb | 4 ++-- actionpack/lib/action_view/helpers/url_helper.rb | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 1b3cf5d95e..d66b43cd68 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -470,11 +470,11 @@ module ActionView #:nodoc: if template_requires_setup?(extension) body = case extension.to_sym when :rxml, :builder - "controller.response.content_type ||= 'application/xml'\n" + + "controller.response.content_type ||= Mime::XML\n" + "xml = Builder::XmlMarkup.new(:indent => 2)\n" + template when :rjs - "controller.response.content_type ||= 'text/javascript'\n" + + "controller.response.content_type ||= Mime::JS\n" + "update_page do |page|\n#{template}\nend" end else diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 93e695ddbb..8b9e4094ce 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -149,19 +149,19 @@ module ActionView if !File.exists?(joined_javascript_path) File.open(joined_javascript_path, "w+") do |cache| javascript_paths = expand_javascript_sources(sources).collect do |source| - compute_public_path(source, 'javascripts', 'js', false) + compute_public_path(source, 'javascripts', 'js', false) end cache.write(join_asset_file_contents(javascript_paths)) end end - content_tag("script", "", { - "type" => "text/javascript", "src" => javascript_path(joined_javascript_name) + content_tag("script", "", { + "type" => Mime::JS, "src" => javascript_path(joined_javascript_name) }.merge(options)) else expand_javascript_sources(sources).collect do |source| - content_tag("script", "", { "type" => "text/javascript", "src" => javascript_path(source) }.merge(options)) + content_tag("script", "", { "type" => Mime::JS, "src" => javascript_path(source) }.merge(options)) end.join("\n") end end @@ -252,15 +252,15 @@ module ActionView end tag("link", { - "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", + "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => stylesheet_path(joined_stylesheet_name) }.merge(options)) else options.delete("cache") expand_stylesheet_sources(sources).collect do |source| - tag("link", { - "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => stylesheet_path(source) + tag("link", { + "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => stylesheet_path(source) }.merge(options)) end.join("\n") end diff --git a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb index 6304a1a8b2..0d9e87fba0 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -198,10 +198,10 @@ module ActionView content_tag("div", "", :id => "#{object}_#{method}_auto_complete", :class => "auto_complete") + auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options)) end - + private def auto_complete_stylesheet - content_tag('style', <<-EOT, :type => 'text/css') + content_tag('style', <<-EOT, :type => Mime::CSS) div.auto_complete { width: 350px; background: #fff; @@ -217,17 +217,17 @@ module ActionView margin:0; padding:3px; } - div.auto_complete ul li.selected { - background-color: #ffb; + div.auto_complete ul li.selected { + background-color: #ffb; } - div.auto_complete ul strong.highlight { + div.auto_complete ul strong.highlight { color: #800; margin:0; padding:0; } EOT end - + end end end diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index ad74a85584..4dd7854367 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -132,7 +132,7 @@ module ActionView # public/javascripts/ directory, and use +javascript_include_tag+ to # create remote def javascript_tag(content, html_options = {}) - content_tag("script", javascript_cdata_section(content), html_options.merge(:type => "text/javascript")) + content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) end def javascript_cdata_section(content) #:nodoc: diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 688790094b..dc9154dea5 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -295,7 +295,7 @@ module ActionView for i in 0...tmp.length string << sprintf("%%%x",tmp[i]) end - "" + "" elsif encode == "hex" email_address_encoded = '' email_address_obfuscated.each_byte do |c| -- cgit v1.2.3