Changeset 6350
- Timestamp:
- 03/06/07 09:46:04 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/deprecated_request_methods.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/mime_type.rb (modified) (3 diffs)
- trunk/actionpack/lib/action_controller/request.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/response.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/test_process.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/base.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/asset_tag_helper.rb (modified) (4 diffs)
- trunk/actionpack/lib/action_view/helpers/java_script_macros_helper.rb (modified) (3 diffs)
- trunk/actionpack/lib/action_view/helpers/javascript_helper.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/helpers/url_helper.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6343 r6350 1 1 *SVN* 2 3 * Prefer MIME constants to strings. #7707 [Dan Kubb] 2 4 3 5 * Allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan] trunk/actionpack/lib/action_controller/deprecated_request_methods.rb
r3847 r6350 7 7 # X-Post-Data-Format HTTP header if present. 8 8 def post_format 9 case content_type .to_s10 when 'application/xml'9 case content_type 10 when Mime::XML 11 11 :xml 12 when 'application/x-yaml'12 when Mime::YAML 13 13 :yaml 14 14 else trunk/actionpack/lib/action_controller/mime_type.rb
r6152 r6350 25 25 @order = order 26 26 @name = name.strip 27 q ||= 0.0 if @name == "*/*" # default "*/*"to end of list27 q ||= 0.0 if @name == Mime::ALL # default wilcard match to end of list 28 28 @q = ((q || 1.0).to_f * 100).to_i 29 29 end … … 71 71 # Take care of the broken text/xml entry by renaming or deleting it 72 72 text_xml = list.index("text/xml") 73 app_xml = list.index( "application/xml")73 app_xml = list.index(Mime::XML.to_s) 74 74 75 75 if text_xml && app_xml … … 85 85 # delete text_xml from the list 86 86 list.delete_at(text_xml) 87 87 88 88 elsif text_xml 89 list[text_xml].name = "application/xml"89 list[text_xml].name = Mime::XML.to_s 90 90 end 91 91 trunk/actionpack/lib/action_controller/request.rb
r6340 r6350 61 61 # Receive header sans any charset information. 62 62 content_type = @env['CONTENT_TYPE'].to_s.sub(/\s*\;.*$/, '').strip.downcase 63 63 64 64 if x_post_format = @env['HTTP_X_POST_DATA_FORMAT'] 65 65 case x_post_format.to_s.downcase 66 66 when 'yaml' 67 content_type = 'application/x-yaml'67 content_type = Mime::YAML.to_s 68 68 when 'xml' 69 content_type = 'application/xml'69 content_type = Mime::XML.to_s 70 70 end 71 71 end 72 72 73 73 Mime::Type.lookup(content_type) 74 74 end trunk/actionpack/lib/action_controller/response.rb
r6169 r6350 21 21 22 22 def charset=(encoding) 23 self.headers["Content-Type"] = "#{content_type || "text/html"}; charset=#{encoding}"23 self.headers["Content-Type"] = "#{content_type || Mime::HTML}; charset=#{encoding}" 24 24 end 25 25 trunk/actionpack/lib/action_controller/test_process.rb
r6145 r6350 326 326 # The filename, *not* including the path, of the "uploaded" file 327 327 attr_reader :original_filename 328 328 329 329 # The content type of the "uploaded" file 330 330 attr_reader :content_type 331 332 def initialize(path, content_type = 'text/plain')331 332 def initialize(path, content_type = Mime::TEXT) 333 333 raise "#{path} file does not exist" unless File.exist?(path) 334 334 @content_type = content_type … … 337 337 FileUtils.copy_file(path, @tempfile.path) 338 338 end 339 339 340 340 def path #:nodoc: 341 341 @tempfile.path 342 342 end 343 343 344 344 alias local_path path 345 345 346 346 def method_missing(method_name, *args, &block) #:nodoc: 347 347 @tempfile.send(method_name, *args, &block) 348 348 end 349 349 end 350 350 351 351 module TestProcess 352 352 def self.included(base) trunk/actionpack/lib/action_view/base.rb
r6178 r6350 471 471 body = case extension.to_sym 472 472 when :rxml, :builder 473 "controller.response.content_type ||= 'application/xml'\n" +473 "controller.response.content_type ||= Mime::XML\n" + 474 474 "xml = Builder::XmlMarkup.new(:indent => 2)\n" + 475 475 template 476 476 when :rjs 477 "controller.response.content_type ||= 'text/javascript'\n" +477 "controller.response.content_type ||= Mime::JS\n" + 478 478 "update_page do |page|\n#{template}\nend" 479 479 end trunk/actionpack/lib/action_view/helpers/asset_tag_helper.rb
r6308 r6350 150 150 File.open(joined_javascript_path, "w+") do |cache| 151 151 javascript_paths = expand_javascript_sources(sources).collect do |source| 152 compute_public_path(source, 'javascripts', 'js', false) 152 compute_public_path(source, 'javascripts', 'js', false) 153 153 end 154 154 … … 157 157 end 158 158 159 content_tag("script", "", { 160 "type" => "text/javascript", "src" => javascript_path(joined_javascript_name)159 content_tag("script", "", { 160 "type" => Mime::JS, "src" => javascript_path(joined_javascript_name) 161 161 }.merge(options)) 162 162 else 163 163 expand_javascript_sources(sources).collect do |source| 164 content_tag("script", "", { "type" => "text/javascript", "src" => javascript_path(source) }.merge(options))164 content_tag("script", "", { "type" => Mime::JS, "src" => javascript_path(source) }.merge(options)) 165 165 end.join("\n") 166 166 end … … 253 253 254 254 tag("link", { 255 "rel" => "Stylesheet", "type" => "text/css", "media" => "screen",255 "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", 256 256 "href" => stylesheet_path(joined_stylesheet_name) 257 257 }.merge(options)) … … 260 260 261 261 expand_stylesheet_sources(sources).collect do |source| 262 tag("link", { 263 "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => stylesheet_path(source)262 tag("link", { 263 "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => stylesheet_path(source) 264 264 }.merge(options)) 265 265 end.join("\n") trunk/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
r6057 r6350 199 199 auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options)) 200 200 end 201 201 202 202 private 203 203 def auto_complete_stylesheet 204 content_tag('style', <<-EOT, :type => 'text/css')204 content_tag('style', <<-EOT, :type => Mime::CSS) 205 205 div.auto_complete { 206 206 width: 350px; … … 218 218 padding:3px; 219 219 } 220 div.auto_complete ul li.selected { 221 background-color: #ffb; 222 } 223 div.auto_complete ul strong.highlight { 220 div.auto_complete ul li.selected { 221 background-color: #ffb; 222 } 223 div.auto_complete ul strong.highlight { 224 224 color: #800; 225 225 margin:0; … … 228 228 EOT 229 229 end 230 230 231 231 end 232 232 end trunk/actionpack/lib/action_view/helpers/javascript_helper.rb
r6057 r6350 133 133 # create remote <script> links. 134 134 def define_javascript_functions 135 javascript = '<script type="text/javascript">'135 javascript = "<script type=\"#{Mime::JS}\">" 136 136 137 137 # load prototype.js and its extensions first … … 167 167 # javascript_tag "alert('All is good')", :defer => 'true' # => <script defer="true" type="text/javascript">alert('All is good')</script> 168 168 def javascript_tag(content, html_options = {}) 169 content_tag("script", javascript_cdata_section(content), html_options.merge(:type => "text/javascript"))169 content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) 170 170 end 171 171 trunk/actionpack/lib/action_view/helpers/url_helper.rb
r6070 r6350 296 296 string << sprintf("%%%x",tmp[i]) 297 297 end 298 "<script type=\" text/javascript\">eval(unescape('#{string}'))</script>"298 "<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>" 299 299 elsif encode == "hex" 300 300 email_address_encoded = ''