Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
miloops committed Aug 7, 2009
2 parents 945ef58 + bfe58ac commit 04abe538ac80b8d82658acaa3de5ef6c961d3e39
Showing with 241 additions and 406 deletions.
  1. +2 −2 actionmailer/lib/action_mailer/base.rb
  2. +6 −4 actionmailer/test/mail_service_test.rb
  3. +3 −5 actionpack/examples/minimal.rb
  4. +3 −3 actionpack/examples/very_simple.rb
  5. +16 −0 actionpack/lib/abstract_controller.rb
  6. +1 −1 actionpack/lib/{action_controller/abstract → abstract_controller}/base.rb
  7. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/benchmarker.rb
  8. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/callbacks.rb
  9. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/exceptions.rb
  10. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/helpers.rb
  11. +16 −0 actionpack/lib/{action_controller/abstract → abstract_controller}/layouts.rb
  12. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/logger.rb
  13. +8 −8 actionpack/lib/{action_controller/abstract → abstract_controller}/renderer.rb
  14. +37 −37 actionpack/lib/action_controller.rb
  15. +0 −16 actionpack/lib/action_controller/abstract.rb
  16. +1 −1 actionpack/lib/action_controller/{base → }/base.rb
  17. +1 −2 actionpack/lib/action_controller/caching/actions.rb
  18. +5 −7 actionpack/lib/action_controller/{base/http.rb → metal.rb}
  19. +2 −2 actionpack/lib/action_controller/{base → metal}/compatibility.rb
  20. 0 actionpack/lib/action_controller/{base → metal}/conditional_get.rb
  21. 0 actionpack/lib/action_controller/{base → metal}/cookies.rb
  22. 0 actionpack/lib/action_controller/{base → metal}/exceptions.rb
  23. 0 actionpack/lib/action_controller/{base → metal}/filter_parameter_logging.rb
  24. 0 actionpack/lib/action_controller/{base → metal}/flash.rb
  25. 0 actionpack/lib/action_controller/{base → metal}/helpers.rb
  26. 0 actionpack/lib/action_controller/{base → metal}/hide_actions.rb
  27. 0 actionpack/lib/action_controller/{base → metal}/http_authentication.rb
  28. 0 actionpack/lib/action_controller/{base → metal}/layouts.rb
  29. 0 actionpack/lib/action_controller/{base → metal}/mime_responds.rb
  30. +1 −1 actionpack/lib/action_controller/{base → metal}/rack_convenience.rb
  31. 0 actionpack/lib/action_controller/{base → metal}/redirector.rb
  32. +7 −7 actionpack/lib/action_controller/{base → metal}/render_options.rb
  33. +2 −13 actionpack/lib/action_controller/{base → metal}/renderer.rb
  34. 0 actionpack/lib/action_controller/{base → metal}/request_forgery_protection.rb
  35. 0 actionpack/lib/action_controller/{base → metal}/rescuable.rb
  36. 0 actionpack/lib/action_controller/{base → metal}/session.rb
  37. 0 actionpack/lib/action_controller/{base → metal}/session_management.rb
  38. 0 actionpack/lib/action_controller/{base → metal}/streaming.rb
  39. 0 actionpack/lib/action_controller/{base → metal}/testing.rb
  40. 0 actionpack/lib/action_controller/{base → metal}/url_for.rb
  41. 0 actionpack/lib/action_controller/{base → metal}/verification.rb
  42. +0 −84 actionpack/lib/action_controller/old_base.rb
  43. +0 −15 actionpack/lib/action_controller/record_identifier.rb
  44. +2 −2 actionpack/lib/action_view/context.rb
  45. +4 −0 actionpack/lib/action_view/helpers/form_helper.rb
  46. +52 −90 actionpack/lib/action_view/render/partials.rb
  47. +63 −41 actionpack/lib/action_view/render/rendering.rb
  48. +3 −3 actionpack/lib/action_view/test_case.rb
  49. +1 −1 actionpack/test/abstract_controller/test_helper.rb
  50. +1 −2 actionpack/test/abstract_unit.rb
  51. +2 −1 actionpack/test/controller/logging_test.rb
  52. +0 −57 actionpack/test/controller/record_identifier_test.rb
  53. +2 −1 actionpack/test/controller/render_test.rb
@@ -566,7 +566,7 @@ def render_template(template, body)
@template = initialize_template_class(body)
layout = _pick_layout(layout, true) unless
ActionController::Base.exempt_from_layout.include?(template.handler)
- @template._render_template_with_layout(template, layout, {})
+ @template._render_template(template, layout, {})
ensure
@current_template_content_type = nil
end
@@ -592,7 +592,7 @@ def render(opts)
!template || ActionController::Base.exempt_from_layout.include?(template.handler))
if template
- @template._render_template_with_layout(template, layout, opts)
+ @template._render_template(template, layout, opts)
elsif inline = opts[:inline]
@template._render_inline(inline, layout, opts)
end
@@ -573,12 +573,14 @@ def initialize
@info_contents, @debug_contents = "", ""
end
- def info(str)
- @info_contents << str
+ def info(str = nil, &blk)
+ @info_contents << str if str
+ @info_contents << blk.call if block_given?
end
- def debug(str)
- @debug_contents << str
+ def debug(str = nil, &blk)
+ @debug_contents << str if str
+ @debug_contents << blk.call if block_given?
end
end
@@ -45,11 +45,9 @@ def index
OK = [200, {}, []]
MetalPostController = lambda { OK }
-if ActionController.const_defined?(:Http)
- class HttpPostController < ActionController::Http
- def index
- self.response_body = ''
- end
+class HttpPostController < ActionController::Metal
+ def index
+ self.response_body = ''
end
end
@@ -3,7 +3,7 @@
require "action_controller"
-class Kaigi < ActionController::Http
+class Kaigi < ActionController::Metal
include AbstractController::Callbacks
include ActionController::RackConvenience
include ActionController::Renderer
@@ -13,7 +13,7 @@ class Kaigi < ActionController::Http
before_filter :set_name
append_view_path "views"
- def _action_view
+ def view_context
self
end
@@ -23,7 +23,7 @@ def controller
DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
- def _render_template_from_controller(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
+ def render_template(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
ret = template.render(self, {})
layout.render(self, {}) { ret }
end
@@ -0,0 +1,16 @@
+require "active_support/core_ext/module/attr_internal"
+require "active_support/core_ext/module/delegation"
+
+module AbstractController
+ autoload :Base, "abstract_controller/base"
+ autoload :Benchmarker, "abstract_controller/benchmarker"
+ autoload :Callbacks, "abstract_controller/callbacks"
+ autoload :Helpers, "abstract_controller/helpers"
+ autoload :Layouts, "abstract_controller/layouts"
+ autoload :Logger, "abstract_controller/logger"
+ autoload :Renderer, "abstract_controller/renderer"
+ # === Exceptions
+ autoload :ActionNotFound, "abstract_controller/exceptions"
+ autoload :DoubleRenderError, "abstract_controller/exceptions"
+ autoload :Error, "abstract_controller/exceptions"
+end
@@ -30,7 +30,7 @@ def descendants
# instance methods on that abstract class. Public instance methods of
# a controller would normally be considered action methods, so we
# are removing those methods on classes declared as abstract
- # (ActionController::Http and ActionController::Base are defined
+ # (ActionController::Metal and ActionController::Base are defined
# as abstract)
def internal_methods
controller = self
@@ -88,6 +88,22 @@ def _layout(details)
end
end
+ def render_to_body(options = {})
+ response = super
+
+ if options.key?(:partial)
+ # This is a little bit messy. We need to explicitly handle partial
+ # layouts here since the core lookup logic is in the view, but
+ # we need to determine the layout based on the controller
+ if options.key?(:layout)
+ layout = _layout_for_option(options[:layout], options[:_template].details)
+ response = layout.render(view_context, options[:locals]) { response }
+ end
+ end
+
+ response
+ end
+
private
# This will be overwritten by _write_layout_method
def _layout(details) end
@@ -1,4 +1,4 @@
-require "action_controller/abstract/logger"
+require "abstract_controller/logger"
module AbstractController
module Renderer
@@ -19,20 +19,20 @@ module Renderer
# The view class must have the following methods:
# View.for_controller[controller] Create a new ActionView instance for a
# controller
- # View#_render_partial_from_controller[options]
+ # View#render_partial[options]
# - responsible for setting options[:_template]
# - Returns String with the rendered partial
# options<Hash>:: see _render_partial in ActionView::Base
- # View#_render_template_from_controller[template, layout, options, partial]
+ # View#render_template[template, layout, options, partial]
# - Returns String with the rendered template
# template<ActionView::Template>:: The template to render
# layout<ActionView::Template>:: The layout to render around the template
# options<Hash>:: See _render_template_with_layout in ActionView::Base
# partial<Boolean>:: Whether or not the template to render is a partial
#
# Override this method in a to change the default behavior.
- def _action_view
- @_action_view ||= ActionView::Base.for_controller(self)
+ def view_context
+ @_view_context ||= ActionView::Base.for_controller(self)
end
# Mostly abstracts the fact that calling render twice is a DoubleRenderError.
@@ -54,8 +54,8 @@ def render(*args)
# :api: plugin
def render_to_body(options = {})
# TODO: Refactor so we can just use the normal template logic for this
- if options[:_partial_object]
- _action_view._render_partial_from_controller(options)
+ if options.key?(:partial)
+ view_context.render_partial(options)
else
_determine_template(options)
_render_template(options)
@@ -77,7 +77,7 @@ def render_to_string(options = {})
# _layout<ActionView::Template>:: The layout to wrap the template in (optional)
# _partial<TrueClass, FalseClass>:: Whether or not the template to be rendered is a partial
def _render_template(options)
- _action_view._render_template_from_controller(options[:_template], options[:_layout], options, options[:_partial])
+ view_context.render_template(options)
end
# The list of view paths for this controller. See ActionView::ViewPathSet for
@@ -1,62 +1,62 @@
module ActionController
- autoload :Base, "action_controller/base/base"
- autoload :ConditionalGet, "action_controller/base/conditional_get"
- autoload :HideActions, "action_controller/base/hide_actions"
- autoload :Http, "action_controller/base/http"
- autoload :Layouts, "action_controller/base/layouts"
- autoload :RackConvenience, "action_controller/base/rack_convenience"
- autoload :Rails2Compatibility, "action_controller/base/compatibility"
- autoload :Redirector, "action_controller/base/redirector"
- autoload :Renderer, "action_controller/base/renderer"
- autoload :RenderOptions, "action_controller/base/render_options"
- autoload :Renderers, "action_controller/base/render_options"
- autoload :Rescue, "action_controller/base/rescuable"
- autoload :Testing, "action_controller/base/testing"
- autoload :UrlFor, "action_controller/base/url_for"
- autoload :Session, "action_controller/base/session"
- autoload :Helpers, "action_controller/base/helpers"
+ autoload :Base, "action_controller/base"
+ autoload :ConditionalGet, "action_controller/metal/conditional_get"
+ autoload :HideActions, "action_controller/metal/hide_actions"
+ autoload :Metal, "action_controller/metal"
+ autoload :Layouts, "action_controller/metal/layouts"
+ autoload :RackConvenience, "action_controller/metal/rack_convenience"
+ autoload :Rails2Compatibility, "action_controller/metal/compatibility"
+ autoload :Redirector, "action_controller/metal/redirector"
+ autoload :Renderer, "action_controller/metal/renderer"
+ autoload :RenderOptions, "action_controller/metal/render_options"
+ autoload :Renderers, "action_controller/metal/render_options"
+ autoload :Rescue, "action_controller/metal/rescuable"
+ autoload :Testing, "action_controller/metal/testing"
+ autoload :UrlFor, "action_controller/metal/url_for"
+ autoload :Session, "action_controller/metal/session"
+ autoload :Helpers, "action_controller/metal/helpers"
# Ported modules
# require 'action_controller/routing'
autoload :Caching, 'action_controller/caching'
autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
autoload :Integration, 'action_controller/testing/integration'
- autoload :MimeResponds, 'action_controller/base/mime_responds'
+ autoload :MimeResponds, 'action_controller/metal/mime_responds'
autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
autoload :RecordIdentifier, 'action_controller/record_identifier'
autoload :Resources, 'action_controller/routing/resources'
- autoload :SessionManagement, 'action_controller/base/session_management'
+ autoload :SessionManagement, 'action_controller/metal/session_management'
autoload :TestCase, 'action_controller/testing/test_case'
autoload :TestProcess, 'action_controller/testing/process'
autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
- autoload :Verification, 'action_controller/base/verification'
- autoload :Flash, 'action_controller/base/flash'
- autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection'
- autoload :Streaming, 'action_controller/base/streaming'
- autoload :HttpAuthentication, 'action_controller/base/http_authentication'
- autoload :FilterParameterLogging, 'action_controller/base/filter_parameter_logging'
+ autoload :Verification, 'action_controller/metal/verification'
+ autoload :Flash, 'action_controller/metal/flash'
+ autoload :RequestForgeryProtection, 'action_controller/metal/request_forgery_protection'
+ autoload :Streaming, 'action_controller/metal/streaming'
+ autoload :HttpAuthentication, 'action_controller/metal/http_authentication'
+ autoload :FilterParameterLogging, 'action_controller/metal/filter_parameter_logging'
autoload :Translation, 'action_controller/translation'
- autoload :Cookies, 'action_controller/base/cookies'
+ autoload :Cookies, 'action_controller/metal/cookies'
- autoload :ActionControllerError, 'action_controller/base/exceptions'
- autoload :SessionRestoreError, 'action_controller/base/exceptions'
- autoload :RenderError, 'action_controller/base/exceptions'
- autoload :RoutingError, 'action_controller/base/exceptions'
- autoload :MethodNotAllowed, 'action_controller/base/exceptions'
- autoload :NotImplemented, 'action_controller/base/exceptions'
- autoload :UnknownController, 'action_controller/base/exceptions'
- autoload :MissingFile, 'action_controller/base/exceptions'
- autoload :RenderError, 'action_controller/base/exceptions'
- autoload :SessionOverflowError, 'action_controller/base/exceptions'
- autoload :UnknownHttpMethod, 'action_controller/base/exceptions'
+ autoload :ActionControllerError, 'action_controller/metal/exceptions'
+ autoload :SessionRestoreError, 'action_controller/metal/exceptions'
+ autoload :RenderError, 'action_controller/metal/exceptions'
+ autoload :RoutingError, 'action_controller/metal/exceptions'
+ autoload :MethodNotAllowed, 'action_controller/metal/exceptions'
+ autoload :NotImplemented, 'action_controller/metal/exceptions'
+ autoload :UnknownController, 'action_controller/metal/exceptions'
+ autoload :MissingFile, 'action_controller/metal/exceptions'
+ autoload :RenderError, 'action_controller/metal/exceptions'
+ autoload :SessionOverflowError, 'action_controller/metal/exceptions'
+ autoload :UnknownHttpMethod, 'action_controller/metal/exceptions'
autoload :Routing, 'action_controller/routing'
end
autoload :HTML, 'action_controller/vendor/html-scanner'
-autoload :AbstractController, 'action_controller/abstract'
+autoload :AbstractController, 'abstract_controller'
autoload :Rack, 'action_dispatch'
autoload :ActionDispatch, 'action_dispatch'
@@ -1,16 +0,0 @@
-require "active_support/core_ext/module/attr_internal"
-require "active_support/core_ext/module/delegation"
-
-module AbstractController
- autoload :Base, "action_controller/abstract/base"
- autoload :Benchmarker, "action_controller/abstract/benchmarker"
- autoload :Callbacks, "action_controller/abstract/callbacks"
- autoload :Helpers, "action_controller/abstract/helpers"
- autoload :Layouts, "action_controller/abstract/layouts"
- autoload :Logger, "action_controller/abstract/logger"
- autoload :Renderer, "action_controller/abstract/renderer"
- # === Exceptions
- autoload :ActionNotFound, "action_controller/abstract/exceptions"
- autoload :DoubleRenderError, "action_controller/abstract/exceptions"
- autoload :Error, "action_controller/abstract/exceptions"
-end
@@ -1,5 +1,5 @@
module ActionController
- class Base < Http
+ class Base < Metal
abstract!
include AbstractController::Benchmarker
@@ -129,8 +129,7 @@ def cache_layout?
end
def content_for_layout(controller)
- # TODO: Remove this when new base is merged in
- template = controller.respond_to?(:template) ? controller.template : controller._action_view
+ template = controller.view_context
template.layout && template.instance_variable_get('@cached_content_for_layout')
end
end
@@ -1,13 +1,11 @@
-require 'action_controller/abstract'
-
module ActionController
- # ActionController::Http provides a way to get a valid Rack application from a controller.
+ # ActionController::Metal provides a way to get a valid Rack application from a controller.
#
# In AbstractController, dispatching is triggered directly by calling #process on a new controller.
- # ActionController::Http provides an #action method that returns a valid Rack application for a
+ # ActionController::Metal provides an #action method that returns a valid Rack application for a
# given action. Other rack builders, such as Rack::Builder, Rack::URLMap, and the Rails router,
# can dispatch directly to the action returned by FooController.action(:index).
- class Http < AbstractController::Base
+ class Metal < AbstractController::Base
abstract!
# :api: public
@@ -72,11 +70,11 @@ def location=(url)
def call(name, env)
@_env = env
process(name)
- to_rack
+ to_a
end
# :api: private
- def to_rack
+ def to_a
[status, headers, response_body]
end
@@ -72,7 +72,7 @@ def assign_shortcuts(*) end
# TODO: Remove this after we flip
def template
- @template ||= _action_view
+ @template ||= view_context
end
def process_action(*)
@@ -141,7 +141,7 @@ def prepend_view_path(path)
end
def view_paths
- _action_view.view_paths
+ view_context.view_paths
end
end
end
@@ -20,7 +20,7 @@ def params
end
# :api: private
- def to_rack
+ def to_a
@_response.prepare!
@_response.to_a
end
Oops, something went wrong.

0 comments on commit 04abe53

Please sign in to comment.