pagelet_rails 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.travis.yml +14 -0
- data/Appraisals +14 -0
- data/CHANGELOG.md +35 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -40
- data/app/assets/javascripts/pagelet_rails.js +4 -8
- data/app/controllers/pagelet_controller.rb +0 -1
- data/app/helpers/pagelets_helper.rb +9 -2
- data/bin/rails +13 -0
- data/gemfiles/rails_4.2.8.gemfile +12 -0
- data/gemfiles/rails_5.0.2.gemfile +12 -0
- data/gemfiles/rails_5.1.0.gemfile +12 -0
- data/lib/pagelet_rails/concerns/cache.rb +13 -11
- data/lib/pagelet_rails/concerns/controller.rb +1 -1
- data/lib/pagelet_rails/encryptor.rb +1 -1
- data/lib/pagelet_rails/version.rb +1 -1
- data/pagelet_rails.gemspec +31 -0
- data/test/benchmarks/ssi_benchmark.rb +47 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/dyno_controller.rb +13 -0
- data/test/dummy/app/controllers/pagelet_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/pagelets/params_example/params_example_controller.rb +7 -0
- data/test/dummy/app/pagelets/params_example/views/show.html.erb +3 -0
- data/test/dummy/app/pagelets/render_inline/render_inline_controller.rb +8 -0
- data/test/dummy/app/pagelets/static_text/static_text_controller.rb +12 -0
- data/test/dummy/app/pagelets/static_text/views/show.html.erb +1 -0
- data/test/dummy/app/views/dyno/benchmark.html.erb +4 -0
- data/test/dummy/app/views/dyno/params_example.html.erb +1 -0
- data/test/dummy/app/views/dyno/ssi.html.erb +2 -0
- data/test/dummy/app/views/dyno/static_text.html.erb +1 -0
- data/test/dummy/app/views/dyno/static_text_ajax.html.erb +1 -0
- data/test/dummy/app/views/dyno/test.html.erb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +29 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/schema.rb +15 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/dyno_test.rb +20 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/lib/options_test.rb +62 -0
- data/test/pagelet_rails_test.rb +7 -0
- data/test/test_helper.rb +30 -0
- metadata +252 -5
- data/MIT-LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a94ff187b504886484c7a6ea7f3e7606ee8a1b4
|
4
|
+
data.tar.gz: da24f459abc2b52b87bc687332467e5d37383bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 944a95a469bf4d377f17ba270bdd2dcf53034e6218b39415ae5529b60e649b51d8f0d427ef0d52e5e94ad1acd5083d20fc02ab42d14b065415b8d52456955507
|
7
|
+
data.tar.gz: bfec15b0d980d68efac76521ef017ef82ecd0713babce334f1e8ed5708e5a1e87eda3ff83c57dd72ac73c6579517d6512f701ac5e0623320525825a8d5371cf8
|
data/.gitignore
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Ignore bundler config.
|
2
|
+
/.bundle
|
3
|
+
.ruby-version
|
4
|
+
|
5
|
+
# Ignore Gemfile.lock
|
6
|
+
/Gemfile.lock
|
7
|
+
/gemfiles/*.gemfile.lock
|
8
|
+
|
9
|
+
# Ignore test files
|
10
|
+
/coverage
|
11
|
+
|
12
|
+
# Ignore dummy app files
|
13
|
+
/test/dummy/db/*.sqlite3
|
14
|
+
/test/dummy/db/*.sqlite3-journal
|
15
|
+
/test/dummy/log/*.log
|
16
|
+
/test/dummy/tmp/
|
17
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
dist: trusty
|
2
|
+
language: ruby
|
3
|
+
sudo: false
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- 2.2.7
|
7
|
+
- 2.3.4
|
8
|
+
- 2.4.1
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/rails_4.2.8.gemfile
|
11
|
+
- gemfiles/rails_5.0.2.gemfile
|
12
|
+
- gemfiles/rails_5.1.0.gemfile
|
13
|
+
after_success:
|
14
|
+
- bundle exec codeclimate-test-reporter
|
data/Appraisals
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
RAILS_VERSIONS = %w(
|
2
|
+
4.2.8
|
3
|
+
5.0.2
|
4
|
+
5.1.0
|
5
|
+
)
|
6
|
+
|
7
|
+
RAILS_VERSIONS.each do |version|
|
8
|
+
appraise "rails_#{version}" do
|
9
|
+
gem 'rails', version
|
10
|
+
|
11
|
+
# http://stackoverflow.com/questions/43886586/minitest-plugin-rb9-getting-wrong-number-of-arguments
|
12
|
+
gem 'minitest', '~> 5.10', '!= 5.10.2'
|
13
|
+
end
|
14
|
+
end
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
### 0.1.7
|
2
|
+
|
3
|
+
- fixed Rails 5.1
|
4
|
+
- added compatibility with Rails 2.4
|
5
|
+
|
6
|
+
### 0.1.6
|
7
|
+
|
8
|
+
- fixed #3 include more data in pagelet request
|
9
|
+
|
10
|
+
### 0.1.5
|
11
|
+
|
12
|
+
- fixed #2 when routes were causing error
|
13
|
+
|
14
|
+
### 0.1.4
|
15
|
+
|
16
|
+
- added support for server side includes rendering mode
|
17
|
+
|
18
|
+
### 0.1.3
|
19
|
+
|
20
|
+
- fixed #1 - ajax loading of single pagelet fails over https
|
21
|
+
- fixed templates
|
22
|
+
- fixed placeholder style
|
23
|
+
|
24
|
+
### 0.1.2
|
25
|
+
|
26
|
+
- removed 'slim' dependency
|
27
|
+
- rails 4 support
|
28
|
+
|
29
|
+
### 0.1.1
|
30
|
+
|
31
|
+
- fixed bugs with missing styles and dependencies
|
32
|
+
|
33
|
+
### 0.1.0
|
34
|
+
|
35
|
+
- extracted as a separate gem
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright 2016 Anton Katunin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
# PageletRails
|
2
2
|
|
3
|
+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/antulik/pagelet_rails/master/LICENSE)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/pagelet_rails.svg)](https://badge.fury.io/rb/pagelet_rails)
|
5
|
+
[![Build Status](https://travis-ci.org/antulik/pagelet_rails.svg?branch=master)](https://travis-ci.org/antulik/pagelet_rails)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/antulik/pagelet_rails/badges/gpa.svg)](https://codeclimate.com/github/antulik/pagelet_rails)
|
7
|
+
[![Test Coverage](https://codeclimate.com/github/antulik/pagelet_rails/badges/coverage.svg)](https://codeclimate.com/github/antulik/pagelet_rails/coverage)
|
4
8
|
|
5
9
|
Warning: This gem is still in testing, so API might change.
|
6
10
|
|
7
11
|
## Why?
|
8
12
|
|
9
|
-
* Do you have pages with a lot of information?
|
13
|
+
* Do you have pages with a lot of information?
|
10
14
|
* The pages where you need to get data from 5 or 10 different sources?
|
11
15
|
* What if one of them is slow?
|
12
16
|
* Does this mean your users have to wait?
|
13
17
|
|
14
18
|
Don't make your users wait for page to load.
|
15
|
-
|
19
|
+
|
16
20
|
[View Demo Project](http://polar-river-18908.herokuapp.com)
|
17
|
-
|
21
|
+
|
18
22
|
## Example
|
19
|
-
|
23
|
+
|
20
24
|
![](https://camo.githubusercontent.com/50f4078cc4015e3df89afc753a5ff79828ac0e8e/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f662e636c2e6c792f6974656d732f303031323133314d324b3147335831483276314f2f313433303033383036373738372e6a7067)
|
21
25
|
|
22
|
-
For example let's take facebook user home page. It has A LOT of data, but it loads very quickly. How? The answer is [perceived performance](https://en.wikipedia.org/wiki/Perceived_performance). It's not about in how many milliseconds you can serve request, but how fast it **feels** to the user.
|
26
|
+
For example let's take facebook user home page. It has A LOT of data, but it loads very quickly. How? The answer is [perceived performance](https://en.wikipedia.org/wiki/Perceived_performance). It's not about in how many milliseconds you can serve request, but how fast it **feels** to the user.
|
23
27
|
|
24
28
|
The page body is served instantly and all the data is loaded after. Even for facebook it takes multiple seconds to fully load the page. But it feels instant, that it's all about.
|
25
29
|
|
@@ -33,12 +37,12 @@ Originally I saw such solution implemented at Facebook and Linkedin. Each page c
|
|
33
37
|
|
34
38
|
## What is Pagelet?
|
35
39
|
|
36
|
-
You can break a web page into number of sections, where each one is responsible for its own functionality. Pagelet is the name for each section. It is a part of the page which has it's own route, controller and view.
|
40
|
+
You can break a web page into number of sections, where each one is responsible for its own functionality. Pagelet is the name for each section. It is a part of the page which has it's own route, controller and view.
|
41
|
+
|
42
|
+
The closest alternative in ruby is [cells gem](https://github.com/apotonick/cells). After using it for long time I've faced many limitations of its approach. Cells has a custom Rails-like syntax but not quite. That is frustrating as you have to learn and remember those differences. The second issue, and the biggest, cells are internal only and not designed to be routable. This stops many great possibilities for improving perceived performance, as request has to wait for all cells to render.
|
37
43
|
|
38
|
-
The closest alternative in ruby is [cells gem](https://github.com/apotonick/cells). After using it for long time I've faced many limitations of its approach. Cells has a custom Rails-like syntax but not quite. That is frustrating as you have to learn and remember those differences. The second issue, and the biggest, cells are internal only and not designed to be routable. This stops many great possibilities for improving perceived performance, as request has to wait for all cells to render.
|
39
|
-
|
40
44
|
Pagelet_rails is built on top of Rails and uses it as much as possible. The main philosophy: **Do not reinvent the wheel, build on shoulders of giants.**
|
41
|
-
|
45
|
+
|
42
46
|
|
43
47
|
# Usage
|
44
48
|
|
@@ -85,16 +89,16 @@ app
|
|
85
89
|
```ruby
|
86
90
|
# app/pagelets/current_time/current_time_controller.rb
|
87
91
|
class CurrentTime::CurrentTimeController < ApplicationController
|
88
|
-
include PageletRails::Concerns::Controller
|
89
|
-
|
92
|
+
include PageletRails::Concerns::Controller
|
93
|
+
|
90
94
|
# add pagelets_current_time_path route
|
91
95
|
# which gives "/pagelets/current_time" url route
|
92
|
-
pagelet_resource only: [:show]
|
96
|
+
pagelet_resource only: [:show]
|
93
97
|
|
94
98
|
def show
|
95
99
|
end
|
96
100
|
end
|
97
|
-
```
|
101
|
+
```
|
98
102
|
|
99
103
|
```erb
|
100
104
|
<!-- Please note view path -->
|
@@ -130,7 +134,7 @@ And now use it anywhere in your view
|
|
130
134
|
|
131
135
|
## Pagelet view helper
|
132
136
|
|
133
|
-
`pagelet` helper allows you to render pagelets in views. Name of pagelet is its path.
|
137
|
+
`pagelet` helper allows you to render pagelets in views. Name of pagelet is its path.
|
134
138
|
|
135
139
|
For example pagelet with route `pagelets_current_time_path` will have `pagelets_current_time` name.
|
136
140
|
|
@@ -198,22 +202,22 @@ You can pass any other data and it will be available in `pagelet_options`
|
|
198
202
|
```ruby
|
199
203
|
class CurrentTime::CurrentTimeController < ::ApplicationController
|
200
204
|
include PageletRails::Concerns::Controller
|
201
|
-
|
205
|
+
|
202
206
|
# Set default option for all actions
|
203
|
-
pagelet_options remote: true
|
204
|
-
|
207
|
+
pagelet_options remote: true
|
208
|
+
|
205
209
|
# set option for :show and :edit actions only
|
206
|
-
pagelet_options :show, :edit, remote: :turbolinks
|
207
|
-
|
210
|
+
pagelet_options :show, :edit, remote: :turbolinks
|
211
|
+
|
208
212
|
def show
|
209
213
|
end
|
210
|
-
|
214
|
+
|
211
215
|
def new
|
212
216
|
end
|
213
|
-
|
217
|
+
|
214
218
|
def edit
|
215
219
|
end
|
216
|
-
|
220
|
+
|
217
221
|
end
|
218
222
|
```
|
219
223
|
|
@@ -226,37 +230,37 @@ end
|
|
226
230
|
|
227
231
|
## Inline routes
|
228
232
|
|
229
|
-
Because pagelets are small you will have many of them. In order to keep them under control pagelet_rails provides helpers.
|
233
|
+
Because pagelets are small you will have many of them. In order to keep them under control pagelet_rails provides helpers.
|
230
234
|
|
231
235
|
You can inline routes inside you controller.
|
232
236
|
|
233
237
|
```ruby
|
234
238
|
class CurrentTime::CurrentTimeController < ::ApplicationController
|
235
239
|
include PageletRails::Concerns::Controller
|
236
|
-
|
240
|
+
|
237
241
|
pagelet_resource only: [:show]
|
238
242
|
# same as in config/routes.rb:
|
239
243
|
#
|
240
244
|
# resource :current_time, only: [:show]
|
241
245
|
#
|
242
|
-
|
246
|
+
|
243
247
|
pagelet_resources
|
244
248
|
# same as in config/routes.rb:
|
245
249
|
#
|
246
250
|
# resources :current_time
|
247
251
|
#
|
248
|
-
|
252
|
+
|
249
253
|
pagelet_routes do
|
250
254
|
# this is the same context as in config/routes.rb:
|
251
255
|
get 'show_me_time' => 'current_time/current_time#show'
|
252
256
|
end
|
253
|
-
|
257
|
+
|
254
258
|
end
|
255
259
|
```
|
256
260
|
|
257
261
|
## Pagelet cache
|
258
262
|
|
259
|
-
Cache of pagelet rails is built on top of [actionpack-action_caching gem](https://github.com/rails/actionpack-action_caching).
|
263
|
+
Cache of pagelet rails is built on top of [actionpack-action_caching gem](https://github.com/rails/actionpack-action_caching).
|
260
264
|
|
261
265
|
Simple example
|
262
266
|
|
@@ -264,7 +268,7 @@ Simple example
|
|
264
268
|
# app/pagelets/current_time/current_time_controller.rb
|
265
269
|
class CurrentTime::CurrentTimeController < ::ApplicationController
|
266
270
|
include PageletRails::Concerns::Controller
|
267
|
-
|
271
|
+
|
268
272
|
pagelet_options expires_in: 10.minutes
|
269
273
|
|
270
274
|
def show
|
@@ -275,7 +279,7 @@ end
|
|
275
279
|
|
276
280
|
### cache_path
|
277
281
|
|
278
|
-
Is a hash of additional parameters for cache key.
|
282
|
+
Is a hash of additional parameters for cache key.
|
279
283
|
|
280
284
|
* `Hash` - static hash
|
281
285
|
* `Proc` - dynamic params, it must return hash. Eg. `Proc.new { params.permit(:sort_by) }`
|
@@ -284,7 +288,7 @@ Is a hash of additional parameters for cache key.
|
|
284
288
|
|
285
289
|
### expires_in
|
286
290
|
|
287
|
-
Set the cache expiry. For example `expires_in: 1.hour`.
|
291
|
+
Set the cache expiry. For example `expires_in: 1.hour`.
|
288
292
|
|
289
293
|
Warning: if `expires_in` is missing, it will be cached indefinitely.
|
290
294
|
|
@@ -330,7 +334,7 @@ In the example above cache will be scoped per `user_id` and for 5 minutes unless
|
|
330
334
|
</p>
|
331
335
|
</div>
|
332
336
|
```
|
333
|
-
Please note `remote: true` option for `link_to`.
|
337
|
+
Please note `remote: true` option for `link_to`.
|
334
338
|
|
335
339
|
This is default Rails functionality with small addition. If that link is inside pagelet, than controller response will be replaced in that pagelet.
|
336
340
|
|
@@ -338,14 +342,14 @@ This is default Rails functionality with small addition. If that link is inside
|
|
338
342
|
# app/pagelets/current_time/current_time_controller.rb
|
339
343
|
class CurrentTime::CurrentTimeController < ::ApplicationController
|
340
344
|
include PageletRails::Concerns::Controller
|
341
|
-
|
345
|
+
|
342
346
|
pagelet_resource only: [:show]
|
343
347
|
|
344
348
|
def show
|
345
349
|
end
|
346
350
|
|
347
351
|
end
|
348
|
-
```
|
352
|
+
```
|
349
353
|
|
350
354
|
This will partially update the page and replace only that pagelet.
|
351
355
|
|
@@ -356,12 +360,14 @@ This is the most efficient way to deliver data with minimum delays. The placehol
|
|
356
360
|
|
357
361
|
This mode requires rendering of templates with [streaming mode](http://api.rubyonrails.org/classes/ActionController/Streaming.html) enabled.
|
358
362
|
|
363
|
+
Warning: Session and Cookies are currently not supported in streaming mode.
|
364
|
+
|
359
365
|
```ruby
|
360
366
|
#...
|
361
367
|
def show
|
362
368
|
render :show, stream: true
|
363
369
|
end
|
364
|
-
#...
|
370
|
+
#...
|
365
371
|
```
|
366
372
|
|
367
373
|
In you layout add `pagelet_stream` right before `</body>` tag.
|
@@ -376,7 +382,7 @@ In you layout add `pagelet_stream` right before `</body>` tag.
|
|
376
382
|
</body>
|
377
383
|
```
|
378
384
|
|
379
|
-
Usage:
|
385
|
+
Usage:
|
380
386
|
|
381
387
|
```erb
|
382
388
|
<%= pagelet :pagelets_current_time, remote: :stream %>
|
@@ -384,15 +390,15 @@ Usage:
|
|
384
390
|
|
385
391
|
**Warning!!!** You also should have webserver compatible for streaming like puma, passenger or unicorn (requires special config).
|
386
392
|
|
387
|
-
**Warning!!!** you need to have multiple threads/processes configured in the web server. This is required so the page could fetch assets while content is streaming.
|
388
|
-
|
389
|
-
Finally if everything is done right you should see significant rendering speed improvements especially on old browsers, slow network or with cold cache.
|
393
|
+
**Warning!!!** you need to have multiple threads/processes configured in the web server. This is required so the page could fetch assets while content is streaming.
|
394
|
+
|
395
|
+
Finally if everything is done right you should see significant rendering speed improvements especially on old browsers, slow network or with cold cache.
|
390
396
|
|
391
397
|
|
392
398
|
### Super smart caching
|
393
399
|
|
394
400
|
Probably one of the coolest functionality of pagelet_rails is "super smart caching". It allows you to render pagelets through ajax and cache them, but if page is reloaded the pagelet is rendered instantly from cache.
|
395
|
-
|
401
|
+
|
396
402
|
So on the first page load user sees "Loading..." blocks, but after the content is instant.
|
397
403
|
|
398
404
|
The best thing, it's enabled by default if pagelet has caching enabled and is rendering through ajax request.
|
@@ -410,6 +416,8 @@ There will be one request per group. Missing value is considered a separate grou
|
|
410
416
|
|
411
417
|
## Todo
|
412
418
|
|
419
|
+
* assets support with webpacker in rails 5.1
|
420
|
+
* session (and CSRF) support in streaming mode
|
413
421
|
* delay load of not visible pagelets (aka. below the fold)
|
414
422
|
* do not load pagelets which are not visible to the user until user scrolls down. For example like Youtube comments.
|
415
423
|
* high test coverage
|
@@ -38,7 +38,7 @@
|
|
38
38
|
};
|
39
39
|
|
40
40
|
root.loadThroughBatchProxy = function(urls) {
|
41
|
-
if (urls.length
|
41
|
+
if (urls.length === 0) { return; }
|
42
42
|
|
43
43
|
var prev_index = 0;
|
44
44
|
|
@@ -59,7 +59,7 @@
|
|
59
59
|
do {
|
60
60
|
end_index = text.indexOf("\n\n//\n\n", prev_index);
|
61
61
|
|
62
|
-
if (end_index
|
62
|
+
if (end_index !== -1) {
|
63
63
|
var new_text = text.substring(prev_index, end_index);
|
64
64
|
|
65
65
|
eval(new_text);
|
@@ -69,7 +69,7 @@
|
|
69
69
|
// console.log(new_text);
|
70
70
|
}
|
71
71
|
|
72
|
-
} while (end_index
|
72
|
+
} while (end_index !== -1);
|
73
73
|
}
|
74
74
|
});
|
75
75
|
};
|
@@ -102,7 +102,7 @@
|
|
102
102
|
if (groups.hasOwnProperty(group_name)) {
|
103
103
|
var group = groups[group_name];
|
104
104
|
|
105
|
-
if (group.length
|
105
|
+
if (group.length === 1) {
|
106
106
|
root.loadDirectly(group[0]);
|
107
107
|
} else {
|
108
108
|
var urls = group.map(function(e) { return e.url; });
|
@@ -179,7 +179,3 @@
|
|
179
179
|
|
180
180
|
initialise();
|
181
181
|
})(window);
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
@@ -70,13 +70,20 @@ module PageletsHelper
|
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
parent_params =
|
74
|
+
if params.respond_to?(:to_unsafe_h)
|
75
|
+
params.to_unsafe_h
|
76
|
+
else
|
77
|
+
params.to_h
|
78
|
+
end
|
79
|
+
|
80
|
+
p_options.deep_merge! parent_params: parent_params
|
74
81
|
|
75
82
|
c = controller_class.new
|
76
83
|
c.pagelet_options p_options
|
77
84
|
c.pagelet_options original_options: p_options
|
78
85
|
|
79
|
-
env = request.env.select do |key,
|
86
|
+
env = request.env.select do |key, _value|
|
80
87
|
case key.to_s
|
81
88
|
when /^action_dispatch\.request/i,
|
82
89
|
/^action_controller/i,
|