step_render 0.2.0 → 0.2.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/README.md +18 -2
- data/app/controllers/step_load_controller.rb +1 -1
- data/config/routes.rb +0 -2
- data/lib/step_render.rb +7 -0
- data/lib/step_render/version.rb +1 -1
- data/lib/step_render/view_helper.rb +4 -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: 7b7796af471880e0e3213065c60c05fc56ca3a1e
|
4
|
+
data.tar.gz: 2ec679a13154dc67b7bc5cc08fc0ff03330e5f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e90b86bfde0bc44bfaad081580b2f37c6a1796edbfc9a4e4fe90f4df070e08b52361321e55690e308ed4bb6d4033b54cca45ed8721b2b583320e244e70f6a94e
|
7
|
+
data.tar.gz: a22216b01645209491439e8364d4495605bda32c24af5e759ca128d489d9efd149e0864cd22e19d7dcb015540b19c5c0c6316d30232bfb970cb4b0fbd10a1e39
|
data/README.md
CHANGED
@@ -36,7 +36,21 @@ If you do not import lazysizes to your application, load `import_step_render` me
|
|
36
36
|
</head>
|
37
37
|
```
|
38
38
|
|
39
|
-
### 2.
|
39
|
+
### 2. Add to routing
|
40
|
+
|
41
|
+
Add the following line to the `routes.rb`.
|
42
|
+
|
43
|
+
#### Example
|
44
|
+
|
45
|
+
`routes.rb`
|
46
|
+
```html
|
47
|
+
Rails.application.routes.draw do
|
48
|
+
~~~
|
49
|
+
mount_step_render
|
50
|
+
~~~
|
51
|
+
```
|
52
|
+
|
53
|
+
### 3. Use `step_render` method instead of `render` method
|
40
54
|
|
41
55
|
Replace `render` helper method used to rendering the partial with `step_render`.
|
42
56
|
Partial must be specified as an absolute path.
|
@@ -52,7 +66,9 @@ Partial must be specified as an absolute path.
|
|
52
66
|
|
53
67
|
### 1. Load javascript library
|
54
68
|
|
55
|
-
### 2.
|
69
|
+
### 2. Add to routing
|
70
|
+
|
71
|
+
### 3. Use `step_cache` method instead of `cache` method
|
56
72
|
|
57
73
|
Replace `cache` helper method used to fragment cache with `step_render`.
|
58
74
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class StepLoadController < ApplicationController
|
3
3
|
layout false
|
4
4
|
def partial
|
5
|
-
@options = Marshal.load(CGI.unescape(params[:key]))
|
5
|
+
@options = ActiveJob::Arguments.deserialize(Marshal.load(CGI.unescape(params[:key])))
|
6
6
|
render inline: "<%= render *@options %>"
|
7
7
|
end
|
8
8
|
|
data/config/routes.rb
CHANGED
data/lib/step_render.rb
CHANGED
@@ -6,3 +6,10 @@ require 'active_job/arguments'
|
|
6
6
|
module StepRender
|
7
7
|
# Your code goes here...
|
8
8
|
end
|
9
|
+
|
10
|
+
class ActionDispatch::Routing::Mapper
|
11
|
+
def mount_step_render
|
12
|
+
get 'step_render/:key', to: 'step_load#partial', as: 'step_render'
|
13
|
+
get 'step_cache/:key', to: 'step_load#fetch', as: 'step_cache'
|
14
|
+
end
|
15
|
+
end
|
data/lib/step_render/version.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module StepRender
|
3
|
+
class RequestURITooLarge < StandardError
|
4
|
+
end
|
3
5
|
module ViewHelper
|
4
6
|
def step_render(*options)
|
5
|
-
key = CGI.escape(Marshal.dump(options))
|
7
|
+
key = CGI.escape(Marshal.dump(ActiveJob::Arguments.serialize(options)))
|
6
8
|
path = step_render_path(key)
|
9
|
+
raise StepRender::RequestURITooLarge if path.to_s.size > 2083
|
7
10
|
%(<div class= "related-articles lazyload" data-include="#{path}">loading</div>).html_safe
|
8
11
|
end
|
9
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: step_render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EastResident
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|