actionpack 3.0.0.beta4 → 3.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (102) hide show
  1. data/CHANGELOG +36 -0
  2. data/{README → README.rdoc} +79 -137
  3. data/lib/abstract_controller.rb +1 -0
  4. data/lib/abstract_controller/asset_paths.rb +1 -1
  5. data/lib/abstract_controller/base.rb +3 -12
  6. data/lib/abstract_controller/rendering.rb +2 -2
  7. data/lib/abstract_controller/view_paths.rb +2 -1
  8. data/lib/action_controller.rb +1 -2
  9. data/lib/action_controller/base.rb +3 -9
  10. data/lib/action_controller/log_subscriber.rb +56 -0
  11. data/lib/action_controller/metal.rb +10 -3
  12. data/lib/action_controller/metal/helpers.rb +5 -4
  13. data/lib/action_controller/metal/hide_actions.rb +3 -3
  14. data/lib/action_controller/metal/instrumentation.rb +2 -1
  15. data/lib/action_controller/metal/mime_responds.rb +13 -10
  16. data/lib/action_controller/metal/rack_delegation.rb +0 -4
  17. data/lib/action_controller/metal/request_forgery_protection.rb +1 -1
  18. data/lib/action_controller/metal/rescue.rb +9 -0
  19. data/lib/action_controller/metal/responder.rb +13 -5
  20. data/lib/action_controller/metal/streaming.rb +2 -0
  21. data/lib/action_controller/metal/url_for.rb +5 -5
  22. data/lib/action_controller/railtie.rb +14 -23
  23. data/lib/action_controller/record_identifier.rb +6 -25
  24. data/lib/action_controller/test_case.rb +18 -6
  25. data/lib/action_controller/vendor/html-scanner/html/node.rb +1 -0
  26. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +1 -0
  27. data/lib/action_dispatch.rb +6 -0
  28. data/lib/action_dispatch/http/cache.rb +2 -2
  29. data/lib/action_dispatch/http/filter_parameters.rb +10 -66
  30. data/lib/action_dispatch/http/mime_type.rb +1 -1
  31. data/lib/action_dispatch/http/parameter_filter.rb +72 -0
  32. data/lib/action_dispatch/http/parameters.rb +31 -2
  33. data/lib/action_dispatch/http/request.rb +4 -1
  34. data/lib/action_dispatch/http/upload.rb +2 -2
  35. data/lib/action_dispatch/middleware/callbacks.rb +4 -4
  36. data/lib/action_dispatch/middleware/cookies.rb +39 -6
  37. data/lib/action_dispatch/middleware/flash.rb +9 -2
  38. data/lib/action_dispatch/middleware/session/abstract_store.rb +121 -36
  39. data/lib/action_dispatch/middleware/session/cookie_store.rb +26 -19
  40. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +9 -1
  41. data/lib/action_dispatch/middleware/show_exceptions.rb +2 -2
  42. data/lib/action_dispatch/middleware/stack.rb +12 -5
  43. data/lib/action_dispatch/railtie.rb +1 -1
  44. data/lib/action_dispatch/routing.rb +11 -13
  45. data/lib/action_dispatch/routing/deprecated_mapper.rb +6 -388
  46. data/lib/action_dispatch/routing/mapper.rb +364 -234
  47. data/lib/action_dispatch/routing/polymorphic_routes.rb +186 -0
  48. data/lib/action_dispatch/routing/route.rb +11 -2
  49. data/lib/action_dispatch/routing/route_set.rb +62 -28
  50. data/lib/action_dispatch/routing/url_for.rb +2 -1
  51. data/lib/action_dispatch/testing/assertions.rb +0 -2
  52. data/lib/action_dispatch/testing/assertions/routing.rb +0 -1
  53. data/lib/action_dispatch/testing/assertions/selector.rb +20 -24
  54. data/lib/action_dispatch/testing/integration.rb +2 -2
  55. data/lib/action_dispatch/testing/test_response.rb +2 -2
  56. data/lib/action_pack/version.rb +1 -1
  57. data/lib/action_view.rb +1 -0
  58. data/lib/action_view/base.rb +20 -21
  59. data/lib/action_view/context.rb +9 -12
  60. data/lib/action_view/helpers.rb +0 -2
  61. data/lib/action_view/helpers/active_model_helper.rb +17 -2
  62. data/lib/action_view/helpers/asset_tag_helper.rb +15 -33
  63. data/lib/action_view/helpers/atom_feed_helper.rb +5 -3
  64. data/lib/action_view/helpers/cache_helper.rb +4 -2
  65. data/lib/action_view/helpers/capture_helper.rb +4 -4
  66. data/lib/action_view/helpers/csrf_helper.rb +3 -1
  67. data/lib/action_view/helpers/date_helper.rb +10 -5
  68. data/lib/action_view/helpers/debug_helper.rb +3 -1
  69. data/lib/action_view/helpers/form_helper.rb +36 -30
  70. data/lib/action_view/helpers/form_options_helper.rb +7 -6
  71. data/lib/action_view/helpers/form_tag_helper.rb +17 -6
  72. data/lib/action_view/helpers/javascript_helper.rb +1 -0
  73. data/lib/action_view/helpers/number_helper.rb +16 -45
  74. data/lib/action_view/helpers/prototype_helper.rb +14 -16
  75. data/lib/action_view/helpers/raw_output_helper.rb +9 -0
  76. data/lib/action_view/helpers/record_tag_helper.rb +5 -0
  77. data/lib/action_view/helpers/sanitize_helper.rb +26 -20
  78. data/lib/action_view/helpers/scriptaculous_helper.rb +6 -5
  79. data/lib/action_view/helpers/tag_helper.rb +2 -1
  80. data/lib/action_view/helpers/text_helper.rb +24 -111
  81. data/lib/action_view/helpers/translation_helper.rb +17 -10
  82. data/lib/action_view/helpers/url_helper.rb +26 -33
  83. data/lib/action_view/log_subscriber.rb +28 -0
  84. data/lib/action_view/lookup_context.rb +2 -0
  85. data/lib/action_view/paths.rb +1 -0
  86. data/lib/action_view/railtie.rb +15 -3
  87. data/lib/action_view/render/layouts.rb +2 -1
  88. data/lib/action_view/render/partials.rb +3 -1
  89. data/lib/action_view/render/rendering.rb +2 -1
  90. data/lib/action_view/template.rb +12 -8
  91. data/lib/action_view/template/error.rb +1 -0
  92. data/lib/action_view/template/handlers.rb +1 -0
  93. data/lib/action_view/template/resolver.rb +2 -1
  94. data/lib/action_view/template/text.rb +1 -0
  95. data/lib/action_view/test_case.rb +42 -20
  96. metadata +44 -23
  97. data/lib/action_controller/polymorphic_routes.rb +0 -182
  98. data/lib/action_controller/railties/log_subscriber.rb +0 -56
  99. data/lib/action_controller/railties/url_helpers.rb +0 -14
  100. data/lib/action_dispatch/testing/assertions/model.rb +0 -19
  101. data/lib/action_view/helpers/record_identification_helper.rb +0 -20
  102. data/lib/action_view/railties/log_subscriber.rb +0 -24
@@ -7,9 +7,7 @@ require 'action_controller/vendor/html-scanner'
7
7
 
8
8
  module ActionDispatch
9
9
  module Assertions
10
- unless const_defined?(:NO_STRIP)
11
- NO_STRIP = %w{pre script style textarea}
12
- end
10
+ NO_STRIP = %w{pre script style textarea}
13
11
 
14
12
  # Adds the +assert_select+ method for use in Rails functional
15
13
  # test cases, which can be used to make assertions on the response HTML of a controller
@@ -359,7 +357,7 @@ module ActionDispatch
359
357
  # position. Possible values are <tt>:top</tt>, <tt>:bottom</tt>, <tt>:before</tt>
360
358
  # and <tt>:after</tt>.
361
359
  #
362
- # Use the argument <tt>:redirect</tt> follwed by a path to check that an statement
360
+ # Use the argument <tt>:redirect</tt> followed by a path to check that an statement
363
361
  # which redirects to the specified path is generated.
364
362
  #
365
363
  # Using the <tt>:remove</tt> statement, you will be able to pass a block, but it will
@@ -581,27 +579,25 @@ module ActionDispatch
581
579
  end
582
580
 
583
581
  protected
584
- unless const_defined?(:RJS_STATEMENTS)
585
- RJS_PATTERN_HTML = "\"((\\\\\"|[^\"])*)\""
586
- RJS_ANY_ID = "\"([^\"])*\""
587
- RJS_STATEMENTS = {
588
- :chained_replace => "\\$\\(#{RJS_ANY_ID}\\)\\.replace\\(#{RJS_PATTERN_HTML}\\)",
589
- :chained_replace_html => "\\$\\(#{RJS_ANY_ID}\\)\\.update\\(#{RJS_PATTERN_HTML}\\)",
590
- :replace_html => "Element\\.update\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
591
- :replace => "Element\\.replace\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
592
- :redirect => "window.location.href = #{RJS_ANY_ID}"
593
- }
594
- [:remove, :show, :hide, :toggle].each do |action|
595
- RJS_STATEMENTS[action] = "Element\\.#{action}\\(#{RJS_ANY_ID}\\)"
596
- end
597
- RJS_INSERTIONS = ["top", "bottom", "before", "after"]
598
- RJS_INSERTIONS.each do |insertion|
599
- RJS_STATEMENTS["insert_#{insertion}".to_sym] = "Element.insert\\(#{RJS_ANY_ID}, \\{ #{insertion}: #{RJS_PATTERN_HTML} \\}\\)"
600
- end
601
- RJS_STATEMENTS[:insert_html] = "Element.insert\\(#{RJS_ANY_ID}, \\{ (#{RJS_INSERTIONS.join('|')}): #{RJS_PATTERN_HTML} \\}\\)"
602
- RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
603
- RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
582
+ RJS_PATTERN_HTML = "\"((\\\\\"|[^\"])*)\""
583
+ RJS_ANY_ID = "\"([^\"])*\""
584
+ RJS_STATEMENTS = {
585
+ :chained_replace => "\\$\\(#{RJS_ANY_ID}\\)\\.replace\\(#{RJS_PATTERN_HTML}\\)",
586
+ :chained_replace_html => "\\$\\(#{RJS_ANY_ID}\\)\\.update\\(#{RJS_PATTERN_HTML}\\)",
587
+ :replace_html => "Element\\.update\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
588
+ :replace => "Element\\.replace\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
589
+ :redirect => "window.location.href = #{RJS_ANY_ID}"
590
+ }
591
+ [:remove, :show, :hide, :toggle].each do |action|
592
+ RJS_STATEMENTS[action] = "Element\\.#{action}\\(#{RJS_ANY_ID}\\)"
593
+ end
594
+ RJS_INSERTIONS = ["top", "bottom", "before", "after"]
595
+ RJS_INSERTIONS.each do |insertion|
596
+ RJS_STATEMENTS["insert_#{insertion}".to_sym] = "Element.insert\\(#{RJS_ANY_ID}, \\{ #{insertion}: #{RJS_PATTERN_HTML} \\}\\)"
604
597
  end
598
+ RJS_STATEMENTS[:insert_html] = "Element.insert\\(#{RJS_ANY_ID}, \\{ (#{RJS_INSERTIONS.join('|')}): #{RJS_PATTERN_HTML} \\}\\)"
599
+ RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
600
+ RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
605
601
 
606
602
  # +assert_select+ and +css_select+ call this to obtain the content in the HTML
607
603
  # page, or from all the RJS statements, depending on the type of response.
@@ -319,7 +319,7 @@ module ActionDispatch
319
319
  reset! unless @integration_session
320
320
  # reset the html_document variable, but only for new get/post calls
321
321
  @html_document = nil unless %w(cookies assigns).include?(method)
322
- returning @integration_session.__send__(method, *args) do
322
+ @integration_session.__send__(method, *args).tap do
323
323
  copy_session_variables!
324
324
  end
325
325
  end
@@ -362,7 +362,7 @@ module ActionDispatch
362
362
  def method_missing(sym, *args, &block)
363
363
  reset! unless @integration_session
364
364
  if @integration_session.respond_to?(sym)
365
- returning @integration_session.__send__(sym, *args, &block) do
365
+ @integration_session.__send__(sym, *args, &block).tap do
366
366
  copy_session_variables!
367
367
  end
368
368
  else
@@ -53,7 +53,7 @@ module ActionDispatch
53
53
  # Returns the template of the file which was used to
54
54
  # render this response (or nil)
55
55
  def rendered
56
- ActiveSupport::Deprecation.warn("response.rendered has been deprecated. Use tempate.rendered instead", caller)
56
+ ActiveSupport::Deprecation.warn("response.rendered has been deprecated. Use template.rendered instead", caller)
57
57
  @template.instance_variable_get(:@_rendered)
58
58
  end
59
59
 
@@ -89,7 +89,7 @@ module ActionDispatch
89
89
 
90
90
  # A shortcut to the template.assigns
91
91
  def template_objects
92
- ActiveSupport::Deprecation.warn("response.template_objects has been deprecated. Use tempate.assigns instead", caller)
92
+ ActiveSupport::Deprecation.warn("response.template_objects has been deprecated. Use template.assigns instead", caller)
93
93
  @template.assigns || {}
94
94
  end
95
95
 
@@ -3,7 +3,7 @@ module ActionPack
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "beta4"
6
+ BUILD = "rc"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
@@ -23,6 +23,7 @@
23
23
 
24
24
  activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
25
25
  $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
26
+
26
27
  require 'active_support/ruby/shim'
27
28
  require 'active_support/core_ext/class/attribute_accessors'
28
29
 
@@ -2,16 +2,20 @@ require 'active_support/core_ext/module/attr_internal'
2
2
  require 'active_support/core_ext/module/delegation'
3
3
  require 'active_support/core_ext/class/attribute'
4
4
  require 'active_support/core_ext/array/wrap'
5
+ require 'active_support/ordered_options'
6
+ require 'action_view/log_subscriber'
5
7
 
6
8
  module ActionView #:nodoc:
7
9
  class NonConcattingString < ActiveSupport::SafeBuffer
8
10
  end
9
11
 
12
+ # = Action View Base
13
+ #
10
14
  # Action View templates can be written in three ways. If the template file has a <tt>.erb</tt> (or <tt>.rhtml</tt>) extension then it uses a mixture of ERb
11
15
  # (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> (or <tt>.rxml</tt>) extension then Jim Weirich's Builder::XmlMarkup library is used.
12
16
  # If the template file has a <tt>.rjs</tt> extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.
13
17
  #
14
- # = ERb
18
+ # == ERb
15
19
  #
16
20
  # You trigger ERb by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
17
21
  # following loop for names:
@@ -31,7 +35,7 @@ module ActionView #:nodoc:
31
35
  #
32
36
  # <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
33
37
  #
34
- # == Using sub templates
38
+ # === Using sub templates
35
39
  #
36
40
  # Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
37
41
  # classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
@@ -53,7 +57,7 @@ module ActionView #:nodoc:
53
57
  #
54
58
  # <title><%= @page_title %></title>
55
59
  #
56
- # == Passing local variables to sub templates
60
+ # === Passing local variables to sub templates
57
61
  #
58
62
  # You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
59
63
  #
@@ -73,7 +77,7 @@ module ActionView #:nodoc:
73
77
  #
74
78
  # Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
75
79
  #
76
- # == Template caching
80
+ # === Template caching
77
81
  #
78
82
  # By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will
79
83
  # check the file's modification time and recompile it.
@@ -158,7 +162,6 @@ module ActionView #:nodoc:
158
162
  end
159
163
 
160
164
  include Helpers, Rendering, Partials, Layouts, ::ERB::Util, Context
161
- extend ActiveSupport::Memoizable
162
165
 
163
166
  # Specify whether RJS responses should be wrapped in a try/catch block
164
167
  # that alert()s the caught exception (and then re-raises it).
@@ -170,10 +173,7 @@ module ActionView #:nodoc:
170
173
  @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
171
174
 
172
175
  class_attribute :helpers
173
- remove_method :helpers
174
- attr_reader :helpers
175
-
176
- class_attribute :_router
176
+ class_attribute :_routes
177
177
 
178
178
  class << self
179
179
  delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
@@ -201,20 +201,25 @@ module ActionView #:nodoc:
201
201
  end
202
202
 
203
203
  def self.process_view_paths(value)
204
- return value.dup if value.is_a?(PathSet)
205
- ActionView::PathSet.new(Array.wrap(value))
204
+ value.is_a?(PathSet) ?
205
+ value.dup : ActionView::PathSet.new(Array.wrap(value))
206
+ end
207
+
208
+ def assign(new_assigns) # :nodoc:
209
+ self.assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
206
210
  end
207
211
 
208
212
  def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc:
209
- @config = nil
210
- @assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) }
211
- @helpers = self.class.helpers || Module.new
213
+ assign(assigns_for_first_render)
214
+ self.helpers = self.class.helpers || Module.new
212
215
 
213
216
  if @_controller = controller
214
217
  @_request = controller.request if controller.respond_to?(:request)
215
218
  end
216
219
 
217
- @_config = ActiveSupport::InheritableOptions.new(controller.config) if controller && controller.respond_to?(:config)
220
+ config = controller && controller.respond_to?(:config) ? controller.config : {}
221
+ @_config = ActiveSupport::InheritableOptions.new(config)
222
+
218
223
  @_content_for = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new }
219
224
  @_virtual_path = nil
220
225
  @output_buffer = nil
@@ -228,12 +233,6 @@ module ActionView #:nodoc:
228
233
  @controller_path ||= controller && controller.controller_path
229
234
  end
230
235
 
231
- def punctuate_body!(part)
232
- flush_output_buffer
233
- response.body_parts << part
234
- nil
235
- end
236
-
237
236
  ActiveSupport.run_load_hooks(:action_view, self)
238
237
  end
239
238
  end
@@ -2,13 +2,12 @@ module ActionView
2
2
  module CompiledTemplates #:nodoc:
3
3
  # holds compiled template code
4
4
  end
5
-
6
- # ActionView contexts are supplied to ActionController
7
- # to render template. The default ActionView context
8
- # is ActionView::Base.
5
+ # = Action View Context
6
+ #
7
+ # Action View contexts are supplied to Action Controller to render template.
8
+ # The default Action View context is ActionView::Base.
9
9
  #
10
- # In order to work with ActionController, a Context
11
- # must implement:
10
+ # In order to work with ActionController, a Context must implement:
12
11
  #
13
12
  # Context#render_partial[options]
14
13
  # - responsible for setting options[:_template]
@@ -21,16 +20,14 @@ module ActionView
21
20
  # options<Hash>:: See _render_template_with_layout in ActionView::Base
22
21
  # partial<Boolean>:: Whether or not the template to render is a partial
23
22
  #
24
- # An ActionView context can also mix in ActionView's
25
- # helpers. In order to mix in helpers, a context must
26
- # implement:
23
+ # An Action View context can also mix in Action View's helpers. In order to
24
+ # mix in helpers, a context must implement:
27
25
  #
28
26
  # Context#controller
29
27
  # - Returns an instance of AbstractController
30
28
  #
31
- # In any case, a context must mix in ActionView::Context,
32
- # which stores compiled template and provides the output
33
- # buffer.
29
+ # In any case, a context must mix in ActionView::Context, which stores compiled
30
+ # template and provides the output buffer.
34
31
  module Context
35
32
  include CompiledTemplates
36
33
  attr_accessor :output_buffer
@@ -20,7 +20,6 @@ module ActionView #:nodoc:
20
20
  autoload :NumberHelper
21
21
  autoload :PrototypeHelper
22
22
  autoload :RawOutputHelper
23
- autoload :RecordIdentificationHelper
24
23
  autoload :RecordTagHelper
25
24
  autoload :SanitizeHelper
26
25
  autoload :ScriptaculousHelper
@@ -51,7 +50,6 @@ module ActionView #:nodoc:
51
50
  include NumberHelper
52
51
  include PrototypeHelper
53
52
  include RawOutputHelper
54
- include RecordIdentificationHelper
55
53
  include RecordTagHelper
56
54
  include SanitizeHelper
57
55
  include ScriptaculousHelper
@@ -4,6 +4,7 @@ require 'active_support/core_ext/enumerable'
4
4
  require 'active_support/core_ext/object/blank'
5
5
 
6
6
  module ActionView
7
+ # = Active Model Helpers
7
8
  module Helpers
8
9
  module ActiveModelHelper
9
10
  %w(input form error_messages_for error_message_on).each do |method|
@@ -35,12 +36,16 @@ module ActionView
35
36
  end
36
37
  end
37
38
 
38
- %w(tag content_tag to_date_select_tag to_datetime_select_tag to_time_select_tag).each do |meth|
39
+ %w(content_tag to_date_select_tag to_datetime_select_tag to_time_select_tag).each do |meth|
39
40
  module_eval "def #{meth}(*) error_wrapping(super) end", __FILE__, __LINE__
40
41
  end
41
42
 
43
+ def tag(type, options, *)
44
+ tag_generate_errors?(options) ? error_wrapping(super) : super
45
+ end
46
+
42
47
  def error_wrapping(html_tag)
43
- if object.respond_to?(:errors) && object.errors.respond_to?(:full_messages) && object.errors[@method_name].any?
48
+ if object_has_errors?
44
49
  Base.field_error_proc.call(html_tag, self)
45
50
  else
46
51
  html_tag
@@ -50,6 +55,16 @@ module ActionView
50
55
  def error_message
51
56
  object.errors[@method_name]
52
57
  end
58
+
59
+ private
60
+
61
+ def object_has_errors?
62
+ object.respond_to?(:errors) && object.errors.respond_to?(:full_messages) && error_message.any?
63
+ end
64
+
65
+ def tag_generate_errors?(options)
66
+ options['type'] != 'hidden'
67
+ end
53
68
  end
54
69
 
55
70
  class FormBuilder
@@ -6,6 +6,7 @@ require 'active_support/core_ext/file'
6
6
  require 'active_support/core_ext/object/blank'
7
7
 
8
8
  module ActionView
9
+ # = Action View Asset Tag Helpers
9
10
  module Helpers #:nodoc:
10
11
  # This module provides methods for generating HTML that links views to assets such
11
12
  # as images, javascripts, stylesheets, and feeds. These methods do not verify
@@ -193,7 +194,19 @@ module ActionView
193
194
  # RewriteEngine On
194
195
  # RewriteRule ^/release-\d+/(images|javascripts|stylesheets)/(.*)$ /$1/$2 [L]
195
196
  module AssetTagHelper
196
- JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls', 'rails'].freeze unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES)
197
+ mattr_reader :javascript_expansions
198
+ @@javascript_expansions = { }
199
+
200
+ mattr_reader :stylesheet_expansions
201
+ @@stylesheet_expansions = {}
202
+
203
+ # You can enable or disable the asset tag timestamps cache.
204
+ # With the cache enabled, the asset tag helper methods will make fewer
205
+ # expensive file system calls. However this prevents you from modifying
206
+ # any asset files while the server is running.
207
+ #
208
+ # ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
209
+ mattr_accessor :cache_asset_timestamps
197
210
 
198
211
  # Returns a link tag that browsers and news readers can use to auto-detect
199
212
  # an RSS or ATOM feed. The +type+ can either be <tt>:rss</tt> (default) or
@@ -350,8 +363,6 @@ module ActionView
350
363
  end
351
364
  end
352
365
 
353
- @@javascript_expansions = { :defaults => JAVASCRIPT_DEFAULT_SOURCES.dup }
354
-
355
366
  # Register one or more javascript files to be included when <tt>symbol</tt>
356
367
  # is passed to <tt>javascript_include_tag</tt>. This method is typically intended
357
368
  # to be called from plugin initialization to register javascript files
@@ -367,8 +378,6 @@ module ActionView
367
378
  @@javascript_expansions.merge!(expansions)
368
379
  end
369
380
 
370
- @@stylesheet_expansions = {}
371
-
372
381
  # Register one or more stylesheet files to be included when <tt>symbol</tt>
373
382
  # is passed to <tt>stylesheet_link_tag</tt>. This method is typically intended
374
383
  # to be called from plugin initialization to register stylesheet files
@@ -384,18 +393,6 @@ module ActionView
384
393
  @@stylesheet_expansions.merge!(expansions)
385
394
  end
386
395
 
387
- # Register one or more additional JavaScript files to be included when
388
- # <tt>javascript_include_tag :defaults</tt> is called. This method is
389
- # typically intended to be called from plugin initialization to register additional
390
- # .js files that the plugin installed in <tt>public/javascripts</tt>.
391
- def self.register_javascript_include_default(*sources)
392
- @@javascript_expansions[:defaults].concat(sources)
393
- end
394
-
395
- def self.reset_javascript_include_default #:nodoc:
396
- @@javascript_expansions[:defaults] = JAVASCRIPT_DEFAULT_SOURCES.dup
397
- end
398
-
399
396
  # Computes the path to a stylesheet asset in the public stylesheets directory.
400
397
  # If the +source+ filename has no extension, <tt>.css</tt> will be appended (except for explicit URIs).
401
398
  # Full paths from the document root will be passed through.
@@ -706,23 +703,8 @@ module ActionView
706
703
  tag("audio", options)
707
704
  end
708
705
 
709
- def self.cache_asset_timestamps
710
- @@cache_asset_timestamps
711
- end
712
-
713
- # You can enable or disable the asset tag timestamps cache.
714
- # With the cache enabled, the asset tag helper methods will make fewer
715
- # expensive file system calls. However this prevents you from modifying
716
- # any asset files while the server is running.
717
- #
718
- # ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
719
- def self.cache_asset_timestamps=(value)
720
- @@cache_asset_timestamps = value
721
- end
722
-
723
- @@cache_asset_timestamps = true
724
-
725
706
  private
707
+
726
708
  def rewrite_extension?(source, dir, ext)
727
709
  source_ext = File.extname(source)[1..-1]
728
710
  ext && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(config.assets_dir, dir, "#{source}.#{ext}"))))
@@ -1,14 +1,16 @@
1
1
  require 'set'
2
2
 
3
- # Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
4
- # template languages).
5
3
  module ActionView
4
+ # = Action View Atom Feed Helpers
6
5
  module Helpers #:nodoc:
7
6
  module AtomFeedHelper
7
+ # Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
8
+ # template languages).
9
+ #
8
10
  # Full usage example:
9
11
  #
10
12
  # config/routes.rb:
11
- # Basecamp::Application.routes.draw do |map|
13
+ # Basecamp::Application.routes.draw do
12
14
  # resources :posts
13
15
  # root :to => "posts#index"
14
16
  # end
@@ -1,8 +1,10 @@
1
1
  module ActionView
2
+ # = Action View Cache Helper
2
3
  module Helpers
3
- # This helper to exposes a method for caching of view fragments.
4
- # See ActionController::Caching::Fragments for usage instructions.
5
4
  module CacheHelper
5
+ # This helper to exposes a method for caching of view fragments.
6
+ # See ActionController::Caching::Fragments for usage instructions.
7
+ #
6
8
  # A method for caching fragments of a view rather than an entire
7
9
  # action or page. This technique is useful caching pieces like
8
10
  # menus, lists of news topics, static HTML fragments, and so on.