actionpack 6.0.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +311 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +58 -0
- data/lib/abstract_controller.rb +27 -0
- data/lib/abstract_controller/asset_paths.rb +12 -0
- data/lib/abstract_controller/base.rb +267 -0
- data/lib/abstract_controller/caching.rb +66 -0
- data/lib/abstract_controller/caching/fragments.rb +150 -0
- data/lib/abstract_controller/callbacks.rb +224 -0
- data/lib/abstract_controller/collector.rb +43 -0
- data/lib/abstract_controller/error.rb +6 -0
- data/lib/abstract_controller/helpers.rb +194 -0
- data/lib/abstract_controller/logger.rb +14 -0
- data/lib/abstract_controller/railties/routes_helpers.rb +20 -0
- data/lib/abstract_controller/rendering.rb +127 -0
- data/lib/abstract_controller/translation.rb +32 -0
- data/lib/abstract_controller/url_for.rb +35 -0
- data/lib/action_controller.rb +67 -0
- data/lib/action_controller/api.rb +150 -0
- data/lib/action_controller/api/api_rendering.rb +16 -0
- data/lib/action_controller/base.rb +271 -0
- data/lib/action_controller/caching.rb +46 -0
- data/lib/action_controller/form_builder.rb +50 -0
- data/lib/action_controller/log_subscriber.rb +81 -0
- data/lib/action_controller/metal.rb +256 -0
- data/lib/action_controller/metal/basic_implicit_render.rb +13 -0
- data/lib/action_controller/metal/conditional_get.rb +280 -0
- data/lib/action_controller/metal/content_security_policy.rb +52 -0
- data/lib/action_controller/metal/cookies.rb +16 -0
- data/lib/action_controller/metal/data_streaming.rb +151 -0
- data/lib/action_controller/metal/default_headers.rb +17 -0
- 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 +74 -0
- data/lib/action_controller/metal/flash.rb +61 -0
- data/lib/action_controller/metal/force_ssl.rb +58 -0
- data/lib/action_controller/metal/head.rb +60 -0
- data/lib/action_controller/metal/helpers.rb +122 -0
- data/lib/action_controller/metal/http_authentication.rb +518 -0
- data/lib/action_controller/metal/implicit_render.rb +63 -0
- data/lib/action_controller/metal/instrumentation.rb +105 -0
- data/lib/action_controller/metal/live.rb +314 -0
- data/lib/action_controller/metal/mime_responds.rb +324 -0
- data/lib/action_controller/metal/parameter_encoding.rb +51 -0
- data/lib/action_controller/metal/params_wrapper.rb +297 -0
- data/lib/action_controller/metal/redirecting.rb +133 -0
- data/lib/action_controller/metal/renderers.rb +181 -0
- data/lib/action_controller/metal/rendering.rb +122 -0
- data/lib/action_controller/metal/request_forgery_protection.rb +456 -0
- data/lib/action_controller/metal/rescue.rb +28 -0
- data/lib/action_controller/metal/streaming.rb +223 -0
- data/lib/action_controller/metal/strong_parameters.rb +1105 -0
- data/lib/action_controller/metal/testing.rb +16 -0
- data/lib/action_controller/metal/url_for.rb +58 -0
- data/lib/action_controller/railtie.rb +89 -0
- data/lib/action_controller/railties/helpers.rb +24 -0
- data/lib/action_controller/renderer.rb +130 -0
- data/lib/action_controller/template_assertions.rb +11 -0
- data/lib/action_controller/test_case.rb +626 -0
- data/lib/action_dispatch.rb +114 -0
- data/lib/action_dispatch/http/cache.rb +226 -0
- data/lib/action_dispatch/http/content_disposition.rb +45 -0
- data/lib/action_dispatch/http/content_security_policy.rb +284 -0
- data/lib/action_dispatch/http/filter_parameters.rb +86 -0
- data/lib/action_dispatch/http/filter_redirect.rb +37 -0
- data/lib/action_dispatch/http/headers.rb +132 -0
- data/lib/action_dispatch/http/mime_negotiation.rb +177 -0
- data/lib/action_dispatch/http/mime_type.rb +350 -0
- data/lib/action_dispatch/http/mime_types.rb +50 -0
- data/lib/action_dispatch/http/parameter_filter.rb +12 -0
- data/lib/action_dispatch/http/parameters.rb +136 -0
- data/lib/action_dispatch/http/rack_cache.rb +63 -0
- data/lib/action_dispatch/http/request.rb +427 -0
- data/lib/action_dispatch/http/response.rb +534 -0
- data/lib/action_dispatch/http/upload.rb +92 -0
- data/lib/action_dispatch/http/url.rb +350 -0
- data/lib/action_dispatch/journey.rb +7 -0
- 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 +47 -0
- data/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
- data/lib/action_dispatch/journey/nodes/node.rb +141 -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 +203 -0
- data/lib/action_dispatch/journey/route.rb +204 -0
- data/lib/action_dispatch/journey/router.rb +153 -0
- data/lib/action_dispatch/journey/router/utils.rb +102 -0
- data/lib/action_dispatch/journey/routes.rb +81 -0
- data/lib/action_dispatch/journey/scanner.rb +71 -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/middleware/actionable_exceptions.rb +39 -0
- data/lib/action_dispatch/middleware/callbacks.rb +34 -0
- data/lib/action_dispatch/middleware/cookies.rb +663 -0
- data/lib/action_dispatch/middleware/debug_exceptions.rb +185 -0
- data/lib/action_dispatch/middleware/debug_locks.rb +124 -0
- data/lib/action_dispatch/middleware/debug_view.rb +68 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +181 -0
- data/lib/action_dispatch/middleware/executor.rb +21 -0
- data/lib/action_dispatch/middleware/flash.rb +300 -0
- data/lib/action_dispatch/middleware/host_authorization.rb +103 -0
- data/lib/action_dispatch/middleware/public_exceptions.rb +61 -0
- data/lib/action_dispatch/middleware/reloader.rb +12 -0
- data/lib/action_dispatch/middleware/remote_ip.rb +181 -0
- data/lib/action_dispatch/middleware/request_id.rb +43 -0
- data/lib/action_dispatch/middleware/session/abstract_store.rb +92 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +54 -0
- data/lib/action_dispatch/middleware/session/cookie_store.rb +113 -0
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +28 -0
- data/lib/action_dispatch/middleware/show_exceptions.rb +62 -0
- data/lib/action_dispatch/middleware/ssl.rb +150 -0
- data/lib/action_dispatch/middleware/stack.rb +148 -0
- data/lib/action_dispatch/middleware/static.rb +129 -0
- data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
- data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +24 -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 +29 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +62 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +38 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +24 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +15 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +165 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
- 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 +203 -0
- data/lib/action_dispatch/railtie.rb +58 -0
- data/lib/action_dispatch/request/session.rb +242 -0
- data/lib/action_dispatch/request/utils.rb +78 -0
- data/lib/action_dispatch/routing.rb +261 -0
- data/lib/action_dispatch/routing/endpoint.rb +17 -0
- data/lib/action_dispatch/routing/inspector.rb +274 -0
- data/lib/action_dispatch/routing/mapper.rb +2289 -0
- data/lib/action_dispatch/routing/polymorphic_routes.rb +351 -0
- data/lib/action_dispatch/routing/redirection.rb +201 -0
- data/lib/action_dispatch/routing/route_set.rb +887 -0
- data/lib/action_dispatch/routing/routes_proxy.rb +69 -0
- data/lib/action_dispatch/routing/url_for.rb +237 -0
- data/lib/action_dispatch/system_test_case.rb +168 -0
- data/lib/action_dispatch/system_testing/browser.rb +80 -0
- data/lib/action_dispatch/system_testing/driver.rb +68 -0
- data/lib/action_dispatch/system_testing/server.rb +31 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +97 -0
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +33 -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.rb +24 -0
- data/lib/action_dispatch/testing/assertions/response.rb +106 -0
- data/lib/action_dispatch/testing/assertions/routing.rb +234 -0
- data/lib/action_dispatch/testing/integration.rb +659 -0
- data/lib/action_dispatch/testing/request_encoder.rb +55 -0
- data/lib/action_dispatch/testing/test_process.rb +50 -0
- data/lib/action_dispatch/testing/test_request.rb +71 -0
- data/lib/action_dispatch/testing/test_response.rb +25 -0
- data/lib/action_pack.rb +26 -0
- data/lib/action_pack/gem_version.rb +17 -0
- data/lib/action_pack/version.rb +10 -0
- metadata +329 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
<header>
|
2
|
+
<h1>No template for interactive request</h1>
|
3
|
+
</header>
|
4
|
+
|
5
|
+
<div id="container">
|
6
|
+
<h2><%= h @exception.message %></h2>
|
7
|
+
|
8
|
+
<p class="summary">
|
9
|
+
<strong>NOTE!</strong><br>
|
10
|
+
Unless told otherwise, Rails expects an action to render a template with the same name,<br>
|
11
|
+
contained in a folder named after its controller.
|
12
|
+
|
13
|
+
If this controller is an API responding with 204 (No Content), <br>
|
14
|
+
which does not require a template,
|
15
|
+
then this error will occur when trying to access it via browser,<br>
|
16
|
+
since we expect an HTML template
|
17
|
+
to be rendered for such requests. If that's the case, carry on.
|
18
|
+
</p>
|
19
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<header>
|
2
|
+
<h1>Template is missing</h1>
|
3
|
+
</header>
|
4
|
+
|
5
|
+
<div id="container">
|
6
|
+
<h2><%= h @exception.message %></h2>
|
7
|
+
|
8
|
+
<%= render "rescues/source", source_extracts: @source_extracts, show_source_idx: @show_source_idx %>
|
9
|
+
<%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
|
10
|
+
<%= render template: "rescues/_request_and_response" %>
|
11
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<header>
|
2
|
+
<h1>Routing Error</h1>
|
3
|
+
</header>
|
4
|
+
<div id="container">
|
5
|
+
<h2><%= h @exception.message %></h2>
|
6
|
+
<% unless @exception.failures.empty? %>
|
7
|
+
<p>
|
8
|
+
<h2>Failure reasons:</h2>
|
9
|
+
<ol>
|
10
|
+
<% @exception.failures.each do |route, reason| %>
|
11
|
+
<li><code><%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %></li>
|
12
|
+
<% end %>
|
13
|
+
</ol>
|
14
|
+
</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
|
18
|
+
|
19
|
+
<% if @routes_inspector %>
|
20
|
+
<h2>
|
21
|
+
Routes
|
22
|
+
</h2>
|
23
|
+
|
24
|
+
<p>
|
25
|
+
Routes match in priority from top to bottom
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<%= render template: "rescues/_request_and_response" %>
|
32
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Routing Error
|
2
|
+
|
3
|
+
<%= @exception.message %>
|
4
|
+
<% unless @exception.failures.empty? %>
|
5
|
+
Failure reasons:
|
6
|
+
<% @exception.failures.each do |route, reason| %>
|
7
|
+
- <%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= render template: "rescues/_trace", format: :text %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<header>
|
2
|
+
<h1>
|
3
|
+
<%= @exception.cause.class.to_s %> in
|
4
|
+
<%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
|
5
|
+
</h1>
|
6
|
+
</header>
|
7
|
+
|
8
|
+
<div id="container">
|
9
|
+
<p>
|
10
|
+
Showing <i><%= @exception.file_name %></i> where line <b>#<%= @exception.line_number %></b> raised:
|
11
|
+
</p>
|
12
|
+
<pre><code><%= h @exception.message %></code></pre>
|
13
|
+
|
14
|
+
<%= render "rescues/source", source_extracts: @source_extracts, show_source_idx: @show_source_idx %>
|
15
|
+
|
16
|
+
<p><%= @exception.sub_template_message %></p>
|
17
|
+
|
18
|
+
<%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
|
19
|
+
<%= render template: "rescues/_request_and_response" %>
|
20
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= @exception.cause.class.to_s %> in <%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
|
2
|
+
|
3
|
+
Showing <%= @exception.file_name %> where line #<%= @exception.line_number %> raised:
|
4
|
+
<%= @exception.message %>
|
5
|
+
<%= @exception.sub_template_message %>
|
6
|
+
<%= render template: "rescues/_trace", format: :text %>
|
7
|
+
<%= render template: "rescues/_request_and_response", format: :text %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<tr class='route_row' data-helper='path'>
|
2
|
+
<td data-route-name='<%= route[:name] %>'>
|
3
|
+
<% if route[:name].present? %>
|
4
|
+
<%= route[:name] %><span class='helper'>_path</span>
|
5
|
+
<% end %>
|
6
|
+
</td>
|
7
|
+
<td>
|
8
|
+
<%= route[:verb] %>
|
9
|
+
</td>
|
10
|
+
<td data-route-path='<%= route[:path] %>'>
|
11
|
+
<%= route[:path] %>
|
12
|
+
</td>
|
13
|
+
<td>
|
14
|
+
<%=simple_format route[:reqs] %>
|
15
|
+
</td>
|
16
|
+
</tr>
|
@@ -0,0 +1,203 @@
|
|
1
|
+
<% content_for :style do %>
|
2
|
+
#route_table {
|
3
|
+
margin: 0;
|
4
|
+
border-collapse: collapse;
|
5
|
+
}
|
6
|
+
|
7
|
+
#route_table thead tr {
|
8
|
+
border-bottom: 2px solid #ddd;
|
9
|
+
}
|
10
|
+
|
11
|
+
#route_table thead tr.bottom {
|
12
|
+
border-bottom: none;
|
13
|
+
}
|
14
|
+
|
15
|
+
#route_table thead tr.bottom th {
|
16
|
+
padding: 10px 0;
|
17
|
+
line-height: 15px;
|
18
|
+
}
|
19
|
+
|
20
|
+
#route_table thead tr.bottom th input#search {
|
21
|
+
-webkit-appearance: textfield;
|
22
|
+
}
|
23
|
+
|
24
|
+
#route_table tbody tr {
|
25
|
+
border-bottom: 1px solid #ddd;
|
26
|
+
}
|
27
|
+
|
28
|
+
#route_table tbody tr:nth-child(odd) {
|
29
|
+
background: #f2f2f2;
|
30
|
+
}
|
31
|
+
|
32
|
+
#route_table tbody.exact_matches,
|
33
|
+
#route_table tbody.fuzzy_matches {
|
34
|
+
background-color: LightGoldenRodYellow;
|
35
|
+
border-bottom: solid 2px SlateGrey;
|
36
|
+
}
|
37
|
+
|
38
|
+
#route_table tbody.exact_matches tr,
|
39
|
+
#route_table tbody.fuzzy_matches tr {
|
40
|
+
background: none;
|
41
|
+
border-bottom: none;
|
42
|
+
}
|
43
|
+
|
44
|
+
#route_table td {
|
45
|
+
padding: 4px 30px;
|
46
|
+
}
|
47
|
+
|
48
|
+
#path_search {
|
49
|
+
width: 80%;
|
50
|
+
font-size: inherit;
|
51
|
+
}
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<table id='route_table' class='route_table'>
|
55
|
+
<thead>
|
56
|
+
<tr>
|
57
|
+
<th>Helper</th>
|
58
|
+
<th>HTTP Verb</th>
|
59
|
+
<th>Path</th>
|
60
|
+
<th>Controller#Action</th>
|
61
|
+
</tr>
|
62
|
+
<tr class='bottom'>
|
63
|
+
<th><%# Helper %>
|
64
|
+
<%= link_to "Path", "#", 'data-route-helper' => '_path',
|
65
|
+
title: "Returns a relative path (without the http or domain)" %> /
|
66
|
+
<%= link_to "Url", "#", 'data-route-helper' => '_url',
|
67
|
+
title: "Returns an absolute URL (with the http and domain)" %>
|
68
|
+
</th>
|
69
|
+
<th><%# HTTP Verb %>
|
70
|
+
</th>
|
71
|
+
<th><%# Path %>
|
72
|
+
<%= search_field(:path, nil, id: 'search', placeholder: "Path Match") %>
|
73
|
+
</th>
|
74
|
+
<th><%# Controller#action %>
|
75
|
+
</th>
|
76
|
+
</tr>
|
77
|
+
</thead>
|
78
|
+
<tbody class='exact_matches' id='exact_matches'>
|
79
|
+
</tbody>
|
80
|
+
<tbody class='fuzzy_matches' id='fuzzy_matches'>
|
81
|
+
</tbody>
|
82
|
+
<tbody>
|
83
|
+
<%= yield %>
|
84
|
+
</tbody>
|
85
|
+
</table>
|
86
|
+
|
87
|
+
<script type='text/javascript'>
|
88
|
+
// support forEarch iterator on NodeList
|
89
|
+
NodeList.prototype.forEach = Array.prototype.forEach;
|
90
|
+
|
91
|
+
// Enables path search functionality
|
92
|
+
function setupMatchPaths() {
|
93
|
+
// Check if there are any matched results in a section
|
94
|
+
function checkNoMatch(section, noMatchText) {
|
95
|
+
if (section.children.length <= 1) {
|
96
|
+
section.innerHTML += noMatchText;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// get JSON from URL and invoke callback with result
|
101
|
+
function getJSON(url, success) {
|
102
|
+
var xhr = new XMLHttpRequest();
|
103
|
+
xhr.open('GET', url);
|
104
|
+
xhr.onload = function() {
|
105
|
+
if (this.status == 200)
|
106
|
+
success(JSON.parse(this.response));
|
107
|
+
};
|
108
|
+
xhr.send();
|
109
|
+
}
|
110
|
+
|
111
|
+
function delayedKeyup(input, callback) {
|
112
|
+
var timeout;
|
113
|
+
input.onkeyup = function(){
|
114
|
+
if (timeout) clearTimeout(timeout);
|
115
|
+
timeout = setTimeout(callback, 300);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
// remove params or fragments
|
120
|
+
function sanitizePath(path) {
|
121
|
+
return path.replace(/[#?].*/, '');
|
122
|
+
}
|
123
|
+
|
124
|
+
var pathElements = document.querySelectorAll('#route_table [data-route-path]'),
|
125
|
+
searchElem = document.querySelector('#search'),
|
126
|
+
exactSection = document.querySelector('#exact_matches'),
|
127
|
+
fuzzySection = document.querySelector('#fuzzy_matches');
|
128
|
+
|
129
|
+
// Remove matches when no search value is present
|
130
|
+
searchElem.onblur = function(e) {
|
131
|
+
if (searchElem.value === "") {
|
132
|
+
exactSection.innerHTML = "";
|
133
|
+
fuzzySection.innerHTML = "";
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
// On key press perform a search for matching paths
|
138
|
+
delayedKeyup(searchElem, function() {
|
139
|
+
var path = sanitizePath(searchElem.value),
|
140
|
+
defaultExactMatch = '<tr><th colspan="4">Paths Matching (' + path +'):</th></tr>',
|
141
|
+
defaultFuzzyMatch = '<tr><th colspan="4">Paths Containing (' + path +'):</th></tr>',
|
142
|
+
noExactMatch = '<tr><th colspan="4">No Exact Matches Found</th></tr>',
|
143
|
+
noFuzzyMatch = '<tr><th colspan="4">No Fuzzy Matches Found</th></tr>';
|
144
|
+
|
145
|
+
if (!path)
|
146
|
+
return searchElem.onblur();
|
147
|
+
|
148
|
+
getJSON('/rails/info/routes?path=' + path, function(matches){
|
149
|
+
// Clear out results section
|
150
|
+
exactSection.innerHTML = defaultExactMatch;
|
151
|
+
fuzzySection.innerHTML = defaultFuzzyMatch;
|
152
|
+
|
153
|
+
// Display exact matches and fuzzy matches
|
154
|
+
pathElements.forEach(function(elem) {
|
155
|
+
var elemPath = elem.getAttribute('data-route-path');
|
156
|
+
|
157
|
+
if (matches['exact'].indexOf(elemPath) != -1)
|
158
|
+
exactSection.appendChild(elem.parentNode.cloneNode(true));
|
159
|
+
|
160
|
+
if (matches['fuzzy'].indexOf(elemPath) != -1)
|
161
|
+
fuzzySection.appendChild(elem.parentNode.cloneNode(true));
|
162
|
+
})
|
163
|
+
|
164
|
+
// Display 'No Matches' message when no matches are found
|
165
|
+
checkNoMatch(exactSection, noExactMatch);
|
166
|
+
checkNoMatch(fuzzySection, noFuzzyMatch);
|
167
|
+
})
|
168
|
+
})
|
169
|
+
}
|
170
|
+
|
171
|
+
// Enables functionality to toggle between `_path` and `_url` helper suffixes
|
172
|
+
function setupRouteToggleHelperLinks() {
|
173
|
+
|
174
|
+
// Sets content for each element
|
175
|
+
function setValOn(elems, val) {
|
176
|
+
elems.forEach(function(elem) {
|
177
|
+
elem.innerHTML = val;
|
178
|
+
});
|
179
|
+
}
|
180
|
+
|
181
|
+
// Sets onClick event for each element
|
182
|
+
function onClick(elems, func) {
|
183
|
+
elems.forEach(function(elem) {
|
184
|
+
elem.onclick = func;
|
185
|
+
});
|
186
|
+
}
|
187
|
+
|
188
|
+
var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]');
|
189
|
+
|
190
|
+
onClick(toggleLinks, function(){
|
191
|
+
var helperTxt = this.getAttribute("data-route-helper"),
|
192
|
+
helperElems = document.querySelectorAll('[data-route-name] span.helper');
|
193
|
+
|
194
|
+
setValOn(helperElems, helperTxt);
|
195
|
+
});
|
196
|
+
}
|
197
|
+
|
198
|
+
setupMatchPaths();
|
199
|
+
setupRouteToggleHelperLinks();
|
200
|
+
|
201
|
+
// Focus the search input after page has loaded
|
202
|
+
document.getElementById('search').focus();
|
203
|
+
</script>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_dispatch"
|
4
|
+
require "active_support/messages/rotation_configuration"
|
5
|
+
|
6
|
+
module ActionDispatch
|
7
|
+
class Railtie < Rails::Railtie # :nodoc:
|
8
|
+
config.action_dispatch = ActiveSupport::OrderedOptions.new
|
9
|
+
config.action_dispatch.x_sendfile_header = nil
|
10
|
+
config.action_dispatch.ip_spoofing_check = true
|
11
|
+
config.action_dispatch.show_exceptions = true
|
12
|
+
config.action_dispatch.tld_length = 1
|
13
|
+
config.action_dispatch.ignore_accept_header = false
|
14
|
+
config.action_dispatch.rescue_templates = {}
|
15
|
+
config.action_dispatch.rescue_responses = {}
|
16
|
+
config.action_dispatch.default_charset = nil
|
17
|
+
config.action_dispatch.rack_cache = false
|
18
|
+
config.action_dispatch.http_auth_salt = "http authentication"
|
19
|
+
config.action_dispatch.signed_cookie_salt = "signed cookie"
|
20
|
+
config.action_dispatch.encrypted_cookie_salt = "encrypted cookie"
|
21
|
+
config.action_dispatch.encrypted_signed_cookie_salt = "signed encrypted cookie"
|
22
|
+
config.action_dispatch.authenticated_encrypted_cookie_salt = "authenticated encrypted cookie"
|
23
|
+
config.action_dispatch.use_authenticated_cookie_encryption = false
|
24
|
+
config.action_dispatch.use_cookies_with_metadata = false
|
25
|
+
config.action_dispatch.perform_deep_munge = true
|
26
|
+
config.action_dispatch.return_only_media_type_on_content_type = true
|
27
|
+
|
28
|
+
config.action_dispatch.default_headers = {
|
29
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
30
|
+
"X-XSS-Protection" => "1; mode=block",
|
31
|
+
"X-Content-Type-Options" => "nosniff",
|
32
|
+
"X-Download-Options" => "noopen",
|
33
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
34
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
35
|
+
}
|
36
|
+
|
37
|
+
config.action_dispatch.cookies_rotations = ActiveSupport::Messages::RotationConfiguration.new
|
38
|
+
|
39
|
+
config.eager_load_namespaces << ActionDispatch
|
40
|
+
|
41
|
+
initializer "action_dispatch.configure" do |app|
|
42
|
+
ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
|
43
|
+
ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
|
44
|
+
ActionDispatch::Request::Utils.perform_deep_munge = app.config.action_dispatch.perform_deep_munge
|
45
|
+
ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
|
46
|
+
ActionDispatch::Response.default_headers = app.config.action_dispatch.default_headers
|
47
|
+
ActionDispatch::Response.return_only_media_type_on_content_type = app.config.action_dispatch.return_only_media_type_on_content_type
|
48
|
+
|
49
|
+
ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses)
|
50
|
+
ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates)
|
51
|
+
|
52
|
+
config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
|
53
|
+
ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
|
54
|
+
|
55
|
+
ActionDispatch.test_app = app
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,242 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rack/session/abstract/id"
|
4
|
+
|
5
|
+
module ActionDispatch
|
6
|
+
class Request
|
7
|
+
# Session is responsible for lazily loading the session from store.
|
8
|
+
class Session # :nodoc:
|
9
|
+
ENV_SESSION_KEY = Rack::RACK_SESSION # :nodoc:
|
10
|
+
ENV_SESSION_OPTIONS_KEY = Rack::RACK_SESSION_OPTIONS # :nodoc:
|
11
|
+
|
12
|
+
# Singleton object used to determine if an optional param wasn't specified.
|
13
|
+
Unspecified = Object.new
|
14
|
+
|
15
|
+
# Creates a session hash, merging the properties of the previous session if any.
|
16
|
+
def self.create(store, req, default_options)
|
17
|
+
session_was = find req
|
18
|
+
session = Request::Session.new(store, req)
|
19
|
+
session.merge! session_was if session_was
|
20
|
+
|
21
|
+
set(req, session)
|
22
|
+
Options.set(req, Request::Session::Options.new(store, default_options))
|
23
|
+
session
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.find(req)
|
27
|
+
req.get_header ENV_SESSION_KEY
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.set(req, session)
|
31
|
+
req.set_header ENV_SESSION_KEY, session
|
32
|
+
end
|
33
|
+
|
34
|
+
class Options #:nodoc:
|
35
|
+
def self.set(req, options)
|
36
|
+
req.set_header ENV_SESSION_OPTIONS_KEY, options
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.find(req)
|
40
|
+
req.get_header ENV_SESSION_OPTIONS_KEY
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(by, default_options)
|
44
|
+
@by = by
|
45
|
+
@delegate = default_options.dup
|
46
|
+
end
|
47
|
+
|
48
|
+
def [](key)
|
49
|
+
@delegate[key]
|
50
|
+
end
|
51
|
+
|
52
|
+
def id(req)
|
53
|
+
@delegate.fetch(:id) {
|
54
|
+
@by.send(:extract_session_id, req)
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def []=(k, v); @delegate[k] = v; end
|
59
|
+
def to_hash; @delegate.dup; end
|
60
|
+
def values_at(*args); @delegate.values_at(*args); end
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(by, req)
|
64
|
+
@by = by
|
65
|
+
@req = req
|
66
|
+
@delegate = {}
|
67
|
+
@loaded = false
|
68
|
+
@exists = nil # We haven't checked yet.
|
69
|
+
end
|
70
|
+
|
71
|
+
def id
|
72
|
+
options.id(@req)
|
73
|
+
end
|
74
|
+
|
75
|
+
def options
|
76
|
+
Options.find @req
|
77
|
+
end
|
78
|
+
|
79
|
+
def destroy
|
80
|
+
clear
|
81
|
+
options = self.options || {}
|
82
|
+
@by.send(:delete_session, @req, options.id(@req), options)
|
83
|
+
|
84
|
+
# Load the new sid to be written with the response.
|
85
|
+
@loaded = false
|
86
|
+
load_for_write!
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns value of the key stored in the session or
|
90
|
+
# +nil+ if the given key is not found in the session.
|
91
|
+
def [](key)
|
92
|
+
load_for_read!
|
93
|
+
@delegate[key.to_s]
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns the nested value specified by the sequence of keys, returning
|
97
|
+
# +nil+ if any intermediate step is +nil+.
|
98
|
+
def dig(*keys)
|
99
|
+
load_for_read!
|
100
|
+
keys = keys.map.with_index { |key, i| i.zero? ? key.to_s : key }
|
101
|
+
@delegate.dig(*keys)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns true if the session has the given key or false.
|
105
|
+
def has_key?(key)
|
106
|
+
load_for_read!
|
107
|
+
@delegate.key?(key.to_s)
|
108
|
+
end
|
109
|
+
alias :key? :has_key?
|
110
|
+
alias :include? :has_key?
|
111
|
+
|
112
|
+
# Returns keys of the session as Array.
|
113
|
+
def keys
|
114
|
+
load_for_read!
|
115
|
+
@delegate.keys
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns values of the session as Array.
|
119
|
+
def values
|
120
|
+
load_for_read!
|
121
|
+
@delegate.values
|
122
|
+
end
|
123
|
+
|
124
|
+
# Writes given value to given key of the session.
|
125
|
+
def []=(key, value)
|
126
|
+
load_for_write!
|
127
|
+
@delegate[key.to_s] = value
|
128
|
+
end
|
129
|
+
|
130
|
+
# Clears the session.
|
131
|
+
def clear
|
132
|
+
load_for_write!
|
133
|
+
@delegate.clear
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns the session as Hash.
|
137
|
+
def to_hash
|
138
|
+
load_for_read!
|
139
|
+
@delegate.dup.delete_if { |_, v| v.nil? }
|
140
|
+
end
|
141
|
+
alias :to_h :to_hash
|
142
|
+
|
143
|
+
# Updates the session with given Hash.
|
144
|
+
#
|
145
|
+
# session.to_hash
|
146
|
+
# # => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2"}
|
147
|
+
#
|
148
|
+
# session.update({ "foo" => "bar" })
|
149
|
+
# # => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}
|
150
|
+
#
|
151
|
+
# session.to_hash
|
152
|
+
# # => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}
|
153
|
+
def update(hash)
|
154
|
+
load_for_write!
|
155
|
+
@delegate.update stringify_keys(hash)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Deletes given key from the session.
|
159
|
+
def delete(key)
|
160
|
+
load_for_write!
|
161
|
+
@delegate.delete key.to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns value of the given key from the session, or raises +KeyError+
|
165
|
+
# if can't find the given key and no default value is set.
|
166
|
+
# Returns default value if specified.
|
167
|
+
#
|
168
|
+
# session.fetch(:foo)
|
169
|
+
# # => KeyError: key not found: "foo"
|
170
|
+
#
|
171
|
+
# session.fetch(:foo, :bar)
|
172
|
+
# # => :bar
|
173
|
+
#
|
174
|
+
# session.fetch(:foo) do
|
175
|
+
# :bar
|
176
|
+
# end
|
177
|
+
# # => :bar
|
178
|
+
def fetch(key, default = Unspecified, &block)
|
179
|
+
load_for_read!
|
180
|
+
if default == Unspecified
|
181
|
+
@delegate.fetch(key.to_s, &block)
|
182
|
+
else
|
183
|
+
@delegate.fetch(key.to_s, default, &block)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def inspect
|
188
|
+
if loaded?
|
189
|
+
super
|
190
|
+
else
|
191
|
+
"#<#{self.class}:0x#{(object_id << 1).to_s(16)} not yet loaded>"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def exists?
|
196
|
+
return @exists unless @exists.nil?
|
197
|
+
@exists = @by.send(:session_exists?, @req)
|
198
|
+
end
|
199
|
+
|
200
|
+
def loaded?
|
201
|
+
@loaded
|
202
|
+
end
|
203
|
+
|
204
|
+
def empty?
|
205
|
+
load_for_read!
|
206
|
+
@delegate.empty?
|
207
|
+
end
|
208
|
+
|
209
|
+
def merge!(other)
|
210
|
+
load_for_write!
|
211
|
+
@delegate.merge!(other)
|
212
|
+
end
|
213
|
+
|
214
|
+
def each(&block)
|
215
|
+
to_hash.each(&block)
|
216
|
+
end
|
217
|
+
|
218
|
+
private
|
219
|
+
|
220
|
+
def load_for_read!
|
221
|
+
load! if !loaded? && exists?
|
222
|
+
end
|
223
|
+
|
224
|
+
def load_for_write!
|
225
|
+
load! unless loaded?
|
226
|
+
end
|
227
|
+
|
228
|
+
def load!
|
229
|
+
id, session = @by.load_session @req
|
230
|
+
options[:id] = id
|
231
|
+
@delegate.replace(stringify_keys(session))
|
232
|
+
@loaded = true
|
233
|
+
end
|
234
|
+
|
235
|
+
def stringify_keys(other)
|
236
|
+
other.each_with_object({}) { |(key, value), hash|
|
237
|
+
hash[key.to_s] = value
|
238
|
+
}
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|