actionpack 1.9.1 → 1.10.1
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 +237 -0
- data/README +12 -12
- data/lib/action_controller.rb +17 -12
- data/lib/action_controller/assertions.rb +119 -67
- data/lib/action_controller/base.rb +184 -102
- data/lib/action_controller/benchmarking.rb +35 -6
- data/lib/action_controller/caching.rb +115 -58
- data/lib/action_controller/cgi_ext/cgi_methods.rb +54 -21
- data/lib/action_controller/cgi_ext/cookie_performance_fix.rb +39 -35
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +34 -21
- data/lib/action_controller/cgi_process.rb +23 -20
- data/lib/action_controller/components.rb +11 -2
- data/lib/action_controller/dependencies.rb +0 -5
- data/lib/action_controller/deprecated_redirects.rb +17 -0
- data/lib/action_controller/filters.rb +13 -9
- data/lib/action_controller/flash.rb +7 -7
- data/lib/action_controller/helpers.rb +1 -14
- data/lib/action_controller/layout.rb +40 -29
- data/lib/action_controller/macros/auto_complete.rb +52 -0
- data/lib/action_controller/macros/in_place_editing.rb +32 -0
- data/lib/action_controller/pagination.rb +44 -28
- data/lib/action_controller/request.rb +54 -40
- data/lib/action_controller/rescue.rb +8 -6
- data/lib/action_controller/routing.rb +77 -28
- data/lib/action_controller/scaffolding.rb +10 -14
- data/lib/action_controller/session/active_record_store.rb +36 -7
- data/lib/action_controller/session_management.rb +126 -0
- data/lib/action_controller/streaming.rb +14 -5
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +1 -1
- data/lib/action_controller/templates/rescues/_trace.rhtml +24 -0
- data/lib/action_controller/templates/rescues/diagnostics.rhtml +2 -13
- data/lib/action_controller/templates/rescues/template_error.rhtml +4 -2
- data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
- data/lib/action_controller/test_process.rb +35 -17
- data/lib/action_controller/upload_progress.rb +52 -0
- data/lib/action_controller/url_rewriter.rb +21 -16
- data/lib/action_controller/vendor/html-scanner/html/document.rb +2 -2
- data/lib/action_controller/vendor/html-scanner/html/node.rb +30 -3
- data/lib/action_pack/version.rb +9 -0
- data/lib/action_view.rb +1 -1
- data/lib/action_view/base.rb +204 -60
- data/lib/action_view/compiled_templates.rb +70 -0
- data/lib/action_view/helpers/active_record_helper.rb +7 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +22 -12
- data/lib/action_view/helpers/capture_helper.rb +2 -10
- data/lib/action_view/helpers/date_helper.rb +21 -13
- data/lib/action_view/helpers/form_helper.rb +14 -10
- data/lib/action_view/helpers/form_options_helper.rb +4 -4
- data/lib/action_view/helpers/form_tag_helper.rb +59 -25
- data/lib/action_view/helpers/java_script_macros_helper.rb +188 -0
- data/lib/action_view/helpers/javascript_helper.rb +68 -133
- data/lib/action_view/helpers/javascripts/controls.js +427 -165
- data/lib/action_view/helpers/javascripts/dragdrop.js +256 -277
- data/lib/action_view/helpers/javascripts/effects.js +766 -277
- data/lib/action_view/helpers/javascripts/prototype.js +906 -218
- data/lib/action_view/helpers/javascripts/slider.js +258 -0
- data/lib/action_view/helpers/number_helper.rb +4 -3
- data/lib/action_view/helpers/pagination_helper.rb +42 -27
- data/lib/action_view/helpers/tag_helper.rb +25 -11
- data/lib/action_view/helpers/text_helper.rb +119 -13
- data/lib/action_view/helpers/upload_progress_helper.rb +2 -2
- data/lib/action_view/helpers/url_helper.rb +68 -21
- data/lib/action_view/partials.rb +17 -6
- data/lib/action_view/template_error.rb +19 -24
- data/rakefile +4 -3
- data/test/abstract_unit.rb +2 -1
- data/test/controller/action_pack_assertions_test.rb +62 -2
- data/test/controller/active_record_assertions_test.rb +5 -6
- data/test/controller/active_record_store_test.rb +23 -1
- data/test/controller/addresses_render_test.rb +4 -0
- data/test/controller/{base_tests.rb → base_test.rb} +4 -3
- data/test/controller/benchmark_test.rb +36 -0
- data/test/controller/caching_filestore.rb +22 -40
- data/test/controller/capture_test.rb +10 -1
- data/test/controller/cgi_test.rb +145 -23
- data/test/controller/components_test.rb +50 -0
- data/test/controller/custom_handler_test.rb +3 -3
- data/test/controller/fake_controllers.rb +24 -0
- data/test/controller/filters_test.rb +6 -6
- data/test/controller/flash_test.rb +6 -6
- data/test/controller/fragment_store_setting_test.rb +45 -0
- data/test/controller/helper_test.rb +1 -3
- data/test/controller/new_render_test.rb +119 -7
- data/test/controller/redirect_test.rb +11 -1
- data/test/controller/render_test.rb +34 -1
- data/test/controller/request_test.rb +14 -5
- data/test/controller/routing_test.rb +238 -42
- data/test/controller/send_file_test.rb +11 -10
- data/test/controller/session_management_test.rb +94 -0
- data/test/controller/test_test.rb +194 -5
- data/test/controller/url_rewriter_test.rb +46 -0
- data/test/fixtures/layouts/talk_from_action.rhtml +2 -0
- data/test/fixtures/layouts/yield.rhtml +2 -0
- data/test/fixtures/multipart/binary_file +0 -0
- data/test/fixtures/multipart/large_text_file +10 -0
- data/test/fixtures/multipart/mixed_files +0 -0
- data/test/fixtures/multipart/single_parameter +5 -0
- data/test/fixtures/multipart/text_file +10 -0
- data/test/fixtures/test/_customer_greeting.rhtml +1 -0
- data/test/fixtures/test/_hash_object.rhtml +1 -0
- data/test/fixtures/test/_person.rhtml +2 -0
- data/test/fixtures/test/action_talk_to_layout.rhtml +2 -0
- data/test/fixtures/test/content_for.rhtml +2 -0
- data/test/fixtures/test/potential_conflicts.rhtml +4 -0
- data/test/template/active_record_helper_test.rb +15 -8
- data/test/template/asset_tag_helper_test.rb +40 -16
- data/test/template/compiled_templates_tests.rb +63 -0
- data/test/template/date_helper_test.rb +80 -4
- data/test/template/form_helper_test.rb +48 -42
- data/test/template/form_options_helper_test.rb +40 -40
- data/test/template/form_tag_helper_test.rb +21 -15
- data/test/template/java_script_macros_helper_test.rb +56 -0
- data/test/template/javascript_helper_test.rb +70 -47
- data/test/template/number_helper_test.rb +2 -0
- data/test/template/tag_helper_test.rb +9 -0
- data/test/template/text_helper_test.rb +146 -1
- data/test/template/upload_progress_helper_testx.rb +11 -147
- data/test/template/url_helper_test.rb +90 -22
- data/test/testing_sandbox.rb +26 -0
- metadata +37 -7
- data/lib/action_controller/auto_complete.rb +0 -47
- data/lib/action_controller/deprecated_renders_and_redirects.rb +0 -76
- data/lib/action_controller/session.rb +0 -14
@@ -1,47 +0,0 @@
|
|
1
|
-
module ActionController
|
2
|
-
module AutoComplete #:nodoc:
|
3
|
-
def self.append_features(base) #:nodoc:
|
4
|
-
super
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
end
|
7
|
-
|
8
|
-
# Example:
|
9
|
-
#
|
10
|
-
# # Controller
|
11
|
-
# class BlogController < ApplicationController
|
12
|
-
# auto_complete_for :post, :title
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# # View
|
16
|
-
# <%= text_field_with_auto_complete :post, title %>
|
17
|
-
#
|
18
|
-
# By default, auto_complete_for limits the results to 10 entries,
|
19
|
-
# and sorts by the given field.
|
20
|
-
#
|
21
|
-
# auto_complete_for takes a third parameter, an options hash to
|
22
|
-
# the find method used to search for the records:
|
23
|
-
#
|
24
|
-
# auto_complete_for :post, :title, :limit => 15, :order => 'created_at DESC'
|
25
|
-
#
|
26
|
-
# For help on defining text input fields with autocompletion,
|
27
|
-
# see ActionView::Helpers::JavaScriptHelper.
|
28
|
-
#
|
29
|
-
# For more examples, see script.aculo.us:
|
30
|
-
# * http://script.aculo.us/demos/ajax/autocompleter
|
31
|
-
# * http://script.aculo.us/demos/ajax/autocompleter_customized
|
32
|
-
module ClassMethods
|
33
|
-
def auto_complete_for(object, method, options = {})
|
34
|
-
define_method("auto_complete_for_#{object}_#{method}") do
|
35
|
-
find_options = {
|
36
|
-
:conditions => [ "LOWER(#{method}) LIKE ?", '%' + params[object][method].downcase + '%' ],
|
37
|
-
:order => "#{method} ASC",
|
38
|
-
:limit => 10 }.merge!(options)
|
39
|
-
|
40
|
-
@items = object.to_s.camelize.constantize.find(:all, find_options)
|
41
|
-
|
42
|
-
render :inline => "<%= auto_complete_result @items, '#{method}' %>"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module ActionController
|
2
|
-
class Base
|
3
|
-
protected
|
4
|
-
# Works like render, but instead of requiring a full template name, you can get by with specifying the action name. So calling
|
5
|
-
# <tt>render_action "show_many"</tt> in WeblogController#display will render "#{template_root}/weblog/show_many.rhtml" or
|
6
|
-
# "#{template_root}/weblog/show_many.rxml".
|
7
|
-
def render_action(action_name, status = nil)
|
8
|
-
render :action => action_name, :status => status
|
9
|
-
end
|
10
|
-
|
11
|
-
# Works like render, but disregards the template_root and requires a full path to the template that needs to be rendered. Can be
|
12
|
-
# used like <tt>render_file "/Users/david/Code/Ruby/template"</tt> to render "/Users/david/Code/Ruby/template.rhtml" or
|
13
|
-
# "/Users/david/Code/Ruby/template.rxml".
|
14
|
-
def render_file(template_path, status = nil, use_full_path = false)
|
15
|
-
render :file => template_path, :status => status, :use_full_path => use_full_path
|
16
|
-
end
|
17
|
-
|
18
|
-
# Renders the +template+ string, which is useful for rendering short templates you don't want to bother having a file for. So
|
19
|
-
# you'd call <tt>render_template "Hello, <%= @user.name %>"</tt> to greet the current user. Or if you want to render as Builder
|
20
|
-
# template, you could do <tt>render_template "xml.h1 @user.name", nil, "rxml"</tt>.
|
21
|
-
def render_template(template, status = nil, type = "rhtml")
|
22
|
-
render :inline => template, :status => status, :type => type
|
23
|
-
end
|
24
|
-
|
25
|
-
# Renders the +text+ string without parsing it through any template engine. Useful for rendering static information as it's
|
26
|
-
# considerably faster than rendering through the template engine.
|
27
|
-
# Use block for response body if provided (useful for deferred rendering or streaming output).
|
28
|
-
def render_text(text = nil, status = nil)
|
29
|
-
render :text => text, :status => status
|
30
|
-
end
|
31
|
-
|
32
|
-
# Renders an empty response that can be used when the request is only interested in triggering an effect. Do note that good
|
33
|
-
# HTTP manners mandate that you don't use GET requests to trigger data changes.
|
34
|
-
def render_nothing(status = nil)
|
35
|
-
render :nothing => true, :status => status
|
36
|
-
end
|
37
|
-
|
38
|
-
# Renders the partial specified by <tt>partial_path</tt>, which by default is the name of the action itself. Example:
|
39
|
-
#
|
40
|
-
# class WeblogController < ActionController::Base
|
41
|
-
# def show
|
42
|
-
# render_partial # renders "weblog/_show.r(xml|html)"
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
def render_partial(partial_path = default_template_name, object = nil, local_assigns = {})
|
46
|
-
render :partial => partial_path, :object => object, :locals => local_assigns
|
47
|
-
end
|
48
|
-
|
49
|
-
# Renders a collection of partials using <tt>partial_name</tt> to iterate over the +collection+.
|
50
|
-
def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = {})
|
51
|
-
render :partial => partial_name, :collection => collection, :spacer_template => partial_spacer_template, :locals => local_assigns
|
52
|
-
end
|
53
|
-
|
54
|
-
def render_with_layout(template_name = default_template_name, status = nil, layout = nil)
|
55
|
-
render :template => template_name, :status => status, :layout => layout
|
56
|
-
end
|
57
|
-
|
58
|
-
def render_without_layout(template_name = default_template_name, status = nil)
|
59
|
-
render :template => template_name, :status => status, :layout => false
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
# Deprecated in favor of calling redirect_to directly with the path.
|
64
|
-
def redirect_to_path(path)
|
65
|
-
redirect_to(path)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Deprecated in favor of calling redirect_to directly with the url. If the resource has moved permanently, it's possible to pass
|
69
|
-
# true as the second parameter and the browser will get "301 Moved Permanently" instead of "302 Found". This can also be done through
|
70
|
-
# just setting the headers["Status"] to "301 Moved Permanently" before using the redirect_to.
|
71
|
-
def redirect_to_url(url, permanently = false)
|
72
|
-
headers["Status"] = "301 Moved Permanently" if permanently
|
73
|
-
redirect_to(url)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module ActionController #:nodoc:
|
2
|
-
module Session #:nodoc:
|
3
|
-
def self.append_features(base) #:nodoc:
|
4
|
-
super #:nodoc:
|
5
|
-
base.after_filter(:clear_persistant_model_associations)
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
def clear_persistant_model_associations #:doc:
|
10
|
-
session = @session.instance_variable_get("@data")
|
11
|
-
session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|