render_async 1.0.0 → 1.0.1
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 +4 -4
- data/.all-contributorsrc +19 -0
- data/README.md +53 -21
- data/app/views/render_async/_render_async.html.erb +16 -5
- data/lib/render_async/version.rb +1 -1
- data/render_async.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec789eda10aa5db3c538756631ee0e6963c6f5e
|
4
|
+
data.tar.gz: 424668e8679890bbf1b8d37bf4ec1e56a7c7cbaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd574849e185137bf16f02b7502ea4f3d0d18deedbf383b289e8f5ee0455c49d55a077f298b01a4338730e5198dda222dc2fbdb03ebe99964ba615b7763c555
|
7
|
+
data.tar.gz: 508546ce17b2ffad8e730c1050dc484b266dfb894318c5c8b9693e8e48a53e3ff42555970840d1bec4ade0dcc6b029ca5349437d51d1d8f8f575551c213f4858
|
data/.all-contributorsrc
CHANGED
@@ -58,6 +58,25 @@
|
|
58
58
|
"code",
|
59
59
|
"doc"
|
60
60
|
]
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"login": "SaladFork",
|
64
|
+
"name": "Elad Shahar",
|
65
|
+
"avatar_url": "https://avatars3.githubusercontent.com/u/107798?v=4",
|
66
|
+
"profile": "https://eladshahar.com",
|
67
|
+
"contributions": [
|
68
|
+
"code"
|
69
|
+
]
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"login": "sasharevzin",
|
73
|
+
"name": "Sasha",
|
74
|
+
"avatar_url": "https://avatars3.githubusercontent.com/u/232392?v=4",
|
75
|
+
"profile": "http://www.revzin.co.il",
|
76
|
+
"contributions": [
|
77
|
+
"code",
|
78
|
+
"doc"
|
79
|
+
]
|
61
80
|
}
|
62
81
|
]
|
63
82
|
}
|
data/README.md
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
[](https://semaphoreci.com/renderedtext/render_async)
|
2
|
-
[](#contributors)
|
3
3
|
[](https://badge.fury.io/rb/render_async)
|
4
|
+
[](https://codeclimate.com/github/renderedtext/render_async)
|
5
|
+
[](https://codeclimate.com/github/renderedtext/render_async/coverage)
|
4
6
|
|
5
7
|

|
6
8
|
|
7
9
|
# render_async
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
your
|
11
|
+
Speed up rendering Rails pages with this gem.
|
12
|
+
|
13
|
+
`render_async` renders partials to your views **asynchronously**. This is done
|
14
|
+
through adding Javascript code that does AJAX request to your controller which
|
15
|
+
then renders your partial into a Rails view.
|
12
16
|
|
13
17
|
Workflow:
|
14
18
|
|
15
|
-
1. user visits a page
|
19
|
+
1. user visits a Rails page
|
16
20
|
2. AJAX request on the controller action
|
17
21
|
3. controller renders a partial
|
18
22
|
4. partials renders in the place where you put `render_async` helper
|
@@ -98,13 +102,21 @@ Rendered code in the view:
|
|
98
102
|
|
99
103
|
<script nonce="lWaaV6eYicpt+oyOfcShYINsz0b70iR+Q1mohZqNaag=">
|
100
104
|
//<![CDATA[
|
101
|
-
|
102
|
-
(
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
(function() {
|
106
|
+
var request = new XMLHttpRequest();
|
107
|
+
var asyncRequest = true;
|
108
|
+
var SUCCESS = 200;
|
109
|
+
var ERROR = 400;
|
110
|
+
request.open("GET", "/users", asyncRequest);
|
111
|
+
|
112
|
+
request.onload = function() {
|
113
|
+
if (request.status >= SUCCESS && request.status < ERROR) {
|
114
|
+
document.getElementById("render_async_18b41794481507226109").outerHTML = request.responseText;
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
request.send();
|
119
|
+
})();
|
108
120
|
//]]>
|
109
121
|
</script>
|
110
122
|
```
|
@@ -130,13 +142,21 @@ Rendered code in the view:
|
|
130
142
|
|
131
143
|
<script>
|
132
144
|
//<![CDATA[
|
133
|
-
|
134
|
-
(
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
145
|
+
(function() {
|
146
|
+
var request = new XMLHttpRequest();
|
147
|
+
var asyncRequest = true;
|
148
|
+
var SUCCESS = 200;
|
149
|
+
var ERROR = 400;
|
150
|
+
request.open("GET", "/users", asyncRequest);
|
151
|
+
|
152
|
+
request.onload = function() {
|
153
|
+
if (request.status >= SUCCESS && request.status < ERROR) {
|
154
|
+
document.getElementById("render_async_14d7ac165d1505993721").outerHTML = request.responseText;
|
155
|
+
}
|
156
|
+
};
|
157
|
+
|
158
|
+
request.send();
|
159
|
+
})();
|
140
160
|
//]]>
|
141
161
|
</script>
|
142
162
|
```
|
@@ -172,6 +192,18 @@ In your views:
|
|
172
192
|
* You can expire cache simply by passing `:expires_in` in your view where
|
173
193
|
you cache the partial
|
174
194
|
|
195
|
+
## Using with Turbolinks
|
196
|
+
|
197
|
+
On Turbolinks applications, you may experience caching issues when navigating
|
198
|
+
away from, and then back to, a page with a `render_async` call on it. This will
|
199
|
+
likely show up as an empty div.
|
200
|
+
|
201
|
+
To resolve, tell turbolinks to reload your `render_async` call as follows:
|
202
|
+
|
203
|
+
```erb
|
204
|
+
<%= render_async events_path, 'data-turbolinks-track': 'reload' %>
|
205
|
+
```
|
206
|
+
|
175
207
|
## Development
|
176
208
|
|
177
209
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
@@ -197,8 +229,8 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
197
229
|
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
|
198
230
|
|
199
231
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
200
|
-
| [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub>Nikola Đuza</sub>](http://nikoladjuza.me/)<br />[💬](#question-nikolalsvk "Answering Questions") [🐛](https://github.com/renderedtext/render_async/issues?q=author%3Anikolalsvk "Bug reports") [💻](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Documentation") [💡](#example-nikolalsvk "Examples") [👀](#review-nikolalsvk "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3866868?v=4" width="100px;"/><br /><sub>Colin</sub>](http://www.colinxfleming.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Code") [📖](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/334273?v=4" width="100px;"/><br /><sub>Kasper Grubbe</sub>](http://kaspergrubbe.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=kaspergrubbe "Code") | [<img src="https://avatars2.githubusercontent.com/u/163584?v=4" width="100px;"/><br /><sub>Sai Ram Kunala</sub>](https://sairam.xyz/)<br />[📖](https://github.com/renderedtext/render_async/commits?author=sairam "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3065882?v=4" width="100px;"/><br /><sub>Josh Arnold</sub>](https://github.com/nightsurge)<br />[💻](https://github.com/renderedtext/render_async/commits?author=nightsurge "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nightsurge "Documentation") |
|
201
|
-
| :---: | :---: | :---: | :---: | :---: |
|
232
|
+
| [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub>Nikola Đuza</sub>](http://nikoladjuza.me/)<br />[💬](#question-nikolalsvk "Answering Questions") [🐛](https://github.com/renderedtext/render_async/issues?q=author%3Anikolalsvk "Bug reports") [💻](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Documentation") [💡](#example-nikolalsvk "Examples") [👀](#review-nikolalsvk "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3866868?v=4" width="100px;"/><br /><sub>Colin</sub>](http://www.colinxfleming.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Code") [📖](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/334273?v=4" width="100px;"/><br /><sub>Kasper Grubbe</sub>](http://kaspergrubbe.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=kaspergrubbe "Code") | [<img src="https://avatars2.githubusercontent.com/u/163584?v=4" width="100px;"/><br /><sub>Sai Ram Kunala</sub>](https://sairam.xyz/)<br />[📖](https://github.com/renderedtext/render_async/commits?author=sairam "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3065882?v=4" width="100px;"/><br /><sub>Josh Arnold</sub>](https://github.com/nightsurge)<br />[💻](https://github.com/renderedtext/render_async/commits?author=nightsurge "Code") [📖](https://github.com/renderedtext/render_async/commits?author=nightsurge "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/107798?v=4" width="100px;"/><br /><sub>Elad Shahar</sub>](https://eladshahar.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=SaladFork "Code") | [<img src="https://avatars3.githubusercontent.com/u/232392?v=4" width="100px;"/><br /><sub>Sasha</sub>](http://www.revzin.co.il)<br />[💻](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Code") [📖](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Documentation") |
|
233
|
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
202
234
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
203
235
|
|
204
236
|
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
@@ -4,10 +4,21 @@
|
|
4
4
|
|
5
5
|
<% content_for :render_async do %>
|
6
6
|
<%= javascript_tag html_options do %>
|
7
|
-
(function(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
(function() {
|
8
|
+
var request = new XMLHttpRequest();
|
9
|
+
var asyncRequest = true;
|
10
|
+
var SUCCESS = 200;
|
11
|
+
var ERROR = 400;
|
12
|
+
|
13
|
+
request.open("GET", "<%= path %>", asyncRequest);
|
14
|
+
|
15
|
+
request.onload = function() {
|
16
|
+
if (request.status >= SUCCESS && request.status < ERROR) {
|
17
|
+
document.getElementById("<%= container_id %>").outerHTML = request.responseText;
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
request.send();
|
22
|
+
})();
|
12
23
|
<% end %>
|
13
24
|
<% end %>
|
data/lib/render_async/version.rb
CHANGED
data/render_async.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Grubbe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.2'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: codeclimate-test-reporter
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.0.8
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.8
|
56
70
|
description: Load parts of your page through simple Javascript and Rails pipeline
|
57
71
|
email:
|
58
72
|
- nikolaseap@gmail.com
|
@@ -95,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
109
|
version: '0'
|
96
110
|
requirements: []
|
97
111
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.13
|
99
113
|
signing_key:
|
100
114
|
specification_version: 4
|
101
115
|
summary: Render parts of the page asynchronously with AJAX
|