mirror of https://github.com/rails/rails
Some mime type refactoring. Closes #9957 [Josh Peek]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8001 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
28729a4829
commit
562b398fd7
|
@ -251,7 +251,7 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
private
|
private
|
||||||
def set_content_type!(controller, extension)
|
def set_content_type!(controller, extension)
|
||||||
controller.response.content_type = Mime::EXTENSION_LOOKUP[extension].to_s if extension
|
controller.response.content_type = Mime::Type.lookup_by_extension(extension).to_s if extension
|
||||||
end
|
end
|
||||||
|
|
||||||
def path_options_for(controller, options)
|
def path_options_for(controller, options)
|
||||||
|
|
|
@ -110,14 +110,11 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
class Responder #:nodoc:
|
class Responder #:nodoc:
|
||||||
def initialize(controller)
|
def initialize(controller)
|
||||||
@controller = controller
|
@controller = controller
|
||||||
@request = controller.request
|
@request = controller.request
|
||||||
@response = controller.response
|
@response = controller.response
|
||||||
|
|
||||||
format = @request.parameters[:format]
|
@mime_type_priority = Array(Mime::Type.lookup_by_extension(@request.parameters[:format]) || @request.accepts)
|
||||||
@mime_type_priority = format && Mime::EXTENSION_LOOKUP[format] ?
|
|
||||||
[ Mime::EXTENSION_LOOKUP[format] ] :
|
|
||||||
@request.accepts
|
|
||||||
|
|
||||||
@order = []
|
@order = []
|
||||||
@responses = {}
|
@responses = {}
|
||||||
|
@ -128,18 +125,10 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
@order << mime_type
|
@order << mime_type
|
||||||
|
|
||||||
if block_given?
|
@responses[mime_type] = Proc.new do
|
||||||
@responses[mime_type] = Proc.new do
|
@response.template.template_format = mime_type.to_sym
|
||||||
@response.template.template_format = mime_type.to_sym
|
@response.content_type = mime_type.to_s
|
||||||
@response.content_type = mime_type.to_s
|
block_given? ? block.call : @controller.send(:render, :action => @controller.action_name)
|
||||||
block.call
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@responses[mime_type] = Proc.new do
|
|
||||||
@response.template.template_format = mime_type.to_sym
|
|
||||||
@response.content_type = mime_type.to_s
|
|
||||||
@controller.send :render, :action => @controller.action_name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Mime
|
module Mime
|
||||||
SET = []
|
SET = []
|
||||||
EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k == "" }
|
EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
|
||||||
LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k == "" }
|
LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
|
||||||
|
|
||||||
# Encapsulates the notion of a mime type. Can be used at render time, for example, with:
|
# Encapsulates the notion of a mime type. Can be used at render time, for example, with:
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue