actionpack 3.2.22.5 → 5.2.4
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +279 -603
- data/MIT-LICENSE +1 -1
- data/README.rdoc +13 -297
- data/lib/abstract_controller/asset_paths.rb +4 -2
- data/lib/abstract_controller/base.rb +82 -52
- data/lib/abstract_controller/caching/fragments.rb +166 -0
- data/lib/abstract_controller/caching.rb +66 -0
- data/lib/abstract_controller/callbacks.rb +117 -103
- data/lib/abstract_controller/collector.rb +18 -7
- data/lib/abstract_controller/error.rb +6 -0
- data/lib/abstract_controller/helpers.rb +65 -38
- data/lib/abstract_controller/logger.rb +3 -2
- data/lib/abstract_controller/railties/routes_helpers.rb +5 -3
- data/lib/abstract_controller/rendering.rb +77 -129
- data/lib/abstract_controller/translation.rb +21 -3
- data/lib/abstract_controller/url_for.rb +9 -7
- data/lib/abstract_controller.rb +12 -13
- data/lib/action_controller/api/api_rendering.rb +16 -0
- data/lib/action_controller/api.rb +149 -0
- data/lib/action_controller/base.rb +81 -40
- data/lib/action_controller/caching.rb +22 -62
- data/lib/action_controller/form_builder.rb +50 -0
- data/lib/action_controller/log_subscriber.rb +30 -18
- data/lib/action_controller/metal/basic_implicit_render.rb +13 -0
- data/lib/action_controller/metal/conditional_get.rb +190 -47
- data/lib/action_controller/metal/content_security_policy.rb +52 -0
- data/lib/action_controller/metal/cookies.rb +3 -3
- data/lib/action_controller/metal/data_streaming.rb +40 -65
- data/lib/action_controller/metal/etag_with_flash.rb +18 -0
- data/lib/action_controller/metal/etag_with_template_digest.rb +57 -0
- data/lib/action_controller/metal/exceptions.rb +19 -12
- data/lib/action_controller/metal/flash.rb +42 -9
- data/lib/action_controller/metal/force_ssl.rb +79 -19
- data/lib/action_controller/metal/head.rb +35 -10
- data/lib/action_controller/metal/helpers.rb +31 -21
- data/lib/action_controller/metal/http_authentication.rb +182 -134
- data/lib/action_controller/metal/implicit_render.rb +62 -8
- data/lib/action_controller/metal/instrumentation.rb +28 -26
- data/lib/action_controller/metal/live.rb +312 -0
- data/lib/action_controller/metal/mime_responds.rb +159 -163
- data/lib/action_controller/metal/parameter_encoding.rb +51 -0
- data/lib/action_controller/metal/params_wrapper.rb +146 -93
- data/lib/action_controller/metal/redirecting.rb +80 -56
- data/lib/action_controller/metal/renderers.rb +119 -47
- data/lib/action_controller/metal/rendering.rb +89 -32
- data/lib/action_controller/metal/request_forgery_protection.rb +373 -41
- data/lib/action_controller/metal/rescue.rb +9 -16
- data/lib/action_controller/metal/streaming.rb +39 -45
- data/lib/action_controller/metal/strong_parameters.rb +1086 -0
- data/lib/action_controller/metal/testing.rb +8 -29
- data/lib/action_controller/metal/url_for.rb +43 -32
- data/lib/action_controller/metal.rb +112 -106
- data/lib/action_controller/railtie.rb +56 -18
- data/lib/action_controller/railties/helpers.rb +24 -0
- data/lib/action_controller/renderer.rb +117 -0
- data/lib/action_controller/template_assertions.rb +11 -0
- data/lib/action_controller/test_case.rb +402 -347
- data/lib/action_controller.rb +31 -30
- data/lib/action_dispatch/http/cache.rb +133 -34
- data/lib/action_dispatch/http/content_security_policy.rb +272 -0
- data/lib/action_dispatch/http/filter_parameters.rb +40 -24
- data/lib/action_dispatch/http/filter_redirect.rb +37 -0
- data/lib/action_dispatch/http/headers.rb +117 -16
- data/lib/action_dispatch/http/mime_negotiation.rb +98 -33
- data/lib/action_dispatch/http/mime_type.rb +198 -146
- data/lib/action_dispatch/http/mime_types.rb +22 -7
- data/lib/action_dispatch/http/parameter_filter.rb +61 -49
- data/lib/action_dispatch/http/parameters.rb +94 -51
- data/lib/action_dispatch/http/rack_cache.rb +4 -3
- data/lib/action_dispatch/http/request.rb +262 -117
- data/lib/action_dispatch/http/response.rb +400 -86
- data/lib/action_dispatch/http/upload.rb +66 -29
- data/lib/action_dispatch/http/url.rb +232 -60
- data/lib/action_dispatch/journey/formatter.rb +189 -0
- data/lib/action_dispatch/journey/gtg/builder.rb +164 -0
- data/lib/action_dispatch/journey/gtg/simulator.rb +41 -0
- data/lib/action_dispatch/journey/gtg/transition_table.rb +158 -0
- data/lib/action_dispatch/journey/nfa/builder.rb +78 -0
- data/lib/action_dispatch/journey/nfa/dot.rb +36 -0
- data/lib/action_dispatch/journey/nfa/simulator.rb +49 -0
- data/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
- data/lib/action_dispatch/journey/nodes/node.rb +140 -0
- data/lib/action_dispatch/journey/parser.rb +199 -0
- data/lib/action_dispatch/journey/parser.y +50 -0
- data/lib/action_dispatch/journey/parser_extras.rb +31 -0
- data/lib/action_dispatch/journey/path/pattern.rb +199 -0
- data/lib/action_dispatch/journey/route.rb +203 -0
- data/lib/action_dispatch/journey/router/utils.rb +102 -0
- data/lib/action_dispatch/journey/router.rb +156 -0
- data/lib/action_dispatch/journey/routes.rb +82 -0
- data/lib/action_dispatch/journey/scanner.rb +64 -0
- data/lib/action_dispatch/journey/visitors.rb +268 -0
- data/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
- data/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
- data/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
- data/lib/action_dispatch/journey.rb +7 -0
- data/lib/action_dispatch/middleware/callbacks.rb +17 -13
- data/lib/action_dispatch/middleware/cookies.rb +494 -162
- data/lib/action_dispatch/middleware/debug_exceptions.rb +176 -53
- data/lib/action_dispatch/middleware/debug_locks.rb +124 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +103 -38
- data/lib/action_dispatch/middleware/executor.rb +21 -0
- data/lib/action_dispatch/middleware/flash.rb +128 -91
- data/lib/action_dispatch/middleware/public_exceptions.rb +43 -16
- data/lib/action_dispatch/middleware/reloader.rb +6 -83
- data/lib/action_dispatch/middleware/remote_ip.rb +151 -49
- data/lib/action_dispatch/middleware/request_id.rb +19 -15
- data/lib/action_dispatch/middleware/session/abstract_store.rb +38 -34
- data/lib/action_dispatch/middleware/session/cache_store.rb +14 -9
- data/lib/action_dispatch/middleware/session/cookie_store.rb +94 -44
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +15 -4
- data/lib/action_dispatch/middleware/show_exceptions.rb +36 -61
- data/lib/action_dispatch/middleware/ssl.rb +150 -0
- data/lib/action_dispatch/middleware/stack.rb +33 -41
- data/lib/action_dispatch/middleware/static.rb +92 -48
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +22 -0
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +27 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +16 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +21 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +13 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +134 -5
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +200 -0
- data/lib/action_dispatch/railtie.rb +29 -8
- data/lib/action_dispatch/request/session.rb +234 -0
- data/lib/action_dispatch/request/utils.rb +78 -0
- data/lib/action_dispatch/routing/endpoint.rb +17 -0
- data/lib/action_dispatch/routing/inspector.rb +225 -0
- data/lib/action_dispatch/routing/mapper.rb +1329 -582
- data/lib/action_dispatch/routing/polymorphic_routes.rb +237 -94
- data/lib/action_dispatch/routing/redirection.rb +120 -50
- data/lib/action_dispatch/routing/route_set.rb +545 -322
- data/lib/action_dispatch/routing/routes_proxy.rb +37 -7
- data/lib/action_dispatch/routing/url_for.rb +103 -34
- data/lib/action_dispatch/routing.rb +66 -99
- data/lib/action_dispatch/system_test_case.rb +147 -0
- data/lib/action_dispatch/system_testing/browser.rb +49 -0
- data/lib/action_dispatch/system_testing/driver.rb +59 -0
- data/lib/action_dispatch/system_testing/server.rb +31 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +96 -0
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +31 -0
- data/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +26 -0
- data/lib/action_dispatch/testing/assertion_response.rb +47 -0
- data/lib/action_dispatch/testing/assertions/response.rb +53 -42
- data/lib/action_dispatch/testing/assertions/routing.rb +79 -74
- data/lib/action_dispatch/testing/assertions.rb +15 -9
- data/lib/action_dispatch/testing/integration.rb +361 -207
- data/lib/action_dispatch/testing/request_encoder.rb +55 -0
- data/lib/action_dispatch/testing/test_process.rb +28 -19
- data/lib/action_dispatch/testing/test_request.rb +30 -33
- data/lib/action_dispatch/testing/test_response.rb +35 -11
- data/lib/action_dispatch.rb +42 -32
- data/lib/action_pack/gem_version.rb +17 -0
- data/lib/action_pack/version.rb +7 -7
- data/lib/action_pack.rb +4 -2
- metadata +116 -175
- data/lib/abstract_controller/layouts.rb +0 -423
- data/lib/abstract_controller/view_paths.rb +0 -96
- data/lib/action_controller/caching/actions.rb +0 -185
- data/lib/action_controller/caching/fragments.rb +0 -127
- data/lib/action_controller/caching/pages.rb +0 -187
- data/lib/action_controller/caching/sweeping.rb +0 -97
- data/lib/action_controller/deprecated/integration_test.rb +0 -2
- data/lib/action_controller/deprecated/performance_test.rb +0 -1
- data/lib/action_controller/deprecated.rb +0 -3
- data/lib/action_controller/metal/compatibility.rb +0 -65
- data/lib/action_controller/metal/hide_actions.rb +0 -41
- data/lib/action_controller/metal/rack_delegation.rb +0 -26
- data/lib/action_controller/metal/responder.rb +0 -286
- data/lib/action_controller/metal/session_management.rb +0 -14
- data/lib/action_controller/middleware.rb +0 -39
- data/lib/action_controller/railties/paths.rb +0 -25
- data/lib/action_controller/record_identifier.rb +0 -85
- data/lib/action_controller/vendor/html-scanner/html/document.rb +0 -68
- data/lib/action_controller/vendor/html-scanner/html/node.rb +0 -532
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +0 -177
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +0 -830
- data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +0 -107
- data/lib/action_controller/vendor/html-scanner/html/version.rb +0 -11
- data/lib/action_controller/vendor/html-scanner.rb +0 -20
- data/lib/action_dispatch/middleware/best_standards_support.rb +0 -30
- data/lib/action_dispatch/middleware/body_proxy.rb +0 -30
- data/lib/action_dispatch/middleware/head.rb +0 -18
- data/lib/action_dispatch/middleware/params_parser.rb +0 -75
- data/lib/action_dispatch/middleware/rescue.rb +0 -26
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +0 -31
- data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +0 -26
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +0 -10
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.erb +0 -2
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +0 -15
- data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +0 -17
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb +0 -2
- data/lib/action_dispatch/testing/assertions/dom.rb +0 -37
- data/lib/action_dispatch/testing/assertions/selector.rb +0 -435
- data/lib/action_dispatch/testing/assertions/tag.rb +0 -138
- data/lib/action_dispatch/testing/performance_test.rb +0 -10
- data/lib/action_view/asset_paths.rb +0 -142
- data/lib/action_view/base.rb +0 -220
- data/lib/action_view/buffers.rb +0 -43
- data/lib/action_view/context.rb +0 -36
- data/lib/action_view/flows.rb +0 -79
- data/lib/action_view/helpers/active_model_helper.rb +0 -50
- data/lib/action_view/helpers/asset_paths.rb +0 -7
- data/lib/action_view/helpers/asset_tag_helper.rb +0 -457
- data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +0 -146
- data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +0 -93
- data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +0 -193
- data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +0 -148
- data/lib/action_view/helpers/atom_feed_helper.rb +0 -200
- data/lib/action_view/helpers/cache_helper.rb +0 -64
- data/lib/action_view/helpers/capture_helper.rb +0 -203
- data/lib/action_view/helpers/controller_helper.rb +0 -25
- data/lib/action_view/helpers/csrf_helper.rb +0 -32
- data/lib/action_view/helpers/date_helper.rb +0 -1062
- data/lib/action_view/helpers/debug_helper.rb +0 -40
- data/lib/action_view/helpers/form_helper.rb +0 -1486
- data/lib/action_view/helpers/form_options_helper.rb +0 -658
- data/lib/action_view/helpers/form_tag_helper.rb +0 -685
- data/lib/action_view/helpers/javascript_helper.rb +0 -110
- data/lib/action_view/helpers/number_helper.rb +0 -622
- data/lib/action_view/helpers/output_safety_helper.rb +0 -38
- data/lib/action_view/helpers/record_tag_helper.rb +0 -111
- data/lib/action_view/helpers/rendering_helper.rb +0 -92
- data/lib/action_view/helpers/sanitize_helper.rb +0 -259
- data/lib/action_view/helpers/tag_helper.rb +0 -167
- data/lib/action_view/helpers/text_helper.rb +0 -426
- data/lib/action_view/helpers/translation_helper.rb +0 -91
- data/lib/action_view/helpers/url_helper.rb +0 -693
- data/lib/action_view/helpers.rb +0 -60
- data/lib/action_view/locale/en.yml +0 -160
- data/lib/action_view/log_subscriber.rb +0 -28
- data/lib/action_view/lookup_context.rb +0 -258
- data/lib/action_view/path_set.rb +0 -101
- data/lib/action_view/railtie.rb +0 -55
- data/lib/action_view/renderer/abstract_renderer.rb +0 -41
- data/lib/action_view/renderer/partial_renderer.rb +0 -415
- data/lib/action_view/renderer/renderer.rb +0 -61
- data/lib/action_view/renderer/streaming_template_renderer.rb +0 -106
- data/lib/action_view/renderer/template_renderer.rb +0 -95
- data/lib/action_view/template/error.rb +0 -128
- data/lib/action_view/template/handlers/builder.rb +0 -26
- data/lib/action_view/template/handlers/erb.rb +0 -125
- data/lib/action_view/template/handlers.rb +0 -50
- data/lib/action_view/template/resolver.rb +0 -298
- data/lib/action_view/template/text.rb +0 -30
- data/lib/action_view/template.rb +0 -337
- data/lib/action_view/test_case.rb +0 -246
- data/lib/action_view/testing/resolvers.rb +0 -49
- data/lib/action_view.rb +0 -84
- data/lib/sprockets/assets.rake +0 -99
- data/lib/sprockets/bootstrap.rb +0 -37
- data/lib/sprockets/compressors.rb +0 -83
- data/lib/sprockets/helpers/isolated_helper.rb +0 -13
- data/lib/sprockets/helpers/rails_helper.rb +0 -182
- data/lib/sprockets/helpers.rb +0 -6
- data/lib/sprockets/railtie.rb +0 -62
- data/lib/sprockets/static_compiler.rb +0 -56
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
require 'zlib'
|
|
2
|
-
require 'active_support/core_ext/file'
|
|
3
|
-
require 'action_controller/metal/exceptions'
|
|
4
|
-
|
|
5
|
-
module ActionView
|
|
6
|
-
class AssetPaths #:nodoc:
|
|
7
|
-
attr_reader :config, :controller
|
|
8
|
-
|
|
9
|
-
def initialize(config, controller = nil)
|
|
10
|
-
@config = config
|
|
11
|
-
@controller = controller
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Add the extension +ext+ if not present. Return full or scheme-relative URLs otherwise untouched.
|
|
15
|
-
# Prefix with <tt>/dir/</tt> if lacking a leading +/+. Account for relative URL
|
|
16
|
-
# roots. Rewrite the asset path for cache-busting asset ids. Include
|
|
17
|
-
# asset host, if configured, with the correct request protocol.
|
|
18
|
-
#
|
|
19
|
-
# When :relative (default), the protocol will be determined by the client using current protocol
|
|
20
|
-
# When :request, the protocol will be the request protocol
|
|
21
|
-
# Otherwise, the protocol is used (E.g. :http, :https, etc)
|
|
22
|
-
def compute_public_path(source, dir, options = {})
|
|
23
|
-
source = source.to_s
|
|
24
|
-
return source if is_uri?(source)
|
|
25
|
-
|
|
26
|
-
source = rewrite_extension(source, dir, options[:ext]) if options[:ext]
|
|
27
|
-
source = rewrite_asset_path(source, dir, options)
|
|
28
|
-
source = rewrite_relative_url_root(source, relative_url_root)
|
|
29
|
-
source = rewrite_host_and_protocol(source, options[:protocol])
|
|
30
|
-
source
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Return the filesystem path for the source
|
|
34
|
-
def compute_source_path(source, dir, ext)
|
|
35
|
-
source = rewrite_extension(source, dir, ext) if ext
|
|
36
|
-
|
|
37
|
-
sources = []
|
|
38
|
-
sources << config.assets_dir
|
|
39
|
-
sources << dir unless source[0] == ?/
|
|
40
|
-
sources << source
|
|
41
|
-
|
|
42
|
-
File.join(sources)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def is_uri?(path)
|
|
46
|
-
path =~ %r{^[-a-z]+://|^(?:cid|data):|^//}i
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def rewrite_extension(source, dir, ext)
|
|
52
|
-
raise NotImplementedError
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def rewrite_asset_path(source, path = nil)
|
|
56
|
-
raise NotImplementedError
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def rewrite_relative_url_root(source, relative_url_root)
|
|
60
|
-
relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def has_request?
|
|
64
|
-
controller.respond_to?(:request)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def rewrite_host_and_protocol(source, protocol = nil)
|
|
68
|
-
host = compute_asset_host(source)
|
|
69
|
-
if host && !is_uri?(host)
|
|
70
|
-
if (protocol || default_protocol) == :request && !has_request?
|
|
71
|
-
host = nil
|
|
72
|
-
else
|
|
73
|
-
host = "#{compute_protocol(protocol)}#{host}"
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
host ? "#{host}#{source}" : source
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def compute_protocol(protocol)
|
|
80
|
-
protocol ||= default_protocol
|
|
81
|
-
case protocol
|
|
82
|
-
when :relative
|
|
83
|
-
"//"
|
|
84
|
-
when :request
|
|
85
|
-
unless @controller
|
|
86
|
-
invalid_asset_host!("The protocol requested was :request. Consider using :relative instead.")
|
|
87
|
-
end
|
|
88
|
-
@controller.request.protocol
|
|
89
|
-
else
|
|
90
|
-
"#{protocol}://"
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def default_protocol
|
|
95
|
-
@config.default_asset_host_protocol || (has_request? ? :request : :relative)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def invalid_asset_host!(help_message)
|
|
99
|
-
raise ActionController::RoutingError, "This asset host cannot be computed without a request in scope. #{help_message}"
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# Pick an asset host for this source. Returns +nil+ if no host is set,
|
|
103
|
-
# the host if no wildcard is set, the host interpolated with the
|
|
104
|
-
# numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
|
|
105
|
-
# or the value returned from invoking call on an object responding to call
|
|
106
|
-
# (proc or otherwise).
|
|
107
|
-
def compute_asset_host(source)
|
|
108
|
-
if host = asset_host_config
|
|
109
|
-
if host.respond_to?(:call)
|
|
110
|
-
args = [source]
|
|
111
|
-
arity = arity_of(host)
|
|
112
|
-
if (arity > 1 || arity < -2) && !has_request?
|
|
113
|
-
invalid_asset_host!("Remove the second argument to your asset_host Proc if you do not need the request, or make it optional.")
|
|
114
|
-
end
|
|
115
|
-
args << current_request if (arity > 1 || arity < 0) && has_request?
|
|
116
|
-
host.call(*args)
|
|
117
|
-
else
|
|
118
|
-
(host =~ /%d/) ? host % (Zlib.crc32(source) % 4) : host
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def relative_url_root
|
|
124
|
-
config.relative_url_root
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def asset_host_config
|
|
128
|
-
config.asset_host
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# Returns the current request if one exists.
|
|
132
|
-
def current_request
|
|
133
|
-
controller.request if has_request?
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Returns the arity of a callable
|
|
137
|
-
def arity_of(callable)
|
|
138
|
-
callable.respond_to?(:arity) ? callable.arity : callable.method(:call).arity
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
end
|
|
142
|
-
end
|
data/lib/action_view/base.rb
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/module/attr_internal'
|
|
2
|
-
require 'active_support/core_ext/module/delegation'
|
|
3
|
-
require 'active_support/core_ext/class/attribute'
|
|
4
|
-
require 'active_support/core_ext/array/wrap'
|
|
5
|
-
require 'active_support/ordered_options'
|
|
6
|
-
require 'action_view/log_subscriber'
|
|
7
|
-
require 'active_support/core_ext/module/deprecation'
|
|
8
|
-
|
|
9
|
-
module ActionView #:nodoc:
|
|
10
|
-
# = Action View Base
|
|
11
|
-
#
|
|
12
|
-
# 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
|
|
13
|
-
# (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then Jim Weirich's Builder::XmlMarkup library is used.
|
|
14
|
-
#
|
|
15
|
-
# == ERB
|
|
16
|
-
#
|
|
17
|
-
# You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
|
|
18
|
-
# following loop for names:
|
|
19
|
-
#
|
|
20
|
-
# <b>Names of all the people</b>
|
|
21
|
-
# <% @people.each do |person| %>
|
|
22
|
-
# Name: <%= person.name %><br/>
|
|
23
|
-
# <% end %>
|
|
24
|
-
#
|
|
25
|
-
# The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this
|
|
26
|
-
# is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
|
|
27
|
-
#
|
|
28
|
-
# <%# WRONG %>
|
|
29
|
-
# Hi, Mr. <% puts "Frodo" %>
|
|
30
|
-
#
|
|
31
|
-
# If you absolutely must write from within a function use +concat+.
|
|
32
|
-
#
|
|
33
|
-
# <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
|
|
34
|
-
#
|
|
35
|
-
# === Using sub templates
|
|
36
|
-
#
|
|
37
|
-
# Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
|
|
38
|
-
# classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
|
|
39
|
-
#
|
|
40
|
-
# <%= render "shared/header" %>
|
|
41
|
-
# Something really specific and terrific
|
|
42
|
-
# <%= render "shared/footer" %>
|
|
43
|
-
#
|
|
44
|
-
# As you see, we use the output embeddings for the render methods. The render call itself will just return a string holding the
|
|
45
|
-
# result of the rendering. The output embedding writes it to the current template.
|
|
46
|
-
#
|
|
47
|
-
# But you don't have to restrict yourself to static includes. Templates can share variables amongst themselves by using instance
|
|
48
|
-
# variables defined using the regular embedding tags. Like this:
|
|
49
|
-
#
|
|
50
|
-
# <% @page_title = "A Wonderful Hello" %>
|
|
51
|
-
# <%= render "shared/header" %>
|
|
52
|
-
#
|
|
53
|
-
# Now the header can pick up on the <tt>@page_title</tt> variable and use it for outputting a title tag:
|
|
54
|
-
#
|
|
55
|
-
# <title><%= @page_title %></title>
|
|
56
|
-
#
|
|
57
|
-
# === Passing local variables to sub templates
|
|
58
|
-
#
|
|
59
|
-
# You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
|
|
60
|
-
#
|
|
61
|
-
# <%= render "shared/header", { :headline => "Welcome", :person => person } %>
|
|
62
|
-
#
|
|
63
|
-
# These can now be accessed in <tt>shared/header</tt> with:
|
|
64
|
-
#
|
|
65
|
-
# Headline: <%= headline %>
|
|
66
|
-
# First name: <%= person.first_name %>
|
|
67
|
-
#
|
|
68
|
-
# If you need to find out whether a certain local variable has been assigned a value in a particular render call,
|
|
69
|
-
# you need to use the following pattern:
|
|
70
|
-
#
|
|
71
|
-
# <% if local_assigns.has_key? :headline %>
|
|
72
|
-
# Headline: <%= headline %>
|
|
73
|
-
# <% end %>
|
|
74
|
-
#
|
|
75
|
-
# Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
|
|
76
|
-
#
|
|
77
|
-
# === Template caching
|
|
78
|
-
#
|
|
79
|
-
# By default, Rails will compile each template to a method in order to render it. When you alter a template,
|
|
80
|
-
# Rails will check the file's modification time and recompile it in development mode.
|
|
81
|
-
#
|
|
82
|
-
# == Builder
|
|
83
|
-
#
|
|
84
|
-
# Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object
|
|
85
|
-
# named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
|
|
86
|
-
#
|
|
87
|
-
# Here are some basic examples:
|
|
88
|
-
#
|
|
89
|
-
# xml.em("emphasized") # => <em>emphasized</em>
|
|
90
|
-
# xml.em { xml.b("emph & bold") } # => <em><b>emph & bold</b></em>
|
|
91
|
-
# xml.a("A Link", "href" => "http://onestepback.org") # => <a href="http://onestepback.org">A Link</a>
|
|
92
|
-
# xml.target("name" => "compile", "option" => "fast") # => <target option="fast" name="compile"\>
|
|
93
|
-
# # NOTE: order of attributes is not specified.
|
|
94
|
-
#
|
|
95
|
-
# Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following:
|
|
96
|
-
#
|
|
97
|
-
# xml.div do
|
|
98
|
-
# xml.h1(@person.name)
|
|
99
|
-
# xml.p(@person.bio)
|
|
100
|
-
# end
|
|
101
|
-
#
|
|
102
|
-
# would produce something like:
|
|
103
|
-
#
|
|
104
|
-
# <div>
|
|
105
|
-
# <h1>David Heinemeier Hansson</h1>
|
|
106
|
-
# <p>A product of Danish Design during the Winter of '79...</p>
|
|
107
|
-
# </div>
|
|
108
|
-
#
|
|
109
|
-
# A full-length RSS example actually used on Basecamp:
|
|
110
|
-
#
|
|
111
|
-
# xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
|
|
112
|
-
# xml.channel do
|
|
113
|
-
# xml.title(@feed_title)
|
|
114
|
-
# xml.link(@url)
|
|
115
|
-
# xml.description "Basecamp: Recent items"
|
|
116
|
-
# xml.language "en-us"
|
|
117
|
-
# xml.ttl "40"
|
|
118
|
-
#
|
|
119
|
-
# @recent_items.each do |item|
|
|
120
|
-
# xml.item do
|
|
121
|
-
# xml.title(item_title(item))
|
|
122
|
-
# xml.description(item_description(item)) if item_description(item)
|
|
123
|
-
# xml.pubDate(item_pubDate(item))
|
|
124
|
-
# xml.guid(@person.firm.account.url + @recent_items.url(item))
|
|
125
|
-
# xml.link(@person.firm.account.url + @recent_items.url(item))
|
|
126
|
-
#
|
|
127
|
-
# xml.tag!("dc:creator", item.author_name) if item_has_creator?(item)
|
|
128
|
-
# end
|
|
129
|
-
# end
|
|
130
|
-
# end
|
|
131
|
-
# end
|
|
132
|
-
#
|
|
133
|
-
# More builder documentation can be found at http://builder.rubyforge.org.
|
|
134
|
-
class Base
|
|
135
|
-
include Helpers, ::ERB::Util, Context
|
|
136
|
-
|
|
137
|
-
# Specify the proc used to decorate input tags that refer to attributes with errors.
|
|
138
|
-
cattr_accessor :field_error_proc
|
|
139
|
-
@@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
|
|
140
|
-
|
|
141
|
-
# How to complete the streaming when an exception occurs.
|
|
142
|
-
# This is our best guess: first try to close the attribute, then the tag.
|
|
143
|
-
cattr_accessor :streaming_completion_on_exception
|
|
144
|
-
@@streaming_completion_on_exception = %("><script type="text/javascript">window.location = "/500.html"</script></html>)
|
|
145
|
-
|
|
146
|
-
class_attribute :helpers
|
|
147
|
-
class_attribute :_routes
|
|
148
|
-
|
|
149
|
-
class << self
|
|
150
|
-
delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
|
|
151
|
-
delegate :logger, :to => 'ActionController::Base', :allow_nil => true
|
|
152
|
-
|
|
153
|
-
def cache_template_loading
|
|
154
|
-
ActionView::Resolver.caching?
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def cache_template_loading=(value)
|
|
158
|
-
ActionView::Resolver.caching = value
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def process_view_paths(value)
|
|
162
|
-
value.is_a?(PathSet) ?
|
|
163
|
-
value.dup : ActionView::PathSet.new(Array.wrap(value))
|
|
164
|
-
end
|
|
165
|
-
deprecate :process_view_paths
|
|
166
|
-
|
|
167
|
-
def xss_safe? #:nodoc:
|
|
168
|
-
true
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# This method receives routes and helpers from the controller
|
|
172
|
-
# and return a subclass ready to be used as view context.
|
|
173
|
-
def prepare(routes, helpers) #:nodoc:
|
|
174
|
-
Class.new(self) do
|
|
175
|
-
if routes
|
|
176
|
-
include routes.url_helpers
|
|
177
|
-
include routes.mounted_helpers
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
if helpers
|
|
181
|
-
include helpers
|
|
182
|
-
self.helpers = helpers
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
attr_accessor :view_renderer
|
|
189
|
-
attr_internal :config, :assigns
|
|
190
|
-
|
|
191
|
-
delegate :lookup_context, :to => :view_renderer
|
|
192
|
-
delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context
|
|
193
|
-
|
|
194
|
-
def assign(new_assigns) # :nodoc:
|
|
195
|
-
@_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
|
|
199
|
-
@_config = ActiveSupport::InheritableOptions.new
|
|
200
|
-
|
|
201
|
-
# Handle all these for backwards compatibility.
|
|
202
|
-
# TODO Provide a new API for AV::Base and deprecate this one.
|
|
203
|
-
if context.is_a?(ActionView::Renderer)
|
|
204
|
-
@view_renderer = context
|
|
205
|
-
elsif
|
|
206
|
-
lookup_context = context.is_a?(ActionView::LookupContext) ?
|
|
207
|
-
context : ActionView::LookupContext.new(context)
|
|
208
|
-
lookup_context.formats = formats if formats
|
|
209
|
-
lookup_context.prefixes = controller._prefixes if controller
|
|
210
|
-
@view_renderer = ActionView::Renderer.new(lookup_context)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
assign(assigns)
|
|
214
|
-
assign_controller(controller)
|
|
215
|
-
_prepare_context
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
ActiveSupport.run_load_hooks(:action_view, self)
|
|
219
|
-
end
|
|
220
|
-
end
|
data/lib/action_view/buffers.rb
DELETED
|
@@ -1,43 +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! if encoding_aware?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def <<(value)
|
|
11
|
-
super(value.to_s)
|
|
12
|
-
end
|
|
13
|
-
alias :append= :<<
|
|
14
|
-
alias :safe_append= :safe_concat
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class StreamingBuffer #:nodoc:
|
|
18
|
-
def initialize(block)
|
|
19
|
-
@block = block
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def <<(value)
|
|
23
|
-
value = value.to_s
|
|
24
|
-
value = ERB::Util.h(value) unless value.html_safe?
|
|
25
|
-
@block.call(value)
|
|
26
|
-
end
|
|
27
|
-
alias :concat :<<
|
|
28
|
-
alias :append= :<<
|
|
29
|
-
|
|
30
|
-
def safe_concat(value)
|
|
31
|
-
@block.call(value.to_s)
|
|
32
|
-
end
|
|
33
|
-
alias :safe_append= :safe_concat
|
|
34
|
-
|
|
35
|
-
def html_safe?
|
|
36
|
-
true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def html_safe
|
|
40
|
-
self
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
data/lib/action_view/context.rb
DELETED
|
@@ -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 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
|
-
# overwriten 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
|
data/lib/action_view/flows.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/string/output_safety'
|
|
2
|
-
|
|
3
|
-
module ActionView
|
|
4
|
-
class OutputFlow #:nodoc:
|
|
5
|
-
attr_reader :content
|
|
6
|
-
|
|
7
|
-
def initialize
|
|
8
|
-
@content = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Called by _layout_for to read stored values.
|
|
12
|
-
def get(key)
|
|
13
|
-
@content[key]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Called by each renderer object to set the layout contents.
|
|
17
|
-
def set(key, value)
|
|
18
|
-
@content[key] = value
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Called by content_for
|
|
22
|
-
def append(key, value)
|
|
23
|
-
@content[key] << value
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Called by provide
|
|
27
|
-
def append!(key, value)
|
|
28
|
-
@content[key] << value
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
class StreamingFlow < OutputFlow #:nodoc:
|
|
33
|
-
def initialize(view, fiber)
|
|
34
|
-
@view = view
|
|
35
|
-
@parent = nil
|
|
36
|
-
@child = view.output_buffer
|
|
37
|
-
@content = view.view_flow.content
|
|
38
|
-
@fiber = fiber
|
|
39
|
-
@root = Fiber.current.object_id
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Try to get an stored content. If the content
|
|
43
|
-
# is not available and we are inside the layout
|
|
44
|
-
# fiber, we set that we are waiting for the given
|
|
45
|
-
# key and yield.
|
|
46
|
-
def get(key)
|
|
47
|
-
return super if @content.key?(key)
|
|
48
|
-
|
|
49
|
-
if inside_fiber?
|
|
50
|
-
view = @view
|
|
51
|
-
|
|
52
|
-
begin
|
|
53
|
-
@waiting_for = key
|
|
54
|
-
view.output_buffer, @parent = @child, view.output_buffer
|
|
55
|
-
Fiber.yield
|
|
56
|
-
ensure
|
|
57
|
-
@waiting_for = nil
|
|
58
|
-
view.output_buffer, @child = @parent, view.output_buffer
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
super
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Appends the contents for the given key. This is called
|
|
66
|
-
# by provides and resumes back to the fiber if it is
|
|
67
|
-
# the key it is waiting for.
|
|
68
|
-
def append!(key, value)
|
|
69
|
-
super
|
|
70
|
-
@fiber.resume if @waiting_for == key
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
private
|
|
74
|
-
|
|
75
|
-
def inside_fiber?
|
|
76
|
-
Fiber.current.object_id != @root
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
|
2
|
-
require 'active_support/core_ext/enumerable'
|
|
3
|
-
require 'active_support/core_ext/object/blank'
|
|
4
|
-
|
|
5
|
-
module ActionView
|
|
6
|
-
# = Active Model Helpers
|
|
7
|
-
module Helpers
|
|
8
|
-
module ActiveModelHelper
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
module ActiveModelInstanceTag
|
|
12
|
-
def object
|
|
13
|
-
@active_model_object ||= begin
|
|
14
|
-
object = super
|
|
15
|
-
object.respond_to?(:to_model) ? object.to_model : object
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
%w(content_tag to_date_select_tag to_datetime_select_tag to_time_select_tag).each do |meth|
|
|
20
|
-
module_eval "def #{meth}(*) error_wrapping(super) end", __FILE__, __LINE__
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def tag(type, options, *)
|
|
24
|
-
tag_generate_errors?(options) ? error_wrapping(super) : super
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def error_wrapping(html_tag)
|
|
28
|
-
if object_has_errors?
|
|
29
|
-
Base.field_error_proc.call(html_tag, self)
|
|
30
|
-
else
|
|
31
|
-
html_tag
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def error_message
|
|
36
|
-
object.errors[@method_name]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
def object_has_errors?
|
|
42
|
-
object.respond_to?(:errors) && object.errors.respond_to?(:full_messages) && error_message.any?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def tag_generate_errors?(options)
|
|
46
|
-
options['type'] != 'hidden'
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|