turbolinks_render 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fcbcc1fa09e0051256ce05c25db9b479796feccbf44f708457a99774d97df18
|
4
|
+
data.tar.gz: 80e2533ddda4ada30a39abef941e65ad0bdce95ae0cf21bd528fdf2ded83842f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2664e7817e907db81c17b8d07d67442d828ace135114c984cfcbf5f030c642afbe64124802a79b3424aa3da2d557a15162c1f644d6cfc7994a678883bfb422b8
|
7
|
+
data.tar.gz: c68aa6038320c61c57dd79a84ceec14105d804097b57d80ddb6033e499e28186b6bc6ba17c065d08f18b779d62525c0ad94d70ec66a092ec3a6f406836dd4fe9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
[![CircleCI](https://circleci.com/gh/jorgemanrubia/turbolinks_render.svg?style=svg)](https://circleci.com/gh/jorgemanrubia/turbolinks_render)
|
2
2
|
|
3
|
-
|
3
|
+
# turbolinks_render
|
4
4
|
|
5
5
|
Use `render` in your Rails controllers and handle the response with Turbolinks.
|
6
6
|
|
data/lib/turbolinks_render.rb
CHANGED
@@ -7,10 +7,10 @@ module TurbolinksRender
|
|
7
7
|
|
8
8
|
if request.xhr? && !request.get_header('X-Turbolinks-Render-Candidate')
|
9
9
|
body = template.render(template: file, layout: false, formats: [:text])
|
10
|
-
format =
|
10
|
+
format = 'text/plain'
|
11
11
|
else
|
12
|
-
body = template.render(template: file, layout:
|
13
|
-
format =
|
12
|
+
body = template.render(template: file, layout: 'rescues/layout')
|
13
|
+
format = 'text/html'
|
14
14
|
end
|
15
15
|
render(wrapper.status_code, body, format)
|
16
16
|
end
|
@@ -26,14 +26,14 @@ module TurbolinksRender
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def html_response?
|
29
|
-
headers['Content-Type'] =~ /
|
29
|
+
headers['Content-Type'] =~ %r{text/html}
|
30
30
|
end
|
31
31
|
|
32
32
|
def body
|
33
33
|
@body ||= begin
|
34
34
|
body = ''
|
35
35
|
# Response does not have to be an Enumerable. It just has to respond to #each according to Rack spec
|
36
|
-
response.each {|part| body << part}
|
36
|
+
response.each { |part| body << part }
|
37
37
|
body
|
38
38
|
end
|
39
39
|
end
|
@@ -47,7 +47,7 @@ module TurbolinksRender
|
|
47
47
|
var newSpanshot = Turbolinks.Snapshot.fromHTMLString(htmlContent);
|
48
48
|
var nullCallback = function(){};
|
49
49
|
var nullDelegate = {viewInvalidated: nullCallback, viewWillRender: nullCallback, viewRendered: nullCallback};
|
50
|
-
|
50
|
+
|
51
51
|
var renderer = new Turbolinks.SnapshotRenderer(currentSnapshot, newSpanshot, false);
|
52
52
|
if(!renderer.shouldRender()){
|
53
53
|
renderer = new Turbolinks.ErrorRenderer(htmlContent);
|
@@ -56,6 +56,7 @@ module TurbolinksRender
|
|
56
56
|
renderer.render(nullCallback);
|
57
57
|
}
|
58
58
|
Turbolinks.clearCache();
|
59
|
+
Turbolinks.dispatch('turbolinks:before-cache');
|
59
60
|
renderWithTurbolinks("#{escaped_html}");
|
60
61
|
Turbolinks.dispatch('turbolinks:load');
|
61
62
|
window.scroll(0, 0);
|
@@ -78,8 +79,8 @@ module TurbolinksRender
|
|
78
79
|
|
79
80
|
return [rack_status, rack_headers, rack_response] unless render_with_turbolinks?(request, response)
|
80
81
|
|
81
|
-
rack_headers[
|
82
|
-
rack_headers[
|
82
|
+
rack_headers['Content-Type'] = 'text/javascript'
|
83
|
+
rack_headers['Content-Length'] = response.turbolinks_body.bytesize.to_s
|
83
84
|
|
84
85
|
[rack_status, rack_headers, [response.turbolinks_body]]
|
85
86
|
end
|
@@ -88,7 +89,7 @@ module TurbolinksRender
|
|
88
89
|
|
89
90
|
def render_with_turbolinks?(request, response)
|
90
91
|
request.candidate_for_turbolinks? && response.candidate_for_turbolinks? &&
|
91
|
-
|
92
|
+
(request.turbolinks_render_option || (render_with_turbolinks_by_default? && request.turbolinks_render_option != false))
|
92
93
|
end
|
93
94
|
|
94
95
|
def render_with_turbolinks_by_default?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbolinks_render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: capybara
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: chromedriver-helper
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: puma
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sqlite3
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -156,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
|
160
|
-
rubygems_version: 2.7.6
|
159
|
+
rubygems_version: 3.0.3
|
161
160
|
signing_key:
|
162
161
|
specification_version: 4
|
163
162
|
summary: Use Rails render with Turbolinks
|