pagelet_rails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -18
- data/app/helpers/pagelets_helper.rb +1 -3
- data/lib/pagelet_rails/concerns/controller.rb +11 -3
- data/lib/pagelet_rails/concerns/placeholder.rb +14 -6
- data/lib/pagelet_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5977b8becea0e8e93782f1bd974d93f57c205ade
|
4
|
+
data.tar.gz: b18dba208a3a75dedf983781bb8435034176efdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83342830b2702259cfe43dd0f360756ebc6937ffba6fca06e0f321eac5371c9eab93db85767b3899ee26cac16a061ae56d231502d32f15507bf179f1b22617f6
|
7
|
+
data.tar.gz: f9dc0e4bfa01c2b01a4b564dceab7dbb5b862ad585882b6f684c7b702e8de6ddf6a2dd6e6b7787d9bea2305e2e1467bcab7a799b10ecb139a7a7348c5d90b4c0
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/pagelet_rails.svg)](https://badge.fury.io/rb/pagelet_rails)
|
4
4
|
|
5
|
+
Warning: This gem is still in testing, so API might change.
|
6
|
+
|
5
7
|
## Why?
|
6
8
|
|
7
9
|
* Do you have pages with a lot of information?
|
@@ -144,6 +146,7 @@ Options for `remote`:
|
|
144
146
|
* `:turbolinks` - same as `:ajax` but inline for turbolinks page visit
|
145
147
|
* `false` or missing - render inline
|
146
148
|
* `:stream` - (aka BigPipe) render placeholder and render full version at the end of html. See streaming for more info.
|
149
|
+
* `:ssi` - render through [server side includes](https://en.wikipedia.org/wiki/Server_Side_Includes)
|
147
150
|
|
148
151
|
### params
|
149
152
|
|
@@ -405,24 +408,6 @@ Only relevant for `remote: true` and `remote: :turbolinks` when request is loade
|
|
405
408
|
|
406
409
|
There will be one request per group. Missing value is considered a separate group as well.
|
407
410
|
|
408
|
-
## All possible advantages of this gem's approach
|
409
|
-
|
410
|
-
This is a list of all advantages that would be made possible by using this gem's approach of abstraction and decomposition. Note: not all features are implemented yet.
|
411
|
-
|
412
|
-
- Ability to use HTTP public cache for fragment caching
|
413
|
-
- Easier fragment caching on the server
|
414
|
-
- Batch Ajax requests
|
415
|
-
- Custom loading placeholders
|
416
|
-
- Progressive rendering of the page
|
417
|
-
- Partial page updates
|
418
|
-
- "Super smart caching"
|
419
|
-
- Delay render below the fold
|
420
|
-
- Simplified development and testing
|
421
|
-
- Minimum DSL or new syntax
|
422
|
-
- Asset dependencies
|
423
|
-
- Parallel rendering
|
424
|
-
- Take advantage of HTTP2 features
|
425
|
-
|
426
411
|
## Todo
|
427
412
|
|
428
413
|
* delay load of not visible pagelets (aka. below the fold)
|
@@ -430,6 +415,9 @@ This is a list of all advantages that would be made possible by using this gem's
|
|
430
415
|
* high test coverage
|
431
416
|
* update actionpack-action_caching gem to support rails 5
|
432
417
|
|
418
|
+
## Links
|
419
|
+
|
420
|
+
- [Parallel rendering in Rails](http://antulik.com/posts/2016-10-02-parallel-rendering-in-rails.html)
|
433
421
|
|
434
422
|
## License
|
435
423
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -10,9 +10,7 @@ module PageletsHelper
|
|
10
10
|
html_opts[:class] = classes.join(' ')
|
11
11
|
|
12
12
|
html_opts['data-pagelet-container'] = true
|
13
|
-
|
14
|
-
encode_data = pagelet_options.original_options.to_h.except('remote')
|
15
|
-
html_opts['data-pagelet-options'] = PageletRails::Encryptor.encode(encode_data)
|
13
|
+
html_opts['data-pagelet-options'] = pagelet_encoded_original_options
|
16
14
|
|
17
15
|
if pagelet_options.ajax_group
|
18
16
|
html_opts['data-pagelet-group'] = pagelet_options.ajax_group
|
@@ -12,9 +12,13 @@ module PageletRails::Concerns::Controller
|
|
12
12
|
prepend_before_action :merge_original_pagelet_options
|
13
13
|
prepend_before_action :append_pagelet_view_paths
|
14
14
|
|
15
|
+
append_view_path 'app/pagelets/'
|
16
|
+
append_view_path 'test/dummy/app/pagelets/' if Rails.env.test?
|
17
|
+
|
15
18
|
layout :layout_name
|
16
19
|
|
17
20
|
helper_method :pagelet_request?
|
21
|
+
helper_method :pagelet_encoded_original_options
|
18
22
|
|
19
23
|
pagelet_options layout: 'container'
|
20
24
|
end
|
@@ -32,9 +36,6 @@ module PageletRails::Concerns::Controller
|
|
32
36
|
private
|
33
37
|
|
34
38
|
def append_pagelet_view_paths
|
35
|
-
self.view_paths.unshift 'app/pagelets/'
|
36
|
-
self.view_paths.unshift 'test/dummy/app/pagelets/' if Rails.env.test?
|
37
|
-
|
38
39
|
# lookup_context.prefixes.clear
|
39
40
|
view = "#{controller_name}/views"
|
40
41
|
if lookup_context.prefixes.exclude?(view)
|
@@ -54,6 +55,11 @@ module PageletRails::Concerns::Controller
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
58
|
+
def pagelet_encoded_original_options
|
59
|
+
encode_data = pagelet_options.original_options.to_h.except('remote')
|
60
|
+
PageletRails::Encryptor.encode(encode_data)
|
61
|
+
end
|
62
|
+
|
57
63
|
def pagelet_render_remotely?
|
58
64
|
case pagelet_options.remote
|
59
65
|
when :stream
|
@@ -64,6 +70,8 @@ module PageletRails::Concerns::Controller
|
|
64
70
|
render_remotely = !is_turbolinks_request
|
65
71
|
when true, :ajax
|
66
72
|
render_remotely = true
|
73
|
+
when :ssi
|
74
|
+
render_remotely = true
|
67
75
|
else
|
68
76
|
render_remotely = false
|
69
77
|
end
|
@@ -23,13 +23,21 @@ module PageletRails::Concerns::Placeholder
|
|
23
23
|
data = params.deep_dup
|
24
24
|
data.permit!
|
25
25
|
|
26
|
-
if pagelet_options.remote
|
27
|
-
|
28
|
-
|
26
|
+
if pagelet_options.remote == :ssi
|
27
|
+
path = url_for data.merge(
|
28
|
+
only_path: true,
|
29
|
+
original_pagelet_options: pagelet_encoded_original_options
|
30
|
+
)
|
31
|
+
render body: "<!--#include virtual=\"#{path}\" -->"
|
32
|
+
else
|
33
|
+
if pagelet_options.remote != :stream
|
34
|
+
pagelet_options html: { 'data-widget-url' => url_for(data) }
|
35
|
+
end
|
29
36
|
|
30
|
-
|
31
|
-
|
37
|
+
default_view = '/layouts/pagelet_rails/loading_placeholder'
|
38
|
+
view = pagelet_options.placeholder.try(:[], :view).presence || default_view
|
32
39
|
|
33
|
-
|
40
|
+
render view
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagelet_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Katunin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|