radiant 0.6.3 → 0.6.4

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

Potentially problematic release.


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

Files changed (197) hide show
  1. data/CHANGELOG +61 -7
  2. data/CONTRIBUTORS +15 -0
  3. data/app/controllers/admin/export_controller.rb +1 -1
  4. data/app/controllers/admin/page_controller.rb +1 -0
  5. data/app/controllers/admin/user_controller.rb +2 -1
  6. data/app/controllers/application.rb +7 -8
  7. data/app/helpers/admin/node_helper.rb +84 -0
  8. data/app/helpers/admin/page_helper.rb +1 -19
  9. data/app/helpers/application_helper.rb +15 -9
  10. data/app/models/file_not_found_page.rb +2 -2
  11. data/app/models/page.rb +22 -18
  12. data/app/models/page_context.rb +9 -0
  13. data/app/models/radiant/config.rb +4 -2
  14. data/app/models/response_cache.rb +18 -12
  15. data/app/models/standard_tags.rb +111 -50
  16. data/app/views/admin/extension/index.rhtml +2 -2
  17. data/app/views/admin/layout/edit.rhtml +2 -2
  18. data/app/views/admin/layout/remove.rhtml +2 -2
  19. data/app/views/admin/page/_node.rhtml +4 -26
  20. data/app/views/admin/page/_part.rhtml +9 -14
  21. data/app/views/admin/page/edit.rhtml +38 -121
  22. data/app/views/admin/page/index.rhtml +2 -6
  23. data/app/views/admin/page/remove.rhtml +2 -2
  24. data/app/views/admin/snippet/edit.rhtml +3 -3
  25. data/app/views/admin/snippet/index.rhtml +2 -2
  26. data/app/views/admin/snippet/remove.rhtml +2 -2
  27. data/app/views/admin/user/edit.rhtml +4 -4
  28. data/app/views/admin/user/preferences.rhtml +2 -2
  29. data/app/views/admin/welcome/login.rhtml +1 -1
  30. data/config/environment.rb +79 -78
  31. data/db/schema.rb +2 -0
  32. data/lib/local_time.rb +12 -0
  33. data/lib/plugins/extension_patches/lib/fixture_loading_extension.rb +1 -1
  34. data/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb +3 -3
  35. data/lib/radiant.rb +1 -1
  36. data/lib/radiant/extension.rb +9 -3
  37. data/lib/radiant/extension_loader.rb +2 -2
  38. data/lib/tasks/extensions.rake +23 -8
  39. data/public/javascripts/admin.js +89 -0
  40. data/public/javascripts/controls.js +486 -354
  41. data/public/javascripts/dragdrop.js +90 -58
  42. data/public/javascripts/effects.js +398 -364
  43. data/public/javascripts/pngfix.js +37 -37
  44. data/public/javascripts/prototype.js +2764 -1095
  45. data/public/javascripts/ruledtable.js +10 -25
  46. data/public/javascripts/sitemap.js +74 -112
  47. data/public/javascripts/string.js +1 -7
  48. data/public/javascripts/tabcontrol.js +71 -86
  49. data/public/javascripts/tag_reference_search.js +19 -26
  50. data/public/stylesheets/admin/main.css +11 -5
  51. data/test/fixtures/extensions/01_basic/lib/new_module.rb +2 -0
  52. data/test/fixtures/page_parts.yml +16 -1
  53. data/test/fixtures/pages.yml +47 -84
  54. data/test/functional/extension_initialization_test.rb +11 -0
  55. data/test/helpers/login_test_helper.rb +12 -1
  56. data/test/helpers/page_test_helper.rb +6 -0
  57. data/test/helpers/render_test_helper.rb +11 -8
  58. data/test/test_helper.rb +1 -12
  59. data/test/unit/file_not_found_page_test.rb +5 -1
  60. data/test/unit/local_time_test.rb +45 -0
  61. data/test/unit/page_context_test.rb +32 -1
  62. data/test/unit/page_test.rb +45 -11
  63. data/test/unit/radiant/config_test.rb +1 -1
  64. data/test/unit/response_cache_test.rb +27 -2
  65. data/test/unit/standard_tags_test.rb +60 -15
  66. data/vendor/extensions/archive/README +29 -0
  67. data/vendor/extensions/archive/Rakefile +25 -0
  68. data/{app → vendor/extensions/archive/app}/models/archive_day_index_page.rb +0 -0
  69. data/{app → vendor/extensions/archive/app}/models/archive_finder.rb +8 -6
  70. data/{app → vendor/extensions/archive/app}/models/archive_month_index_page.rb +0 -0
  71. data/{app → vendor/extensions/archive/app}/models/archive_page.rb +0 -0
  72. data/{app → vendor/extensions/archive/app}/models/archive_year_index_page.rb +0 -0
  73. data/vendor/extensions/archive/archive_extension.rb +19 -0
  74. data/{lib → vendor/extensions/archive/lib}/archive_index_tags_and_methods.rb +0 -0
  75. data/vendor/extensions/archive/lib/tasks/archive_extension_tasks.rake +28 -0
  76. data/vendor/extensions/archive/test/fixtures/pages.yml +397 -0
  77. data/vendor/extensions/archive/test/functional/archive_extension_test.rb +16 -0
  78. data/{test → vendor/extensions/archive/test}/helpers/archive_index_test_helper.rb +0 -0
  79. data/vendor/extensions/archive/test/test_helper.rb +19 -0
  80. data/{test → vendor/extensions/archive/test}/unit/archive_day_index_page_test.rb +0 -0
  81. data/{test → vendor/extensions/archive/test}/unit/archive_month_index_page_test.rb +0 -0
  82. data/{test → vendor/extensions/archive/test}/unit/archive_page_test.rb +7 -1
  83. data/{test → vendor/extensions/archive/test}/unit/archive_year_index_page_test.rb +0 -0
  84. data/vendor/rails/actionmailer/CHANGELOG +10 -0
  85. data/vendor/rails/actionmailer/Rakefile +1 -1
  86. data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
  87. data/vendor/rails/actionpack/CHANGELOG +51 -2
  88. data/vendor/rails/actionpack/Rakefile +1 -1
  89. data/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +2 -2
  90. data/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +1 -1
  91. data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +3 -0
  92. data/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +1 -0
  93. data/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +2 -0
  94. data/vendor/rails/actionpack/lib/action_controller/base.rb +7 -1
  95. data/vendor/rails/actionpack/lib/action_controller/caching.rb +39 -38
  96. data/vendor/rails/actionpack/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
  97. data/vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
  98. data/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +13 -4
  99. data/vendor/rails/actionpack/lib/action_controller/cookies.rb +5 -3
  100. data/vendor/rails/actionpack/lib/action_controller/filters.rb +176 -77
  101. data/vendor/rails/actionpack/lib/action_controller/integration.rb +31 -21
  102. data/vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb +1 -1
  103. data/vendor/rails/actionpack/lib/action_controller/pagination.rb +7 -1
  104. data/vendor/rails/actionpack/lib/action_controller/resources.rb +117 -32
  105. data/vendor/rails/actionpack/lib/action_controller/routing.rb +56 -23
  106. data/vendor/rails/actionpack/lib/action_controller/test_process.rb +5 -2
  107. data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +4 -1
  108. data/vendor/rails/actionpack/lib/action_controller/verification.rb +1 -0
  109. data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
  110. data/vendor/rails/actionpack/lib/action_view/base.rb +25 -19
  111. data/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +2 -2
  112. data/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +18 -18
  113. data/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +10 -0
  114. data/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb +3 -0
  115. data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +33 -17
  116. data/vendor/rails/actionpack/test/activerecord/pagination_test.rb +9 -0
  117. data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +13 -0
  118. data/vendor/rails/actionpack/test/controller/addresses_render_test.rb +4 -1
  119. data/vendor/rails/actionpack/test/controller/base_test.rb +1 -1
  120. data/vendor/rails/actionpack/test/controller/caching_test.rb +3 -2
  121. data/vendor/rails/actionpack/test/controller/cookie_test.rb +11 -0
  122. data/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
  123. data/vendor/rails/actionpack/test/controller/filter_params_test.rb +1 -0
  124. data/vendor/rails/actionpack/test/controller/filters_test.rb +149 -26
  125. data/vendor/rails/actionpack/test/controller/integration_test.rb +93 -8
  126. data/vendor/rails/actionpack/test/controller/resources_test.rb +215 -36
  127. data/vendor/rails/actionpack/test/controller/routing_test.rb +2 -2
  128. data/vendor/rails/actionpack/test/controller/test_test.rb +16 -0
  129. data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +66 -10
  130. data/vendor/rails/actionpack/test/controller/verification_test.rb +15 -0
  131. data/vendor/rails/actionpack/test/fixtures/test/hello_world.rxml +2 -1
  132. data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +5 -0
  133. data/vendor/rails/actionpack/test/template/compiled_templates_test.rb +29 -17
  134. data/vendor/rails/actionpack/test/template/javascript_helper_test.rb +4 -4
  135. data/vendor/rails/actionpack/test/template/number_helper_test.rb +1 -1
  136. data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +13 -13
  137. data/vendor/rails/actionwebservice/CHANGELOG +14 -0
  138. data/vendor/rails/actionwebservice/Rakefile +2 -2
  139. data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +1 -1
  140. data/vendor/rails/activerecord/CHANGELOG +34 -0
  141. data/vendor/rails/activerecord/Rakefile +1 -1
  142. data/vendor/rails/activerecord/lib/active_record/acts/list.rb +14 -2
  143. data/vendor/rails/activerecord/lib/active_record/acts/tree.rb +7 -0
  144. data/vendor/rails/activerecord/lib/active_record/associations.rb +29 -14
  145. data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +5 -1
  146. data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +2 -2
  147. data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +10 -0
  148. data/vendor/rails/activerecord/lib/active_record/base.rb +12 -3
  149. data/vendor/rails/activerecord/lib/active_record/calculations.rb +2 -2
  150. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
  151. data/vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
  152. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +2 -2
  153. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +54 -38
  154. data/vendor/rails/activerecord/lib/active_record/deprecated_finders.rb +3 -3
  155. data/vendor/rails/activerecord/lib/active_record/fixtures.rb +1 -1
  156. data/vendor/rails/activerecord/lib/active_record/timestamp.rb +0 -9
  157. data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
  158. data/vendor/rails/activerecord/test/associations/eager_test.rb +13 -0
  159. data/vendor/rails/activerecord/test/associations/join_model_test.rb +10 -1
  160. data/vendor/rails/activerecord/test/associations_test.rb +36 -3
  161. data/vendor/rails/activerecord/test/base_test.rb +17 -4
  162. data/vendor/rails/activerecord/test/defaults_test.rb +15 -0
  163. data/vendor/rails/activerecord/test/fixtures/author.rb +1 -0
  164. data/vendor/rails/activerecord/test/fixtures/binaries.yml +437 -0
  165. data/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +13 -0
  166. data/vendor/rails/activerecord/test/fixtures/developer.rb +10 -0
  167. data/vendor/rails/activerecord/test/fixtures_test.rb +9 -5
  168. data/vendor/rails/activerecord/test/migration_test.rb +9 -10
  169. data/vendor/rails/activerecord/test/mixin_test.rb +47 -0
  170. data/vendor/rails/activerecord/test/validations_test.rb +2 -2
  171. data/vendor/rails/activesupport/CHANGELOG +16 -0
  172. data/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +9 -3
  173. data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +48 -3
  174. data/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +14 -0
  175. data/vendor/rails/activesupport/lib/active_support/dependencies.rb +3 -3
  176. data/vendor/rails/activesupport/lib/active_support/json/encoders/core.rb +5 -3
  177. data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +6 -6
  178. data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
  179. data/vendor/rails/activesupport/test/core_ext/hash_ext_test.rb +37 -0
  180. data/vendor/rails/activesupport/test/core_ext/module_test.rb +8 -0
  181. data/vendor/rails/activesupport/test/dependencies_test.rb +11 -0
  182. data/vendor/rails/activesupport/test/{json.rb → json_test.rb} +15 -5
  183. data/vendor/rails/railties/CHANGELOG +25 -1
  184. data/vendor/rails/railties/README +32 -3
  185. data/vendor/rails/railties/Rakefile +5 -5
  186. data/vendor/rails/railties/environments/boot.rb +12 -18
  187. data/vendor/rails/railties/environments/environment.rb +15 -15
  188. data/vendor/rails/railties/lib/dispatcher.rb +1 -2
  189. data/vendor/rails/railties/lib/initializer.rb +33 -9
  190. data/vendor/rails/railties/lib/rails/version.rb +1 -1
  191. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -1
  192. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +1 -0
  193. data/vendor/rails/railties/lib/railties_path.rb +1 -1
  194. data/vendor/rails/railties/lib/tasks/framework.rake +4 -4
  195. data/vendor/rails/railties/lib/tasks/routes.rake +17 -0
  196. data/vendor/rails/release.rb +2 -2
  197. metadata +1877 -1848
@@ -24,6 +24,7 @@ module ActionController #:nodoc:
24
24
  attr_accessor :cookies, :session_options
25
25
  attr_accessor :query_parameters, :request_parameters, :path, :session, :env
26
26
  attr_accessor :host
27
+ attr_reader :request_uri_overridden
27
28
 
28
29
  def initialize(query_parameters = nil, request_parameters = nil, session = nil)
29
30
  @query_parameters = query_parameters || {}
@@ -67,12 +68,14 @@ module ActionController #:nodoc:
67
68
  # Used to check AbstractRequest's request_uri functionality.
68
69
  # Disables the use of @path and @request_uri so superclass can handle those.
69
70
  def set_REQUEST_URI(value)
71
+ @request_uri_overridden = true
70
72
  @env["REQUEST_URI"] = value
71
73
  @request_uri = nil
72
74
  @path = nil
73
75
  end
74
76
 
75
77
  def request_uri=(uri)
78
+ @env["REQUEST_URI"] = uri
76
79
  @request_uri = uri
77
80
  @path = uri.split("?").first
78
81
  end
@@ -426,12 +429,12 @@ module ActionController #:nodoc:
426
429
  end
427
430
 
428
431
  def build_request_uri(action, parameters)
429
- unless @request.env['REQUEST_URI']
432
+ unless @request.request_uri_overridden
430
433
  options = @controller.send(:rewrite_options, parameters)
431
434
  options.update(:only_path => true, :action => action)
432
435
 
433
436
  url = ActionController::UrlRewriter.new(@request, parameters)
434
- @request.set_REQUEST_URI(url.rewrite(options))
437
+ @request.request_uri = url.rewrite(options)
435
438
  end
436
439
  end
437
440
 
@@ -52,8 +52,9 @@ module ActionController
52
52
  # Delete the unused options to prevent their appearance in the query string
53
53
  [:protocol, :host, :port].each { |k| options.delete k }
54
54
  end
55
+ anchor = "##{options.delete(:anchor)}" if options.key?(:anchor)
55
56
  url << Routing::Routes.generate(options, {})
56
- return url
57
+ return "#{url}#{anchor}"
57
58
  end
58
59
 
59
60
  end
@@ -76,6 +77,7 @@ module ActionController
76
77
  alias_method :to_s, :to_str
77
78
 
78
79
  private
80
+ # Given a path and options, returns a rewritten URL string
79
81
  def rewrite_url(path, options)
80
82
  rewritten_url = ""
81
83
  unless options[:only_path]
@@ -91,6 +93,7 @@ module ActionController
91
93
  rewritten_url
92
94
  end
93
95
 
96
+ # Given a Hash of options, generates a route
94
97
  def rewrite_path(options)
95
98
  options = options.symbolize_keys
96
99
  options.update(options[:params].symbolize_keys) if options[:params]
@@ -95,6 +95,7 @@ module ActionController #:nodoc:
95
95
  response.headers.update(options[:add_headers]) if options[:add_headers]
96
96
  unless performed?
97
97
  render(options[:render]) if options[:render]
98
+ options[:redirect_to] = self.send(options[:redirect_to]) if options[:redirect_to].is_a? Symbol
98
99
  redirect_to(options[:redirect_to]) if options[:redirect_to]
99
100
  end
100
101
  return false
@@ -2,7 +2,7 @@ module ActionPack #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 13
5
- TINY = 3
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -148,7 +148,7 @@ module ActionView #:nodoc:
148
148
  #
149
149
  # This refreshes the sidebar, removes a person element and highlights the user list.
150
150
  #
151
- # See the ActionView::Helpers::PrototypeHelper::JavaScriptGenerator documentation for more details.
151
+ # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
152
152
  class Base
153
153
  include ERB::Util
154
154
 
@@ -160,7 +160,7 @@ module ActionView #:nodoc:
160
160
  attr_internal *ActionController::Base::DEPRECATED_INSTANCE_VARIABLES
161
161
 
162
162
  # Specify trim mode for the ERB compiler. Defaults to '-'.
163
- # See ERB documentation for suitable values.
163
+ # See ERb documentation for suitable values.
164
164
  @@erb_trim_mode = '-'
165
165
  cattr_accessor :erb_trim_mode
166
166
 
@@ -191,17 +191,17 @@ module ActionView #:nodoc:
191
191
  end
192
192
  include CompiledTemplates
193
193
 
194
- # maps inline templates to their method names
194
+ # Maps inline templates to their method names
195
195
  @@method_names = {}
196
- # map method names to their compile time
196
+ # Map method names to their compile time
197
197
  @@compile_time = {}
198
- # map method names to the names passed in local assigns so far
198
+ # Map method names to the names passed in local assigns so far
199
199
  @@template_args = {}
200
- # count the number of inline templates
200
+ # Count the number of inline templates
201
201
  @@inline_template_count = 0
202
- # maps template paths without extension to their file extension returned by pick_template_extension.
203
- # if for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions
204
- # used by pick_template_extension determines whether ext1 or ext2 will be stored
202
+ # Maps template paths without extension to their file extension returned by pick_template_extension.
203
+ # If for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions
204
+ # used by pick_template_extension determines whether ext1 or ext2 will be stored.
205
205
  @@cached_template_extension = {}
206
206
 
207
207
  class ObjectWrapper < Struct.new(:value) #:nodoc:
@@ -305,7 +305,6 @@ module ActionView #:nodoc:
305
305
  # Render the provided template with the given local assigns. If the template has not been rendered with the provided
306
306
  # local assigns yet, or if the template has been updated on disk, then the template will be compiled to a method.
307
307
  #
308
-
309
308
  # Either, but not both, of template and file_path may be nil. If file_path is given, the template
310
309
  # will only be read if it has to be compiled.
311
310
  #
@@ -371,10 +370,12 @@ module ActionView #:nodoc:
371
370
  end
372
371
 
373
372
  private
373
+ # Builds a string holding the full path of the template including extension
374
374
  def full_template_path(template_path, extension)
375
375
  "#{@base_path}/#{template_path}.#{extension}"
376
376
  end
377
377
 
378
+ # Asserts the existence of a template.
378
379
  def template_exists?(template_path, extension)
379
380
  file_path = full_template_path(template_path, extension)
380
381
  @@method_names.has_key?(file_path) || FileTest.exists?(file_path)
@@ -389,6 +390,7 @@ module ActionView #:nodoc:
389
390
  @@cache_template_extensions && @@cached_template_extension[template_path]
390
391
  end
391
392
 
393
+ # Determines the template's file extension, such as rhtml, rxml, or rjs.
392
394
  def find_template_extension_for(template_path)
393
395
  if match = delegate_template_exists?(template_path)
394
396
  match.first.to_sym
@@ -405,6 +407,7 @@ module ActionView #:nodoc:
405
407
  File.read(template_path)
406
408
  end
407
409
 
410
+ # Evaluate the local assigns and pushes them to the view.
408
411
  def evaluate_assigns
409
412
  unless @assigns_added
410
413
  assign_variables_from_controller
@@ -416,6 +419,7 @@ module ActionView #:nodoc:
416
419
  handler.new(self).render(template, local_assigns)
417
420
  end
418
421
 
422
+ # Assigns instance variables from the controller to the view.
419
423
  def assign_variables_from_controller
420
424
  @assigns.each { |key, value| instance_variable_set("@#{key}", value) }
421
425
  end
@@ -427,10 +431,10 @@ module ActionView #:nodoc:
427
431
  ((args = @@template_args[render_symbol]) && local_assigns.all? { |k,_| args.has_key?(k) })
428
432
  end
429
433
 
430
- # Check whether compilation is necessary.
431
- # Compile if the inline template or file has not been compiled yet.
432
- # Or if local_assigns has a new key, which isn't supported by the compiled code yet.
433
- # Or if the file has changed on disk and checking file mods hasn't been disabled.
434
+ # Method to check whether template compilation is necessary.
435
+ # The template will be compiled if the inline template or file has not been compiled yet,
436
+ # if local_assigns has a new key, which isn't supported by the compiled code yet,
437
+ # or if the file has changed on disk and checking file mods hasn't been disabled.
434
438
  def compile_template?(template, file_name, local_assigns)
435
439
  method_key = file_name || template
436
440
  render_symbol = @@method_names[method_key]
@@ -445,14 +449,15 @@ module ActionView #:nodoc:
445
449
  end
446
450
  end
447
451
 
448
- # Create source code for given template
452
+ # Method to create the source code for a given template.
449
453
  def create_template_source(extension, template, render_symbol, locals)
450
454
  if template_requires_setup?(extension)
451
455
  body = case extension.to_sym
452
456
  when :rxml
453
457
  "controller.response.content_type ||= 'application/xml'\n" +
454
- "xml = Builder::XmlMarkup.new(:indent => 2)\n" +
455
- template
458
+ "xml ||= Builder::XmlMarkup.new(:indent => 2)\n" +
459
+ template +
460
+ "\nxml.target!\n"
456
461
  when :rjs
457
462
  "controller.response.content_type ||= 'text/javascript'\n" +
458
463
  "update_page do |page|\n#{template}\nend"
@@ -473,11 +478,11 @@ module ActionView #:nodoc:
473
478
  "def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend"
474
479
  end
475
480
 
476
- def template_requires_setup?(extension)
481
+ def template_requires_setup?(extension) #:nodoc:
477
482
  templates_requiring_setup.include? extension.to_s
478
483
  end
479
484
 
480
- def templates_requiring_setup
485
+ def templates_requiring_setup #:nodoc:
481
486
  %w(rxml rjs)
482
487
  end
483
488
 
@@ -501,6 +506,7 @@ module ActionView #:nodoc:
501
506
  end
502
507
  end
503
508
 
509
+ # Compile and evaluate the template's code
504
510
  def compile_template(extension, template, file_name, local_assigns)
505
511
  render_symbol = assign_method_name(extension, template, file_name)
506
512
  render_source = create_template_source(extension, template, render_symbol, local_assigns.keys)
@@ -3,14 +3,14 @@ module ActionView
3
3
 
4
4
  # CompiledTemplates modules hold methods that have been compiled.
5
5
  # Templates are compiled into these methods so that they do not need to be
6
- # re-read and re-parsed each request.
6
+ # read and parsed for each request.
7
7
  #
8
8
  # Each template may be compiled into one or more methods. Each method accepts a given
9
9
  # set of parameters which is used to implement local assigns passing.
10
10
  #
11
11
  # To use a compiled template module, create a new instance and include it into the class
12
12
  # in which you want the template to be rendered.
13
- class CompiledTemplates < Module #:nodoc:
13
+ class CompiledTemplates < Module
14
14
  attr_reader :method_names
15
15
 
16
16
  def initialize
@@ -13,17 +13,18 @@ module ActionView
13
13
  # is a great of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form.
14
14
  # In that case, it's better to use the input method and the specialized form methods in link:classes/ActionView/Helpers/FormHelper.html
15
15
  module ActiveRecordHelper
16
- # Returns a default input tag for the type of object returned by the method. Example
17
- # (title is a VARCHAR column and holds "Hello World"):
16
+ # Returns a default input tag for the type of object returned by the method. For example, let's say you have a model
17
+ # that has an attribute +title+ of type VARCHAR column, and this instance holds "Hello World":
18
18
  # input("post", "title") =>
19
19
  # <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
20
20
  def input(record_name, method, options = {})
21
21
  InstanceTag.new(record_name, method, self).to_tag(options)
22
22
  end
23
23
 
24
- # Returns an entire form with input tags and everything for a specified Active Record object. Example
25
- # (post is a new record that has a title using VARCHAR and a body using TEXT):
26
- # form("post") =>
24
+ # Returns an entire form with all needed input tags for a specified Active Record object. For example, let's say you
25
+ # have a table model <tt>Post</tt> with attributes named <tt>title</tt> of type <tt>VARCHAR</tt> and <tt>body</tt> of type <tt>TEXT</tt>:
26
+ # form("post")
27
+ # That line would yield a form like the following:
27
28
  # <form action='/post/create' method='post'>
28
29
  # <p>
29
30
  # <label for="post_title">Title</label><br />
@@ -32,14 +33,13 @@ module ActionView
32
33
  # <p>
33
34
  # <label for="post_body">Body</label><br />
34
35
  # <textarea cols="40" id="post_body" name="post[body]" rows="20">
35
- # Back to the hill and over it again!
36
36
  # </textarea>
37
37
  # </p>
38
38
  # <input type='submit' value='Create' />
39
39
  # </form>
40
40
  #
41
41
  # It's possible to specialize the form builder by using a different action name and by supplying another
42
- # block renderer. Example (entry is a new record that has a message attribute using VARCHAR):
42
+ # block renderer. For example, let's say you have a model <tt>Entry</tt> with an attribute <tt>message</tt> of type <tt>VARCHAR</tt>:
43
43
  #
44
44
  # form("entry", :action => "sign", :input_block =>
45
45
  # Proc.new { |record, column| "#{column.human_name}: #{input(record, column.name)}<br />" }) =>
@@ -74,16 +74,16 @@ module ActionView
74
74
  content_tag('form', contents, :action => action, :method => 'post', :enctype => options[:multipart] ? 'multipart/form-data': nil)
75
75
  end
76
76
 
77
- # Returns a string containing the error message attached to the +method+ on the +object+, if one exists.
78
- # This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+
79
- # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message
80
- # "can't be empty" on the title attribute):
77
+ # Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
78
+ # This error message is wrapped in a <tt>DIV</tt> tag, which can be extended to include a +prepend_text+ and/or +append_text+
79
+ # (to properly explain the error), and a +css_class+ to style it accordingly. As an example, let's say you have a model
80
+ # +post+ that has an error message on the +title+ attribute:
81
81
  #
82
82
  # <%= error_message_on "post", "title" %> =>
83
83
  # <div class="formError">can't be empty</div>
84
84
  #
85
- # <%= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" %> =>
86
- # <div class="inputError">Title simply can't be empty (or it won't work)</div>
85
+ # <%= error_message_on "post", "title", "Title simply ", " (or it won't work).", "inputError" %> =>
86
+ # <div class="inputError">Title simply can't be empty (or it won't work).</div>
87
87
  def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError")
88
88
  if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method))
89
89
  content_tag("div", "#{prepend_text}#{errors.is_a?(Array) ? errors.first : errors}#{append_text}", :class => css_class)
@@ -92,11 +92,11 @@ module ActionView
92
92
  end
93
93
  end
94
94
 
95
- # Returns a string with a div containing all of the error messages for the objects located as instance variables by the names
95
+ # Returns a string with a <tt>DIV</tt> containing all of the error messages for the objects located as instance variables by the names
96
96
  # given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are
97
97
  # provided.
98
98
  #
99
- # This div can be tailored by the following options:
99
+ # This <tt>DIV</tt> can be tailored by the following options:
100
100
  #
101
101
  # * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
102
102
  # * <tt>id</tt> - The id of the error div (default: errorExplanation)
@@ -105,12 +105,12 @@ module ActionView
105
105
  # any text that you prefer. If <tt>object_name</tt> is not set, the name of
106
106
  # the first object will be used.
107
107
  #
108
- # Specifying one object:
108
+ # To specify the display for one object, you simply provide its name as a parameter. For example, for the +User+ model:
109
109
  #
110
110
  # error_messages_for 'user'
111
111
  #
112
- # Specifying more than one object (and using the name 'user' in the
113
- # header as the <tt>object_name</tt> instead of 'user_common'):
112
+ # To specify more than one object, you simply list them; optionally, you can add an extra +object_name+ parameter, which
113
+ # be the name in the header.
114
114
  #
115
115
  # error_messages_for 'user_common', 'user', :object_name => 'user'
116
116
  #
@@ -3,6 +3,16 @@ module ActionView
3
3
  # Provides a set of methods for making it easier to locate problems.
4
4
  module DebugHelper
5
5
  # Returns a <pre>-tag set with the +object+ dumped by YAML. Very readable way to inspect an object.
6
+ # my_hash = {'first' => 1, 'second' => 'two', 'third' => [1,2,3]}
7
+ # debug(my_hash)
8
+ # => <pre class='debug_dump'>---
9
+ # first: 1
10
+ # second: two
11
+ # third:
12
+ # - 1
13
+ # - 2
14
+ # - 3
15
+ # </pre>
6
16
  def debug(object)
7
17
  begin
8
18
  Marshal::dump(object)
@@ -2,6 +2,9 @@ module ActionView
2
2
  module Helpers
3
3
  module PrototypeHelper
4
4
 
5
+ # Method to execute an element update using Prototype.
6
+ # DEPRECATION WARNING: This helper has been depercated; use RJS instead.
7
+ # See ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods for more information.
5
8
  def update_element_function(element_id, options = {}, &block)
6
9
  content = escape_javascript(options[:content] || '')
7
10
  content = escape_javascript(capture(&block)) if block
@@ -250,8 +250,10 @@ module ActionView
250
250
  return function
251
251
  end
252
252
 
253
- # Observes the field with the DOM ID specified by +field_id+ and makes
254
- # an Ajax call when its contents have changed.
253
+ # Observes the field with the DOM ID specified by +field_id+ and calls a
254
+ # callback when its contents have changed. The default callback is an
255
+ # Ajax call. By default the value of the observed field is sent as a
256
+ # parameter with the Ajax call.
255
257
  #
256
258
  # Required +options+ are either of:
257
259
  # <tt>:url</tt>:: +url_for+-style options for the action to call
@@ -268,14 +270,24 @@ module ActionView
268
270
  # <tt>:update</tt>:: Specifies the DOM ID of the element whose
269
271
  # innerHTML should be updated with the
270
272
  # XMLHttpRequest response text.
271
- # <tt>:with</tt>:: A JavaScript expression specifying the
272
- # parameters for the XMLHttpRequest. This defaults
273
- # to 'value', which in the evaluated context
274
- # refers to the new field value. If you specify a
275
- # string without a "=", it'll be extended to mean
276
- # the form key that the value should be assigned to.
277
- # So :with => "term" gives "'term'=value". If a "=" is
278
- # present, no extension will happen.
273
+ # <tt>:with</tt>:: A JavaScript expression specifying the parameters
274
+ # for the XMLHttpRequest. The default is to send the
275
+ # key and value of the observed field. Any custom
276
+ # expressions should return a valid URL query string.
277
+ # The value of the field is stored in the JavaScript
278
+ # variable +value+.
279
+ #
280
+ # Examples
281
+ #
282
+ # :with => "'my_custom_key=' + value"
283
+ # :with => "'person[name]=' + prompt('New name')"
284
+ # :with => "Form.Element.serialize('other-field')"
285
+ #
286
+ # Finally
287
+ # :with => 'name'
288
+ # is shorthand for
289
+ # :with => "'name=' + value"
290
+ # This essentially just changes the key of the parameter.
279
291
  # <tt>:on</tt>:: Specifies which event handler to observe. By default,
280
292
  # it's set to "changed" for text fields and areas and
281
293
  # "click" for radio buttons and checkboxes. With this,
@@ -291,11 +303,15 @@ module ActionView
291
303
  build_observer('Form.Element.EventObserver', field_id, options)
292
304
  end
293
305
  end
294
-
295
- # Like +observe_field+, but operates on an entire form identified by the
296
- # DOM ID +form_id+. +options+ are the same as +observe_field+, except
297
- # the default value of the <tt>:with</tt> option evaluates to the
298
- # serialized (request string) value of the form.
306
+
307
+ # Observes the form with the DOM ID specified by +form_id+ and calls a
308
+ # callback when its contents have changed. The default callback is an
309
+ # Ajax call. By default all fields of the observed field are sent as
310
+ # parameters with the Ajax call.
311
+ #
312
+ # The +options+ for +observe_form+ are the same as the options for
313
+ # +observe_field+. The JavaScript variable +value+ available to the
314
+ # <tt>:with</tt> option is set to the serialized form by default.
299
315
  def observe_form(form_id, options = {})
300
316
  if options[:frequency]
301
317
  build_observer('Form.Observer', form_id, options)
@@ -660,10 +676,10 @@ module ActionView
660
676
  end
661
677
 
662
678
  def build_observer(klass, name, options = {})
663
- if options[:with] && !options[:with].include?("=")
679
+ if options[:with] && (options[:with] !~ /[=(.]/)
664
680
  options[:with] = "'#{options[:with]}=' + value"
665
681
  else
666
- options[:with] ||= 'value' if options[:update]
682
+ options[:with] ||= 'value' unless options[:function]
667
683
  end
668
684
 
669
685
  callback = options[:function] || remote_function(options)
@@ -5,6 +5,8 @@ class PaginationTest < ActiveRecordTestCase
5
5
 
6
6
  class PaginationController < ActionController::Base
7
7
  self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
8
+
9
+ around_filter :silence_deprecation_warnings
8
10
 
9
11
  def simple_paginate
10
12
  @topic_pages, @topics = paginate(:topics)
@@ -67,6 +69,13 @@ class PaginationTest < ActiveRecordTestCase
67
69
  :count => "d.id")
68
70
  render :nothing => true
69
71
  end
72
+
73
+
74
+ def silence_deprecation_warnings
75
+ ActiveSupport::Deprecation.silence do
76
+ yield
77
+ end
78
+ end
70
79
 
71
80
  def rescue_errors(e) raise e end
72
81