actionpack 4.0.13 → 4.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +131 -1636
  3. data/README.rdoc +1 -6
  4. data/lib/abstract_controller.rb +1 -2
  5. data/lib/abstract_controller/base.rb +3 -25
  6. data/lib/abstract_controller/callbacks.rb +4 -2
  7. data/lib/abstract_controller/collector.rb +11 -1
  8. data/lib/abstract_controller/helpers.rb +18 -15
  9. data/lib/abstract_controller/rendering.rb +48 -127
  10. data/lib/action_controller.rb +1 -17
  11. data/lib/action_controller/base.rb +14 -6
  12. data/lib/action_controller/caching.rb +1 -11
  13. data/lib/action_controller/log_subscriber.rb +1 -1
  14. data/lib/action_controller/metal.rb +0 -4
  15. data/lib/action_controller/metal/flash.rb +17 -0
  16. data/lib/action_controller/metal/force_ssl.rb +1 -1
  17. data/lib/action_controller/metal/head.rb +1 -3
  18. data/lib/action_controller/metal/helpers.rb +6 -2
  19. data/lib/action_controller/metal/http_authentication.rb +7 -14
  20. data/lib/action_controller/metal/instrumentation.rb +1 -1
  21. data/lib/action_controller/metal/live.rb +74 -0
  22. data/lib/action_controller/metal/mime_responds.rb +93 -16
  23. data/lib/action_controller/metal/params_wrapper.rb +4 -11
  24. data/lib/action_controller/metal/rack_delegation.rb +1 -1
  25. data/lib/action_controller/metal/redirecting.rb +20 -20
  26. data/lib/action_controller/metal/renderers.rb +8 -5
  27. data/lib/action_controller/metal/rendering.rb +14 -11
  28. data/lib/action_controller/metal/request_forgery_protection.rb +67 -13
  29. data/lib/action_controller/metal/responder.rb +12 -2
  30. data/lib/action_controller/metal/streaming.rb +18 -20
  31. data/lib/action_controller/metal/strong_parameters.rb +22 -34
  32. data/lib/action_controller/railtie.rb +0 -1
  33. data/lib/action_controller/test_case.rb +0 -15
  34. data/lib/action_dispatch.rb +1 -0
  35. data/lib/action_dispatch/http/headers.rb +1 -3
  36. data/lib/action_dispatch/http/mime_negotiation.rb +16 -2
  37. data/lib/action_dispatch/http/mime_type.rb +4 -22
  38. data/lib/action_dispatch/http/mime_types.rb +1 -0
  39. data/lib/action_dispatch/http/parameters.rb +18 -19
  40. data/lib/action_dispatch/http/request.rb +16 -25
  41. data/lib/action_dispatch/http/response.rb +21 -8
  42. data/lib/action_dispatch/http/upload.rb +0 -13
  43. data/lib/action_dispatch/http/url.rb +10 -18
  44. data/lib/action_dispatch/journey/formatter.rb +3 -3
  45. data/lib/action_dispatch/journey/gtg/transition_table.rb +3 -5
  46. data/lib/action_dispatch/journey/parser.rb +1 -1
  47. data/lib/action_dispatch/journey/parser.y +1 -0
  48. data/lib/action_dispatch/journey/router.rb +7 -1
  49. data/lib/action_dispatch/journey/router/utils.rb +1 -1
  50. data/lib/action_dispatch/journey/visitors.rb +26 -47
  51. data/lib/action_dispatch/middleware/callbacks.rb +6 -6
  52. data/lib/action_dispatch/middleware/cookies.rb +15 -15
  53. data/lib/action_dispatch/middleware/debug_exceptions.rb +21 -13
  54. data/lib/action_dispatch/middleware/exception_wrapper.rb +1 -1
  55. data/lib/action_dispatch/middleware/flash.rb +5 -11
  56. data/lib/action_dispatch/middleware/params_parser.rb +1 -1
  57. data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
  58. data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
  59. data/lib/action_dispatch/middleware/session/cookie_store.rb +4 -3
  60. data/lib/action_dispatch/middleware/show_exceptions.rb +5 -2
  61. data/lib/action_dispatch/middleware/ssl.rb +1 -1
  62. data/lib/action_dispatch/middleware/static.rb +5 -25
  63. data/lib/action_dispatch/middleware/templates/rescues/{_request_and_response.erb → _request_and_response.html.erb} +0 -0
  64. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  65. data/lib/action_dispatch/middleware/templates/rescues/{_trace.erb → _trace.html.erb} +0 -0
  66. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +15 -0
  67. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +1 -1
  68. data/lib/action_dispatch/middleware/templates/rescues/{missing_template.erb → missing_template.html.erb} +1 -1
  69. data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  70. data/lib/action_dispatch/middleware/templates/rescues/{routing_error.erb → routing_error.html.erb} +1 -1
  71. data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  72. data/lib/action_dispatch/middleware/templates/rescues/{template_error.erb → template_error.html.erb} +1 -1
  73. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +8 -0
  74. data/lib/action_dispatch/middleware/templates/rescues/{unknown_action.erb → unknown_action.html.erb} +1 -1
  75. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  76. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +3 -3
  77. data/lib/action_dispatch/railtie.rb +1 -2
  78. data/lib/action_dispatch/request/session.rb +12 -0
  79. data/lib/action_dispatch/request/utils.rb +24 -0
  80. data/lib/action_dispatch/routing.rb +7 -6
  81. data/lib/action_dispatch/routing/inspector.rb +4 -4
  82. data/lib/action_dispatch/routing/mapper.rb +81 -138
  83. data/lib/action_dispatch/routing/polymorphic_routes.rb +13 -0
  84. data/lib/action_dispatch/routing/redirection.rb +34 -27
  85. data/lib/action_dispatch/routing/route_set.rb +43 -37
  86. data/lib/action_dispatch/routing/url_for.rb +3 -1
  87. data/lib/action_dispatch/testing/assertions/response.rb +8 -15
  88. data/lib/action_dispatch/testing/assertions/selector.rb +4 -4
  89. data/lib/action_dispatch/testing/integration.rb +1 -7
  90. data/lib/action_pack/version.rb +1 -1
  91. metadata +43 -167
  92. data/lib/abstract_controller/layouts.rb +0 -423
  93. data/lib/abstract_controller/view_paths.rb +0 -96
  94. data/lib/action_controller/deprecated.rb +0 -7
  95. data/lib/action_controller/deprecated/integration_test.rb +0 -5
  96. data/lib/action_controller/record_identifier.rb +0 -31
  97. data/lib/action_controller/vendor/html-scanner.rb +0 -5
  98. data/lib/action_view.rb +0 -93
  99. data/lib/action_view/base.rb +0 -205
  100. data/lib/action_view/buffers.rb +0 -49
  101. data/lib/action_view/context.rb +0 -36
  102. data/lib/action_view/dependency_tracker.rb +0 -93
  103. data/lib/action_view/digestor.rb +0 -113
  104. data/lib/action_view/flows.rb +0 -76
  105. data/lib/action_view/helpers.rb +0 -58
  106. data/lib/action_view/helpers/active_model_helper.rb +0 -49
  107. data/lib/action_view/helpers/asset_tag_helper.rb +0 -320
  108. data/lib/action_view/helpers/asset_url_helper.rb +0 -355
  109. data/lib/action_view/helpers/atom_feed_helper.rb +0 -203
  110. data/lib/action_view/helpers/cache_helper.rb +0 -196
  111. data/lib/action_view/helpers/capture_helper.rb +0 -216
  112. data/lib/action_view/helpers/controller_helper.rb +0 -25
  113. data/lib/action_view/helpers/csrf_helper.rb +0 -32
  114. data/lib/action_view/helpers/date_helper.rb +0 -1087
  115. data/lib/action_view/helpers/debug_helper.rb +0 -39
  116. data/lib/action_view/helpers/form_helper.rb +0 -1882
  117. data/lib/action_view/helpers/form_options_helper.rb +0 -838
  118. data/lib/action_view/helpers/form_tag_helper.rb +0 -785
  119. data/lib/action_view/helpers/javascript_helper.rb +0 -117
  120. data/lib/action_view/helpers/number_helper.rb +0 -451
  121. data/lib/action_view/helpers/output_safety_helper.rb +0 -38
  122. data/lib/action_view/helpers/record_tag_helper.rb +0 -106
  123. data/lib/action_view/helpers/rendering_helper.rb +0 -90
  124. data/lib/action_view/helpers/sanitize_helper.rb +0 -256
  125. data/lib/action_view/helpers/tag_helper.rb +0 -173
  126. data/lib/action_view/helpers/tags.rb +0 -39
  127. data/lib/action_view/helpers/tags/base.rb +0 -148
  128. data/lib/action_view/helpers/tags/check_box.rb +0 -64
  129. data/lib/action_view/helpers/tags/checkable.rb +0 -16
  130. data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -53
  131. data/lib/action_view/helpers/tags/collection_helpers.rb +0 -84
  132. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -36
  133. data/lib/action_view/helpers/tags/collection_select.rb +0 -28
  134. data/lib/action_view/helpers/tags/color_field.rb +0 -25
  135. data/lib/action_view/helpers/tags/date_field.rb +0 -13
  136. data/lib/action_view/helpers/tags/date_select.rb +0 -72
  137. data/lib/action_view/helpers/tags/datetime_field.rb +0 -22
  138. data/lib/action_view/helpers/tags/datetime_local_field.rb +0 -19
  139. data/lib/action_view/helpers/tags/datetime_select.rb +0 -8
  140. data/lib/action_view/helpers/tags/email_field.rb +0 -8
  141. data/lib/action_view/helpers/tags/file_field.rb +0 -8
  142. data/lib/action_view/helpers/tags/grouped_collection_select.rb +0 -29
  143. data/lib/action_view/helpers/tags/hidden_field.rb +0 -8
  144. data/lib/action_view/helpers/tags/label.rb +0 -65
  145. data/lib/action_view/helpers/tags/month_field.rb +0 -13
  146. data/lib/action_view/helpers/tags/number_field.rb +0 -18
  147. data/lib/action_view/helpers/tags/password_field.rb +0 -12
  148. data/lib/action_view/helpers/tags/radio_button.rb +0 -31
  149. data/lib/action_view/helpers/tags/range_field.rb +0 -8
  150. data/lib/action_view/helpers/tags/search_field.rb +0 -22
  151. data/lib/action_view/helpers/tags/select.rb +0 -40
  152. data/lib/action_view/helpers/tags/tel_field.rb +0 -8
  153. data/lib/action_view/helpers/tags/text_area.rb +0 -18
  154. data/lib/action_view/helpers/tags/text_field.rb +0 -30
  155. data/lib/action_view/helpers/tags/time_field.rb +0 -13
  156. data/lib/action_view/helpers/tags/time_select.rb +0 -8
  157. data/lib/action_view/helpers/tags/time_zone_select.rb +0 -20
  158. data/lib/action_view/helpers/tags/url_field.rb +0 -8
  159. data/lib/action_view/helpers/tags/week_field.rb +0 -13
  160. data/lib/action_view/helpers/text_helper.rb +0 -448
  161. data/lib/action_view/helpers/translation_helper.rb +0 -112
  162. data/lib/action_view/helpers/url_helper.rb +0 -635
  163. data/lib/action_view/locale/en.yml +0 -56
  164. data/lib/action_view/log_subscriber.rb +0 -30
  165. data/lib/action_view/lookup_context.rb +0 -248
  166. data/lib/action_view/model_naming.rb +0 -12
  167. data/lib/action_view/path_set.rb +0 -77
  168. data/lib/action_view/railtie.rb +0 -43
  169. data/lib/action_view/record_identifier.rb +0 -84
  170. data/lib/action_view/renderer/abstract_renderer.rb +0 -47
  171. data/lib/action_view/renderer/partial_renderer.rb +0 -500
  172. data/lib/action_view/renderer/renderer.rb +0 -50
  173. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -103
  174. data/lib/action_view/renderer/template_renderer.rb +0 -96
  175. data/lib/action_view/routing_url_for.rb +0 -107
  176. data/lib/action_view/tasks/dependencies.rake +0 -17
  177. data/lib/action_view/template.rb +0 -339
  178. data/lib/action_view/template/error.rb +0 -138
  179. data/lib/action_view/template/handlers.rb +0 -53
  180. data/lib/action_view/template/handlers/builder.rb +0 -26
  181. data/lib/action_view/template/handlers/erb.rb +0 -146
  182. data/lib/action_view/template/handlers/raw.rb +0 -11
  183. data/lib/action_view/template/resolver.rb +0 -340
  184. data/lib/action_view/template/text.rb +0 -34
  185. data/lib/action_view/template/types.rb +0 -57
  186. data/lib/action_view/test_case.rb +0 -270
  187. data/lib/action_view/testing/resolvers.rb +0 -50
  188. data/lib/action_view/vendor/html-scanner.rb +0 -20
  189. data/lib/action_view/vendor/html-scanner/html/document.rb +0 -68
  190. data/lib/action_view/vendor/html-scanner/html/node.rb +0 -532
  191. data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +0 -188
  192. data/lib/action_view/vendor/html-scanner/html/selector.rb +0 -830
  193. data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +0 -107
  194. data/lib/action_view/vendor/html-scanner/html/version.rb +0 -11
@@ -1,7 +0,0 @@
1
- ActionController::AbstractRequest = ActionController::Request = ActionDispatch::Request
2
- ActionController::AbstractResponse = ActionController::Response = ActionDispatch::Response
3
- ActionController::Routing = ActionDispatch::Routing
4
-
5
- ActiveSupport::Deprecation.warn 'ActionController::AbstractRequest and ActionController::Request are deprecated and will be removed, use ActionDispatch::Request instead.'
6
- ActiveSupport::Deprecation.warn 'ActionController::AbstractResponse and ActionController::Response are deprecated and will be removed, use ActionDispatch::Response instead.'
7
- ActiveSupport::Deprecation.warn 'ActionController::Routing is deprecated and will be removed, use ActionDispatch::Routing instead.'
@@ -1,5 +0,0 @@
1
- ActionController::Integration = ActionDispatch::Integration
2
- ActionController::IntegrationTest = ActionDispatch::IntegrationTest
3
-
4
- ActiveSupport::Deprecation.warn 'ActionController::Integration is deprecated and will be removed, use ActionDispatch::Integration instead.'
5
- ActiveSupport::Deprecation.warn 'ActionController::IntegrationTest is deprecated and will be removed, use ActionDispatch::IntegrationTest instead.'
@@ -1,31 +0,0 @@
1
- require 'action_view/record_identifier'
2
-
3
- module ActionController
4
- module RecordIdentifier
5
- MODULE_MESSAGE = 'Calling ActionController::RecordIdentifier.%s is deprecated and ' \
6
- 'will be removed in Rails 4.1, please call using ActionView::RecordIdentifier instead.'
7
- INSTANCE_MESSAGE = '%s method will no longer be included by default in controllers ' \
8
- 'since Rails 4.1. If you would like to use it in controllers, please include ' \
9
- 'ActionView::RecordIdentifier module.'
10
-
11
- def dom_id(record, prefix = nil)
12
- ActiveSupport::Deprecation.warn(INSTANCE_MESSAGE % 'dom_id')
13
- ActionView::RecordIdentifier.dom_id(record, prefix)
14
- end
15
-
16
- def dom_class(record, prefix = nil)
17
- ActiveSupport::Deprecation.warn(INSTANCE_MESSAGE % 'dom_class')
18
- ActionView::RecordIdentifier.dom_class(record, prefix)
19
- end
20
-
21
- def self.dom_id(record, prefix = nil)
22
- ActiveSupport::Deprecation.warn(MODULE_MESSAGE % 'dom_id')
23
- ActionView::RecordIdentifier.dom_id(record, prefix)
24
- end
25
-
26
- def self.dom_class(record, prefix = nil)
27
- ActiveSupport::Deprecation.warn(MODULE_MESSAGE % 'dom_class')
28
- ActionView::RecordIdentifier.dom_class(record, prefix)
29
- end
30
- end
31
- end
@@ -1,5 +0,0 @@
1
- require 'action_view/vendor/html-scanner'
2
- require 'active_support/deprecation'
3
-
4
- ActiveSupport::Deprecation.warn 'Vendored html-scanner was moved to action_view, please require "action_view/vendor/html-scanner" instead. ' +
5
- 'This file will be removed in Rails 4.1'
@@ -1,93 +0,0 @@
1
- #--
2
- # Copyright (c) 2004-2013 David Heinemeier Hansson
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- require 'active_support'
25
- require 'active_support/rails'
26
- require 'action_pack'
27
-
28
- module ActionView
29
- extend ActiveSupport::Autoload
30
-
31
- eager_autoload do
32
- autoload :Base
33
- autoload :Context
34
- autoload :CompiledTemplates, "action_view/context"
35
- autoload :Digestor
36
- autoload :Helpers
37
- autoload :LookupContext
38
- autoload :PathSet
39
- autoload :RecordIdentifier
40
- autoload :RoutingUrlFor
41
- autoload :Template
42
-
43
- autoload_under "renderer" do
44
- autoload :Renderer
45
- autoload :AbstractRenderer
46
- autoload :PartialRenderer
47
- autoload :TemplateRenderer
48
- autoload :StreamingTemplateRenderer
49
- end
50
-
51
- autoload_at "action_view/template/resolver" do
52
- autoload :Resolver
53
- autoload :PathResolver
54
- autoload :FileSystemResolver
55
- autoload :OptimizedFileSystemResolver
56
- autoload :FallbackFileSystemResolver
57
- end
58
-
59
- autoload_at "action_view/buffers" do
60
- autoload :OutputBuffer
61
- autoload :StreamingBuffer
62
- end
63
-
64
- autoload_at "action_view/flows" do
65
- autoload :OutputFlow
66
- autoload :StreamingFlow
67
- end
68
-
69
- autoload_at "action_view/template/error" do
70
- autoload :MissingTemplate
71
- autoload :ActionViewError
72
- autoload :EncodingError
73
- autoload :MissingRequestError
74
- autoload :TemplateError
75
- autoload :WrongEncodingError
76
- end
77
- end
78
-
79
- autoload :TestCase
80
-
81
- ENCODING_FLAG = '#.*coding[:=]\s*(\S+)[ \t]*'
82
-
83
- def self.eager_load!
84
- super
85
- ActionView::Template.eager_load!
86
- end
87
- end
88
-
89
- require 'active_support/core_ext/string/output_safety'
90
-
91
- ActiveSupport.on_load(:i18n) do
92
- I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
93
- end
@@ -1,205 +0,0 @@
1
- require 'active_support/core_ext/module/attr_internal'
2
- require 'active_support/core_ext/class/attribute_accessors'
3
- require 'active_support/ordered_options'
4
- require 'action_view/log_subscriber'
5
-
6
- module ActionView #:nodoc:
7
- # = Action View Base
8
- #
9
- # Action View templates can be written in several ways. If the template file has a <tt>.erb</tt> extension then it uses a mixture of ERB
10
- # (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then Jim Weirich's Builder::XmlMarkup library is used.
11
- #
12
- # == ERB
13
- #
14
- # You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
15
- # following loop for names:
16
- #
17
- # <b>Names of all the people</b>
18
- # <% @people.each do |person| %>
19
- # Name: <%= person.name %><br/>
20
- # <% end %>
21
- #
22
- # The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this
23
- # is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
24
- #
25
- # <%# WRONG %>
26
- # Hi, Mr. <% puts "Frodo" %>
27
- #
28
- # If you absolutely must write from within a function use +concat+.
29
- #
30
- # <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
31
- #
32
- # === Using sub templates
33
- #
34
- # Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
35
- # classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
36
- #
37
- # <%= render "shared/header" %>
38
- # Something really specific and terrific
39
- # <%= render "shared/footer" %>
40
- #
41
- # As you see, we use the output embeddings for the render methods. The render call itself will just return a string holding the
42
- # result of the rendering. The output embedding writes it to the current template.
43
- #
44
- # But you don't have to restrict yourself to static includes. Templates can share variables amongst themselves by using instance
45
- # variables defined using the regular embedding tags. Like this:
46
- #
47
- # <% @page_title = "A Wonderful Hello" %>
48
- # <%= render "shared/header" %>
49
- #
50
- # Now the header can pick up on the <tt>@page_title</tt> variable and use it for outputting a title tag:
51
- #
52
- # <title><%= @page_title %></title>
53
- #
54
- # === Passing local variables to sub templates
55
- #
56
- # You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
57
- #
58
- # <%= render "shared/header", { headline: "Welcome", person: person } %>
59
- #
60
- # These can now be accessed in <tt>shared/header</tt> with:
61
- #
62
- # Headline: <%= headline %>
63
- # First name: <%= person.first_name %>
64
- #
65
- # If you need to find out whether a certain local variable has been assigned a value in a particular render call,
66
- # you need to use the following pattern:
67
- #
68
- # <% if local_assigns.has_key? :headline %>
69
- # Headline: <%= headline %>
70
- # <% end %>
71
- #
72
- # Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
73
- #
74
- # === Template caching
75
- #
76
- # By default, Rails will compile each template to a method in order to render it. When you alter a template,
77
- # Rails will check the file's modification time and recompile it in development mode.
78
- #
79
- # == Builder
80
- #
81
- # Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object
82
- # named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
83
- #
84
- # Here are some basic examples:
85
- #
86
- # xml.em("emphasized") # => <em>emphasized</em>
87
- # xml.em { xml.b("emph & bold") } # => <em><b>emph &amp; bold</b></em>
88
- # xml.a("A Link", "href" => "http://onestepback.org") # => <a href="http://onestepback.org">A Link</a>
89
- # xml.target("name" => "compile", "option" => "fast") # => <target option="fast" name="compile"\>
90
- # # NOTE: order of attributes is not specified.
91
- #
92
- # Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following:
93
- #
94
- # xml.div do
95
- # xml.h1(@person.name)
96
- # xml.p(@person.bio)
97
- # end
98
- #
99
- # would produce something like:
100
- #
101
- # <div>
102
- # <h1>David Heinemeier Hansson</h1>
103
- # <p>A product of Danish Design during the Winter of '79...</p>
104
- # </div>
105
- #
106
- # A full-length RSS example actually used on Basecamp:
107
- #
108
- # xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
109
- # xml.channel do
110
- # xml.title(@feed_title)
111
- # xml.link(@url)
112
- # xml.description "Basecamp: Recent items"
113
- # xml.language "en-us"
114
- # xml.ttl "40"
115
- #
116
- # @recent_items.each do |item|
117
- # xml.item do
118
- # xml.title(item_title(item))
119
- # xml.description(item_description(item)) if item_description(item)
120
- # xml.pubDate(item_pubDate(item))
121
- # xml.guid(@person.firm.account.url + @recent_items.url(item))
122
- # xml.link(@person.firm.account.url + @recent_items.url(item))
123
- #
124
- # xml.tag!("dc:creator", item.author_name) if item_has_creator?(item)
125
- # end
126
- # end
127
- # end
128
- # end
129
- #
130
- # More builder documentation can be found at http://builder.rubyforge.org.
131
- class Base
132
- include Helpers, ::ERB::Util, Context
133
-
134
- # Specify the proc used to decorate input tags that refer to attributes with errors.
135
- cattr_accessor :field_error_proc
136
- @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
137
-
138
- # How to complete the streaming when an exception occurs.
139
- # This is our best guess: first try to close the attribute, then the tag.
140
- cattr_accessor :streaming_completion_on_exception
141
- @@streaming_completion_on_exception = %("><script>window.location = "/500.html"</script></html>)
142
-
143
- # Specify whether rendering within namespaced controllers should prefix
144
- # the partial paths for ActiveModel objects with the namespace.
145
- # (e.g., an Admin::PostsController would render @post using /admin/posts/_post.erb)
146
- cattr_accessor :prefix_partial_path_with_controller_namespace
147
- @@prefix_partial_path_with_controller_namespace = true
148
-
149
- # Specify default_formats that can be rendered.
150
- cattr_accessor :default_formats
151
-
152
- # Specify whether an error should be raised for missing translations
153
- cattr_accessor :raise_on_missing_translations
154
- @@raise_on_missing_translations = false
155
-
156
- class_attribute :_routes
157
- class_attribute :logger
158
-
159
- class << self
160
- delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
161
-
162
- def cache_template_loading
163
- ActionView::Resolver.caching?
164
- end
165
-
166
- def cache_template_loading=(value)
167
- ActionView::Resolver.caching = value
168
- end
169
-
170
- def xss_safe? #:nodoc:
171
- true
172
- end
173
- end
174
-
175
- attr_accessor :view_renderer
176
- attr_internal :config, :assigns
177
-
178
- delegate :lookup_context, :to => :view_renderer
179
- delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context
180
-
181
- def assign(new_assigns) # :nodoc:
182
- @_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
183
- end
184
-
185
- def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
186
- @_config = ActiveSupport::InheritableOptions.new
187
-
188
- if context.is_a?(ActionView::Renderer)
189
- @view_renderer = context
190
- else
191
- lookup_context = context.is_a?(ActionView::LookupContext) ?
192
- context : ActionView::LookupContext.new(context)
193
- lookup_context.formats = formats if formats
194
- lookup_context.prefixes = controller._prefixes if controller
195
- @view_renderer = ActionView::Renderer.new(lookup_context)
196
- end
197
-
198
- assign(assigns)
199
- assign_controller(controller)
200
- _prepare_context
201
- end
202
-
203
- ActiveSupport.run_load_hooks(:action_view, self)
204
- end
205
- end
@@ -1,49 +0,0 @@
1
- require 'active_support/core_ext/string/output_safety'
2
-
3
- module ActionView
4
- class OutputBuffer < ActiveSupport::SafeBuffer #:nodoc:
5
- def initialize(*)
6
- super
7
- encode!
8
- end
9
-
10
- def <<(value)
11
- return self if value.nil?
12
- super(value.to_s)
13
- end
14
- alias :append= :<<
15
-
16
- def safe_concat(value)
17
- return self if value.nil?
18
- super(value.to_s)
19
- end
20
- alias :safe_append= :safe_concat
21
- end
22
-
23
- class StreamingBuffer #:nodoc:
24
- def initialize(block)
25
- @block = block
26
- end
27
-
28
- def <<(value)
29
- value = value.to_s
30
- value = ERB::Util.h(value) unless value.html_safe?
31
- @block.call(value)
32
- end
33
- alias :concat :<<
34
- alias :append= :<<
35
-
36
- def safe_concat(value)
37
- @block.call(value.to_s)
38
- end
39
- alias :safe_append= :safe_concat
40
-
41
- def html_safe?
42
- true
43
- end
44
-
45
- def html_safe
46
- self
47
- end
48
- end
49
- end
@@ -1,36 +0,0 @@
1
- module ActionView
2
- module CompiledTemplates #:nodoc:
3
- # holds compiled template code
4
- end
5
-
6
- # = Action View Context
7
- #
8
- # Action View contexts are supplied to Action Controller to render a template.
9
- # The default Action View context is ActionView::Base.
10
- #
11
- # In order to work with ActionController, a Context must just include this module.
12
- # The initialization of the variables used by the context (@output_buffer, @view_flow,
13
- # and @virtual_path) is responsibility of the object that includes this module
14
- # (although you can call _prepare_context defined below).
15
- module Context
16
- include CompiledTemplates
17
- attr_accessor :output_buffer, :view_flow
18
-
19
- # Prepares the context by setting the appropriate instance variables.
20
- # :api: plugin
21
- def _prepare_context
22
- @view_flow = OutputFlow.new
23
- @output_buffer = nil
24
- @virtual_path = nil
25
- end
26
-
27
- # Encapsulates the interaction with the view flow so it
28
- # returns the correct buffer on +yield+. This is usually
29
- # overwritten by helpers to add more behavior.
30
- # :api: plugin
31
- def _layout_for(name=nil)
32
- name ||= :layout
33
- view_flow.get(name).html_safe
34
- end
35
- end
36
- end
@@ -1,93 +0,0 @@
1
- require 'thread_safe'
2
-
3
- module ActionView
4
- class DependencyTracker
5
- @trackers = ThreadSafe::Cache.new
6
-
7
- def self.find_dependencies(name, template)
8
- tracker = @trackers[template.handler]
9
-
10
- if tracker.present?
11
- tracker.call(name, template)
12
- else
13
- []
14
- end
15
- end
16
-
17
- def self.register_tracker(extension, tracker)
18
- handler = Template.handler_for_extension(extension)
19
- @trackers[handler] = tracker
20
- end
21
-
22
- def self.remove_tracker(handler)
23
- @trackers.delete(handler)
24
- end
25
-
26
- class ERBTracker
27
- EXPLICIT_DEPENDENCY = /# Template Dependency: (\S+)/
28
-
29
- # Matches:
30
- # render partial: "comments/comment", collection: commentable.comments
31
- # render "comments/comments"
32
- # render 'comments/comments'
33
- # render('comments/comments')
34
- #
35
- # render(@topic) => render("topics/topic")
36
- # render(topics) => render("topics/topic")
37
- # render(message.topics) => render("topics/topic")
38
- RENDER_DEPENDENCY = /
39
- render\s* # render, followed by optional whitespace
40
- \(? # start an optional parenthesis for the render call
41
- (partial:|:partial\s+=>)?\s* # naming the partial, used with collection -- 1st capture
42
- ([@a-z"'][@\w\/\."']+) # the template name itself -- 2nd capture
43
- /x
44
-
45
- def self.call(name, template)
46
- new(name, template).dependencies
47
- end
48
-
49
- def initialize(name, template)
50
- @name, @template = name, template
51
- end
52
-
53
- def dependencies
54
- render_dependencies + explicit_dependencies
55
- end
56
-
57
- attr_reader :name, :template
58
- private :name, :template
59
-
60
- private
61
-
62
- def source
63
- template.source
64
- end
65
-
66
- def directory
67
- name.split("/")[0..-2].join("/")
68
- end
69
-
70
- def render_dependencies
71
- source.scan(RENDER_DEPENDENCY).
72
- collect(&:second).uniq.
73
-
74
- # render(@topic) => render("topics/topic")
75
- # render(topics) => render("topics/topic")
76
- # render(message.topics) => render("topics/topic")
77
- collect { |name| name.sub(/\A@?([a-z_]+\.)*([a-z_]+)\z/) { "#{$2.pluralize}/#{$2.singularize}" } }.
78
-
79
- # render("headline") => render("message/headline")
80
- collect { |name| name.include?("/") ? name : "#{directory}/#{name}" }.
81
-
82
- # replace quotes from string renders
83
- collect { |name| name.gsub(/["']/, "") }
84
- end
85
-
86
- def explicit_dependencies
87
- source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
88
- end
89
- end
90
-
91
- register_tracker :erb, ERBTracker
92
- end
93
- end