actionpack 3.0.20 → 3.1.0.beta1
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.
- data/CHANGELOG +88 -142
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -6
- data/lib/abstract_controller.rb +1 -0
- data/lib/abstract_controller/asset_paths.rb +2 -2
- data/lib/abstract_controller/base.rb +24 -19
- data/lib/abstract_controller/callbacks.rb +19 -19
- data/lib/abstract_controller/helpers.rb +11 -13
- data/lib/abstract_controller/layouts.rb +4 -5
- data/lib/abstract_controller/railties/routes_helpers.rb +18 -0
- data/lib/abstract_controller/rendering.rb +34 -31
- data/lib/abstract_controller/url_for.rb +27 -0
- data/lib/abstract_controller/view_paths.rb +31 -6
- data/lib/action_controller.rb +5 -3
- data/lib/action_controller/base.rb +15 -16
- data/lib/action_controller/caching.rb +2 -2
- data/lib/action_controller/caching/actions.rb +11 -12
- data/lib/action_controller/caching/fragments.rb +41 -19
- data/lib/action_controller/caching/pages.rb +3 -9
- data/lib/action_controller/caching/sweeping.rb +0 -1
- data/lib/action_controller/deprecated.rb +1 -1
- data/lib/action_controller/log_subscriber.rb +1 -1
- data/lib/action_controller/metal.rb +78 -20
- data/lib/action_controller/metal/compatibility.rb +0 -9
- data/lib/action_controller/metal/conditional_get.rb +9 -9
- data/lib/action_controller/metal/data_streaming.rb +145 -0
- data/lib/action_controller/metal/force_ssl.rb +35 -0
- data/lib/action_controller/metal/head.rb +1 -1
- data/lib/action_controller/metal/helpers.rb +37 -44
- data/lib/action_controller/metal/hide_actions.rb +2 -3
- data/lib/action_controller/metal/http_authentication.rb +41 -38
- data/lib/action_controller/metal/implicit_render.rb +13 -13
- data/lib/action_controller/metal/instrumentation.rb +2 -2
- data/lib/action_controller/metal/mime_responds.rb +25 -19
- data/lib/action_controller/metal/params_wrapper.rb +224 -0
- data/lib/action_controller/metal/redirecting.rb +6 -2
- data/lib/action_controller/metal/renderers.rb +50 -36
- data/lib/action_controller/metal/rendering.rb +34 -25
- data/lib/action_controller/metal/request_forgery_protection.rb +18 -36
- data/lib/action_controller/metal/responder.rb +47 -12
- data/lib/action_controller/metal/streaming.rb +244 -138
- data/lib/action_controller/metal/testing.rb +0 -9
- data/lib/action_controller/metal/url_for.rb +12 -14
- data/lib/action_controller/railtie.rb +19 -37
- data/lib/action_controller/railties/paths.rb +24 -0
- data/lib/action_controller/record_identifier.rb +4 -10
- data/lib/action_controller/test_case.rb +36 -19
- data/lib/action_controller/vendor/html-scanner/html/node.rb +5 -5
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +3 -3
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +2 -0
- data/lib/action_dispatch.rb +4 -1
- data/lib/action_dispatch/http/cache.rb +5 -32
- data/lib/action_dispatch/http/filter_parameters.rb +3 -1
- data/lib/action_dispatch/http/mime_negotiation.rb +22 -3
- data/lib/action_dispatch/http/mime_type.rb +45 -5
- data/lib/action_dispatch/http/rack_cache.rb +58 -0
- data/lib/action_dispatch/http/request.rb +27 -41
- data/lib/action_dispatch/http/response.rb +56 -54
- data/lib/action_dispatch/http/upload.rb +1 -11
- data/lib/action_dispatch/http/url.rb +102 -42
- data/lib/action_dispatch/middleware/callbacks.rb +8 -25
- data/lib/action_dispatch/middleware/closed_error.rb +7 -0
- data/lib/action_dispatch/middleware/cookies.rb +37 -15
- data/lib/action_dispatch/middleware/flash.rb +80 -11
- data/lib/action_dispatch/middleware/params_parser.rb +2 -2
- data/lib/action_dispatch/middleware/reloader.rb +76 -0
- data/lib/action_dispatch/middleware/session/abstract_store.rb +56 -226
- data/lib/action_dispatch/middleware/session/cookie_store.rb +20 -44
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -46
- data/lib/action_dispatch/middleware/show_exceptions.rb +15 -2
- data/lib/action_dispatch/middleware/stack.rb +50 -17
- data/lib/action_dispatch/middleware/static.rb +41 -29
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +4 -2
- data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +2 -6
- data/lib/action_dispatch/railtie.rb +8 -0
- data/lib/action_dispatch/routing.rb +13 -1
- data/lib/action_dispatch/routing/mapper.rb +345 -227
- data/lib/action_dispatch/routing/polymorphic_routes.rb +33 -13
- data/lib/action_dispatch/routing/redirection.rb +110 -0
- data/lib/action_dispatch/routing/route.rb +15 -13
- data/lib/action_dispatch/routing/route_set.rb +116 -90
- data/lib/action_dispatch/routing/routes_proxy.rb +35 -0
- data/lib/action_dispatch/routing/url_for.rb +25 -1
- data/lib/action_dispatch/testing/assertions/response.rb +8 -10
- data/lib/action_dispatch/testing/assertions/routing.rb +15 -15
- data/lib/action_dispatch/testing/assertions/selector.rb +13 -220
- data/lib/action_dispatch/testing/integration.rb +37 -28
- data/lib/action_dispatch/testing/performance_test.rb +1 -3
- data/lib/action_dispatch/testing/test_process.rb +1 -1
- data/lib/action_dispatch/testing/test_request.rb +9 -3
- data/lib/action_dispatch/testing/test_response.rb +4 -111
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +3 -3
- data/lib/action_view.rb +39 -24
- data/lib/action_view/base.rb +61 -86
- data/lib/action_view/buffers.rb +43 -0
- data/lib/action_view/context.rb +21 -24
- data/lib/action_view/flows.rb +79 -0
- data/lib/action_view/helpers.rb +8 -6
- data/lib/action_view/helpers/active_model_helper.rb +0 -23
- data/lib/action_view/helpers/asset_paths.rb +79 -0
- data/lib/action_view/helpers/asset_tag_helper.rb +30 -500
- data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +147 -0
- data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +101 -0
- data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +200 -0
- data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +152 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
- data/lib/action_view/helpers/cache_helper.rb +11 -19
- data/lib/action_view/helpers/capture_helper.rb +19 -8
- data/lib/action_view/helpers/controller_helper.rb +21 -0
- data/lib/action_view/helpers/csrf_helper.rb +22 -4
- data/lib/action_view/helpers/date_helper.rb +36 -22
- data/lib/action_view/helpers/form_helper.rb +199 -113
- data/lib/action_view/helpers/form_options_helper.rb +10 -11
- data/lib/action_view/helpers/form_tag_helper.rb +94 -22
- data/lib/action_view/helpers/javascript_helper.rb +24 -107
- data/lib/action_view/helpers/number_helper.rb +36 -33
- data/lib/action_view/helpers/output_safety_helper.rb +38 -0
- data/lib/action_view/helpers/record_tag_helper.rb +6 -6
- data/lib/action_view/helpers/rendering_helper.rb +90 -0
- data/lib/action_view/helpers/sanitize_helper.rb +2 -2
- data/lib/action_view/helpers/sprockets_helper.rb +69 -0
- data/lib/action_view/helpers/tag_helper.rb +34 -12
- data/lib/action_view/helpers/text_helper.rb +30 -145
- data/lib/action_view/helpers/translation_helper.rb +10 -17
- data/lib/action_view/helpers/url_helper.rb +70 -67
- data/lib/action_view/locale/en.yml +1 -1
- data/lib/action_view/lookup_context.rb +36 -14
- data/lib/action_view/{paths.rb → path_set.rb} +9 -8
- data/lib/action_view/railtie.rb +12 -4
- data/lib/action_view/renderer/abstract_renderer.rb +36 -0
- data/lib/action_view/{render/partials.rb → renderer/partial_renderer.rb} +147 -146
- data/lib/action_view/renderer/renderer.rb +54 -0
- data/lib/action_view/renderer/streaming_template_renderer.rb +106 -0
- data/lib/action_view/renderer/template_renderer.rb +74 -0
- data/lib/action_view/template.rb +91 -54
- data/lib/action_view/template/error.rb +11 -8
- data/lib/action_view/template/handler.rb +9 -1
- data/lib/action_view/template/handlers.rb +9 -9
- data/lib/action_view/template/handlers/builder.rb +4 -4
- data/lib/action_view/template/handlers/erb.rb +21 -41
- data/lib/action_view/template/resolver.rb +171 -57
- data/lib/action_view/template/text.rb +0 -4
- data/lib/action_view/test_case.rb +32 -16
- data/lib/action_view/testing/resolvers.rb +16 -10
- data/lib/sprockets/railtie.rb +100 -0
- metadata +162 -140
- checksums.yaml +0 -7
- data/lib/action_controller/deprecated/base.rb +0 -143
- data/lib/action_controller/deprecated/dispatcher.rb +0 -28
- data/lib/action_controller/deprecated/url_writer.rb +0 -14
- data/lib/action_dispatch/routing/deprecated_mapper.rb +0 -525
- data/lib/action_view/helpers/prototype_helper.rb +0 -851
- data/lib/action_view/helpers/raw_output_helper.rb +0 -18
- data/lib/action_view/helpers/scriptaculous_helper.rb +0 -263
- data/lib/action_view/render/layouts.rb +0 -83
- data/lib/action_view/render/rendering.rb +0 -67
- data/lib/action_view/template/handlers/rjs.rb +0 -17
@@ -1,18 +0,0 @@
|
|
1
|
-
module ActionView #:nodoc:
|
2
|
-
# = Action View Raw Output Helper
|
3
|
-
module Helpers #:nodoc:
|
4
|
-
module RawOutputHelper
|
5
|
-
# This method outputs without escaping a string. Since escaping tags is
|
6
|
-
# now default, this can be used when you don't want Rails to automatically
|
7
|
-
# escape tags. This is not recommended if the data is coming from the user's
|
8
|
-
# input.
|
9
|
-
#
|
10
|
-
# For example:
|
11
|
-
#
|
12
|
-
# <%=raw @user.name %>
|
13
|
-
def raw(stringish)
|
14
|
-
stringish.to_s.html_safe
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,263 +0,0 @@
|
|
1
|
-
require 'action_view/helpers/javascript_helper'
|
2
|
-
require 'active_support/json'
|
3
|
-
|
4
|
-
module ActionView
|
5
|
-
# = Action View Scriptaculous Helpers
|
6
|
-
module Helpers
|
7
|
-
# Provides a set of helpers for calling Scriptaculous[http://script.aculo.us/]
|
8
|
-
# JavaScript functions, including those which create Ajax controls and visual
|
9
|
-
# effects.
|
10
|
-
#
|
11
|
-
# To be able to use these helpers, you must include the Prototype
|
12
|
-
# JavaScript framework and the Scriptaculous JavaScript library in your
|
13
|
-
# pages. See the documentation for ActionView::Helpers::JavaScriptHelper
|
14
|
-
# for more information on including the necessary JavaScript.
|
15
|
-
#
|
16
|
-
# The Scriptaculous helpers' behavior can be tweaked with various options.
|
17
|
-
#
|
18
|
-
# See the documentation at http://script.aculo.us for more information on
|
19
|
-
# using these helpers in your application.
|
20
|
-
module ScriptaculousHelper
|
21
|
-
TOGGLE_EFFECTS = [:toggle_appear, :toggle_slide, :toggle_blind]
|
22
|
-
|
23
|
-
# Returns a JavaScript snippet to be used on the Ajax callbacks for
|
24
|
-
# starting visual effects.
|
25
|
-
#
|
26
|
-
# If no +element_id+ is given, it assumes "element" which should be a local
|
27
|
-
# variable in the generated JavaScript execution context. This can be
|
28
|
-
# used for example with +drop_receiving_element+:
|
29
|
-
#
|
30
|
-
# <%= drop_receiving_element (...), :loading => visual_effect(:fade) %>
|
31
|
-
#
|
32
|
-
# This would fade the element that was dropped on the drop receiving
|
33
|
-
# element.
|
34
|
-
#
|
35
|
-
# For toggling visual effects, you can use <tt>:toggle_appear</tt>, <tt>:toggle_slide</tt>, and
|
36
|
-
# <tt>:toggle_blind</tt> which will alternate between appear/fade, slidedown/slideup, and
|
37
|
-
# blinddown/blindup respectively.
|
38
|
-
#
|
39
|
-
# You can change the behaviour with various options, see
|
40
|
-
# http://script.aculo.us for more documentation.
|
41
|
-
def visual_effect(name, element_id = false, js_options = {})
|
42
|
-
element = element_id ? ActiveSupport::JSON.encode(element_id) : "element"
|
43
|
-
|
44
|
-
js_options[:queue] = if js_options[:queue].is_a?(Hash)
|
45
|
-
'{' + js_options[:queue].map {|k, v| k == :limit ? "#{k}:#{v}" : "#{k}:'#{v}'" }.join(',') + '}'
|
46
|
-
elsif js_options[:queue]
|
47
|
-
"'#{js_options[:queue]}'"
|
48
|
-
end if js_options[:queue]
|
49
|
-
|
50
|
-
[:endcolor, :direction, :startcolor, :scaleMode, :restorecolor].each do |option|
|
51
|
-
js_options[option] = "'#{js_options[option]}'" if js_options[option]
|
52
|
-
end
|
53
|
-
|
54
|
-
if TOGGLE_EFFECTS.include? name.to_sym
|
55
|
-
"Effect.toggle(#{element},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)});"
|
56
|
-
else
|
57
|
-
"new Effect.#{name.to_s.camelize}(#{element},#{options_for_javascript(js_options)});"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Makes the element with the DOM ID specified by +element_id+ sortable
|
62
|
-
# by drag-and-drop and make an Ajax call whenever the sort order has
|
63
|
-
# changed. By default, the action called gets the serialized sortable
|
64
|
-
# element as parameters.
|
65
|
-
#
|
66
|
-
# Example:
|
67
|
-
#
|
68
|
-
# <%= sortable_element("my_list", :url => { :action => "order" }) %>
|
69
|
-
#
|
70
|
-
# In the example, the action gets a "my_list" array parameter
|
71
|
-
# containing the values of the ids of elements the sortable consists
|
72
|
-
# of, in the current order.
|
73
|
-
#
|
74
|
-
# Important: For this to work, the sortable elements must have id
|
75
|
-
# attributes in the form "string_identifier". For example, "item_1". Only
|
76
|
-
# the identifier part of the id attribute will be serialized.
|
77
|
-
#
|
78
|
-
# Additional +options+ are:
|
79
|
-
#
|
80
|
-
# * <tt>:format</tt> - A regular expression to determine what to send as the
|
81
|
-
# serialized id to the server (the default is <tt>/^[^_]*_(.*)$/</tt>).
|
82
|
-
#
|
83
|
-
# * <tt>:constraint</tt> - Whether to constrain the dragging to either
|
84
|
-
# <tt>:horizontal</tt> or <tt>:vertical</tt> (or false to make it unconstrained).
|
85
|
-
#
|
86
|
-
# * <tt>:overlap</tt> - Calculate the item overlap in the <tt>:horizontal</tt>
|
87
|
-
# or <tt>:vertical</tt> direction.
|
88
|
-
#
|
89
|
-
# * <tt>:tag</tt> - Which children of the container element to treat as
|
90
|
-
# sortable (default is <tt>li</tt>).
|
91
|
-
#
|
92
|
-
# * <tt>:containment</tt> - Takes an element or array of elements to treat as
|
93
|
-
# potential drop targets (defaults to the original target element).
|
94
|
-
#
|
95
|
-
# * <tt>:only</tt> - A CSS class name or array of class names used to filter
|
96
|
-
# out child elements as candidates.
|
97
|
-
#
|
98
|
-
# * <tt>:scroll</tt> - Determines whether to scroll the list during drag
|
99
|
-
# operations if the list runs past the visual border.
|
100
|
-
#
|
101
|
-
# * <tt>:tree</tt> - Determines whether to treat nested lists as part of the
|
102
|
-
# main sortable list. This means that you can create multi-layer lists,
|
103
|
-
# and not only sort items at the same level, but drag and sort items
|
104
|
-
# between levels.
|
105
|
-
#
|
106
|
-
# * <tt>:hoverclass</tt> - If set, the Droppable will have this additional CSS class
|
107
|
-
# when an accepted Draggable is hovered over it.
|
108
|
-
#
|
109
|
-
# * <tt>:handle</tt> - Sets whether the element should only be draggable by an
|
110
|
-
# embedded handle. The value may be a string referencing a CSS class value
|
111
|
-
# (as of script.aculo.us V1.5). The first child/grandchild/etc. element
|
112
|
-
# found within the element that has this CSS class value will be used as
|
113
|
-
# the handle.
|
114
|
-
#
|
115
|
-
# * <tt>:ghosting</tt> - Clones the element and drags the clone, leaving
|
116
|
-
# the original in place until the clone is dropped (default is <tt>false</tt>).
|
117
|
-
#
|
118
|
-
# * <tt>:dropOnEmpty</tt> - If true the Sortable container will be made into
|
119
|
-
# a Droppable, that can receive a Draggable (as according to the containment
|
120
|
-
# rules) as a child element when there are no more elements inside (default
|
121
|
-
# is <tt>false</tt>).
|
122
|
-
#
|
123
|
-
# * <tt>:onChange</tt> - Called whenever the sort order changes while dragging. When
|
124
|
-
# dragging from one Sortable to another, the callback is called once on each
|
125
|
-
# Sortable. Gets the affected element as its parameter.
|
126
|
-
#
|
127
|
-
# * <tt>:onUpdate</tt> - Called when the drag ends and the Sortable's order is
|
128
|
-
# changed in any way. When dragging from one Sortable to another, the callback
|
129
|
-
# is called once on each Sortable. Gets the container as its parameter.
|
130
|
-
#
|
131
|
-
# See http://script.aculo.us for more documentation.
|
132
|
-
def sortable_element(element_id, options = {})
|
133
|
-
javascript_tag(sortable_element_js(element_id, options).chop!)
|
134
|
-
end
|
135
|
-
|
136
|
-
def sortable_element_js(element_id, options = {}) #:nodoc:
|
137
|
-
options[:with] ||= "Sortable.serialize(#{ActiveSupport::JSON.encode(element_id)})"
|
138
|
-
options[:onUpdate] ||= "function(){" + remote_function(options) + "}"
|
139
|
-
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
|
140
|
-
|
141
|
-
[:tag, :overlap, :constraint, :handle].each do |option|
|
142
|
-
options[option] = "'#{options[option]}'" if options[option]
|
143
|
-
end
|
144
|
-
|
145
|
-
options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
|
146
|
-
options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
|
147
|
-
|
148
|
-
%(Sortable.create(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
149
|
-
end
|
150
|
-
|
151
|
-
# Makes the element with the DOM ID specified by +element_id+ draggable.
|
152
|
-
#
|
153
|
-
# Example:
|
154
|
-
# <%= draggable_element("my_image", :revert => true)
|
155
|
-
#
|
156
|
-
# You can change the behaviour with various options, see
|
157
|
-
# http://script.aculo.us for more documentation.
|
158
|
-
def draggable_element(element_id, options = {})
|
159
|
-
javascript_tag(draggable_element_js(element_id, options).chop!)
|
160
|
-
end
|
161
|
-
|
162
|
-
def draggable_element_js(element_id, options = {}) #:nodoc:
|
163
|
-
%(new Draggable(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
164
|
-
end
|
165
|
-
|
166
|
-
# Makes the element with the DOM ID specified by +element_id+ receive
|
167
|
-
# dropped draggable elements (created by +draggable_element+).
|
168
|
-
# and make an AJAX call. By default, the action called gets the DOM ID
|
169
|
-
# of the element as parameter.
|
170
|
-
#
|
171
|
-
# Example:
|
172
|
-
# <%= drop_receiving_element("my_cart", :url =>
|
173
|
-
# { :controller => "cart", :action => "add" }) %>
|
174
|
-
#
|
175
|
-
# You can change the behaviour with various options, see
|
176
|
-
# http://script.aculo.us for more documentation.
|
177
|
-
#
|
178
|
-
# Some of these +options+ include:
|
179
|
-
# * <tt>:accept</tt> - Set this to a string or an array of strings describing the
|
180
|
-
# allowable CSS classes that the +draggable_element+ must have in order
|
181
|
-
# to be accepted by this +drop_receiving_element+.
|
182
|
-
#
|
183
|
-
# * <tt>:confirm</tt> - Adds a confirmation dialog. Example:
|
184
|
-
#
|
185
|
-
# :confirm => "Are you sure you want to do this?"
|
186
|
-
#
|
187
|
-
# * <tt>:hoverclass</tt> - If set, the +drop_receiving_element+ will have
|
188
|
-
# this additional CSS class when an accepted +draggable_element+ is
|
189
|
-
# hovered over it.
|
190
|
-
#
|
191
|
-
# * <tt>:onDrop</tt> - Called when a +draggable_element+ is dropped onto
|
192
|
-
# this element. Override this callback with a JavaScript expression to
|
193
|
-
# change the default drop behaviour. Example:
|
194
|
-
#
|
195
|
-
# :onDrop => "function(draggable_element, droppable_element, event) { alert('I like bananas') }"
|
196
|
-
#
|
197
|
-
# This callback gets three parameters: The Draggable element, the Droppable
|
198
|
-
# element and the Event object. You can extract additional information about
|
199
|
-
# the drop - like if the Ctrl or Shift keys were pressed - from the Event object.
|
200
|
-
#
|
201
|
-
# * <tt>:with</tt> - A JavaScript expression specifying the parameters for
|
202
|
-
# the XMLHttpRequest. Any expressions should return a valid URL query string.
|
203
|
-
def drop_receiving_element(element_id, options = {})
|
204
|
-
javascript_tag(drop_receiving_element_js(element_id, options).chop!)
|
205
|
-
end
|
206
|
-
|
207
|
-
def drop_receiving_element_js(element_id, options = {}) #:nodoc:
|
208
|
-
options[:with] ||= "'id=' + encodeURIComponent(element.id)"
|
209
|
-
options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
|
210
|
-
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
|
211
|
-
|
212
|
-
options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
|
213
|
-
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
|
214
|
-
|
215
|
-
# Confirmation happens during the onDrop callback, so it can be removed from the options
|
216
|
-
options.delete(:confirm) if options[:confirm]
|
217
|
-
|
218
|
-
%(Droppables.add(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
219
|
-
end
|
220
|
-
|
221
|
-
protected
|
222
|
-
def array_or_string_for_javascript(option)
|
223
|
-
if option.kind_of?(Array)
|
224
|
-
"['#{option.join('\',\'')}']"
|
225
|
-
elsif !option.nil?
|
226
|
-
"'#{option}'"
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
module PrototypeHelper
|
232
|
-
class JavaScriptGenerator
|
233
|
-
module GeneratorMethods
|
234
|
-
# Starts a script.aculo.us visual effect. See
|
235
|
-
# ActionView::Helpers::ScriptaculousHelper for more information.
|
236
|
-
def visual_effect(name, id = nil, options = {})
|
237
|
-
record @context.send(:visual_effect, name, id, options)
|
238
|
-
end
|
239
|
-
|
240
|
-
# Creates a script.aculo.us sortable element. Useful
|
241
|
-
# to recreate sortable elements after items get added
|
242
|
-
# or deleted.
|
243
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
244
|
-
def sortable(id, options = {})
|
245
|
-
record @context.send(:sortable_element_js, id, options)
|
246
|
-
end
|
247
|
-
|
248
|
-
# Creates a script.aculo.us draggable element.
|
249
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
250
|
-
def draggable(id, options = {})
|
251
|
-
record @context.send(:draggable_element_js, id, options)
|
252
|
-
end
|
253
|
-
|
254
|
-
# Creates a script.aculo.us drop receiving element.
|
255
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
256
|
-
def drop_receiving(id, options = {})
|
257
|
-
record @context.send(:drop_receiving_element_js, id, options)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module ActionView
|
2
|
-
# = Action View Layouts
|
3
|
-
module Layouts
|
4
|
-
# Returns the contents that are yielded to a layout, given a name or a block.
|
5
|
-
#
|
6
|
-
# You can think of a layout as a method that is called with a block. If the user calls
|
7
|
-
# <tt>yield :some_name</tt>, the block, by default, returns <tt>content_for(:some_name)</tt>.
|
8
|
-
# If the user calls simply +yield+, the default block returns <tt>content_for(:layout)</tt>.
|
9
|
-
#
|
10
|
-
# The user can override this default by passing a block to the layout:
|
11
|
-
#
|
12
|
-
# # The template
|
13
|
-
# <%= render :layout => "my_layout" do %>
|
14
|
-
# Content
|
15
|
-
# <% end %>
|
16
|
-
#
|
17
|
-
# # The layout
|
18
|
-
# <html>
|
19
|
-
# <%= yield %>
|
20
|
-
# </html>
|
21
|
-
#
|
22
|
-
# In this case, instead of the default block, which would return <tt>content_for(:layout)</tt>,
|
23
|
-
# this method returns the block that was passed in to <tt>render :layout</tt>, and the response
|
24
|
-
# would be
|
25
|
-
#
|
26
|
-
# <html>
|
27
|
-
# Content
|
28
|
-
# </html>
|
29
|
-
#
|
30
|
-
# Finally, the block can take block arguments, which can be passed in by +yield+:
|
31
|
-
#
|
32
|
-
# # The template
|
33
|
-
# <%= render :layout => "my_layout" do |customer| %>
|
34
|
-
# Hello <%= customer.name %>
|
35
|
-
# <% end %>
|
36
|
-
#
|
37
|
-
# # The layout
|
38
|
-
# <html>
|
39
|
-
# <%= yield Struct.new(:name).new("David") %>
|
40
|
-
# </html>
|
41
|
-
#
|
42
|
-
# In this case, the layout would receive the block passed into <tt>render :layout</tt>,
|
43
|
-
# and the struct specified would be passed into the block as an argument. The result
|
44
|
-
# would be
|
45
|
-
#
|
46
|
-
# <html>
|
47
|
-
# Hello David
|
48
|
-
# </html>
|
49
|
-
#
|
50
|
-
def _layout_for(*args, &block) #:nodoc:
|
51
|
-
name = args.first
|
52
|
-
|
53
|
-
if name.is_a?(Symbol)
|
54
|
-
@_content_for[name].html_safe
|
55
|
-
elsif block
|
56
|
-
capture(*args, &block)
|
57
|
-
else
|
58
|
-
@_content_for[:layout].html_safe
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# This is the method which actually finds the layout using details in the lookup
|
63
|
-
# context object. If no layout is found, it checks if at least a layout with
|
64
|
-
# the given name exists across all details before raising the error.
|
65
|
-
def find_layout(layout)
|
66
|
-
begin
|
67
|
-
with_layout_format do
|
68
|
-
layout =~ /^\// ?
|
69
|
-
with_fallbacks { find_template(layout) } : find_template(layout)
|
70
|
-
end
|
71
|
-
rescue ActionView::MissingTemplate => e
|
72
|
-
update_details(:formats => nil) do
|
73
|
-
raise unless template_exists?(layout)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Contains the logic that actually renders the layout.
|
79
|
-
def _render_layout(layout, locals, &block) #:nodoc:
|
80
|
-
layout.render(self, locals){ |*name| _layout_for(*name, &block) }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/try'
|
2
|
-
|
3
|
-
module ActionView
|
4
|
-
# = Action View Rendering
|
5
|
-
module Rendering
|
6
|
-
# Returns the result of a render that's dictated by the options hash. The primary options are:
|
7
|
-
#
|
8
|
-
# * <tt>:partial</tt> - See ActionView::Partials.
|
9
|
-
# * <tt>:update</tt> - Calls update_page with the block given.
|
10
|
-
# * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those.
|
11
|
-
# * <tt>:inline</tt> - Renders an inline template similar to how it's done in the controller.
|
12
|
-
# * <tt>:text</tt> - Renders the text passed in out.
|
13
|
-
#
|
14
|
-
# If no options hash is passed or :update specified, the default is to render a partial and use the second parameter
|
15
|
-
# as the locals hash.
|
16
|
-
def render(options = {}, locals = {}, &block)
|
17
|
-
case options
|
18
|
-
when Hash
|
19
|
-
if block_given?
|
20
|
-
_render_partial(options.merge(:partial => options.delete(:layout)), &block)
|
21
|
-
elsif options.key?(:partial)
|
22
|
-
_render_partial(options)
|
23
|
-
else
|
24
|
-
template = _determine_template(options)
|
25
|
-
lookup_context.freeze_formats(template.formats, true)
|
26
|
-
_render_template(template, options[:layout], options)
|
27
|
-
end
|
28
|
-
when :update
|
29
|
-
update_page(&block)
|
30
|
-
else
|
31
|
-
_render_partial(:partial => options, :locals => locals)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Determine the template to be rendered using the given options.
|
36
|
-
def _determine_template(options) #:nodoc:
|
37
|
-
if options.key?(:inline)
|
38
|
-
handler = Template.handler_class_for_extension(options[:type] || "erb")
|
39
|
-
Template.new(options[:inline], "inline template", handler, {})
|
40
|
-
elsif options.key?(:text)
|
41
|
-
Template::Text.new(options[:text], formats.try(:first))
|
42
|
-
elsif options.key?(:file)
|
43
|
-
with_fallbacks { find_template(options[:file], options[:prefix]) }
|
44
|
-
elsif options.key?(:template)
|
45
|
-
options[:template].respond_to?(:render) ?
|
46
|
-
options[:template] : find_template(options[:template], options[:prefix])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Renders the given template. An string representing the layout can be
|
51
|
-
# supplied as well.
|
52
|
-
def _render_template(template, layout = nil, options = {}) #:nodoc:
|
53
|
-
locals = options[:locals] || {}
|
54
|
-
layout = find_layout(layout) if layout
|
55
|
-
|
56
|
-
ActiveSupport::Notifications.instrument("render_template.action_view",
|
57
|
-
:identifier => template.identifier, :layout => layout.try(:virtual_path)) do
|
58
|
-
|
59
|
-
content = template.render(self, locals) { |*name| _layout_for(*name) }
|
60
|
-
@_content_for[:layout] = content if layout
|
61
|
-
|
62
|
-
content = _render_layout(layout, locals) if layout
|
63
|
-
content
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ActionView
|
2
|
-
module Template::Handlers
|
3
|
-
class RJS < Template::Handler
|
4
|
-
include Compilable
|
5
|
-
|
6
|
-
self.default_format = Mime::JS
|
7
|
-
|
8
|
-
def compile(template)
|
9
|
-
"update_page do |page|;#{template.source}\nend"
|
10
|
-
end
|
11
|
-
|
12
|
-
def default_format
|
13
|
-
Mime::JS
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|