step_render 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85b293e7d7eacb9f44c36874af70c8d25640dfc5
4
- data.tar.gz: f2f55fa8d6465eb0d29217409b0b0f4e8e920187
3
+ metadata.gz: bba6f547ad110f7ade5623bf045adb5ae2aab594
4
+ data.tar.gz: 6af12bfab5fa1c24dda036dbac35056feb9a0efe
5
5
  SHA512:
6
- metadata.gz: b5e99963dd835207e3bf06856d1152588771066d295ec8171a9300805a3217df37b812311f3b927f1f812a0963ef1e8bbb779578553010b75e714abd02f768a3
7
- data.tar.gz: 9b9e976413489f7477eb8626818b5135d2fd5eabd68198f8aae464dd7f18e350c538187a41ca4b7233bdfc028e2405674fa9aafb8a4b61c1f9d425de081c732f
6
+ metadata.gz: d558f6d89e80bb8e6e5ac831cb462a294dd48a428619f0cecb7dadd7be90d32ddbe95d68caeffee24b898b230f2f8926967e239489bc7308a03cd697dc7684f8
7
+ data.tar.gz: eb38b11ae4f5b4b391274b8638c614e7125e95fff1b788c1ed31e790d332fa19673c58c1c1eb6c165098d437d37ed88bae385c2320724836c6c3709add6f4eee
data/README.md CHANGED
@@ -3,6 +3,8 @@ It is very easy to enable lazy loading of partial with scroll in views.
3
3
 
4
4
  You only use `step_render` method instead of `render` method.
5
5
 
6
+ Likewise, you can lazy load a fragment cache.
7
+
6
8
  ## Installation
7
9
  Add this line to your application's Gemfile:
8
10
 
@@ -15,7 +17,7 @@ And then execute:
15
17
  $ bundle
16
18
  ```
17
19
 
18
- ## Usage
20
+ ## Usage 1: Lazy Load Partial
19
21
 
20
22
  ### 1. Load javascript library
21
23
 
@@ -46,6 +48,23 @@ Partial must be specified as an absolute path.
46
48
  <%= step_render 'top/partial_name' %>
47
49
  ```
48
50
 
51
+ ## Usage 2: Lazy Load fragment cache
52
+
53
+ ### 1. Load javascript library
54
+
55
+ ### 2. Use `step_cache` method instead of `cache` method
56
+
57
+ Replace `cache` helper method used to fragment cache with `step_render`.
58
+
59
+ #### Example
60
+
61
+ `app/views/top/index.html.erb`
62
+ ```html
63
+ <%= step_cache 'cache_key', skip_digest: true, expires_in: 24.hours %>
64
+ ~~~
65
+ ~~~html tags
66
+ ```
67
+
49
68
  ## Contributing
50
69
  Contribution directions go here.
51
70
 
@@ -2,7 +2,7 @@
2
2
  class StepLoadController < ApplicationController
3
3
  layout false
4
4
  def partial
5
- @options = ActiveJob::Arguments.deserialize(Marshal.load(cookies.signed[params[:key]]))
5
+ @options = Marshal.load(CGI.unescape(params[:key]))
6
6
  render inline: "<%= render *@options %>"
7
7
  end
8
8
 
@@ -1,3 +1,3 @@
1
1
  module StepRender
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -2,11 +2,9 @@
2
2
  module StepRender
3
3
  module ViewHelper
4
4
  def step_render(*options)
5
- key = "lazy-partial-#{SecureRandom.hex(12)}"
6
- cookies.signed[key] = { value: Marshal.dump(ActiveJob::Arguments.serialize(options)), expires: 2.hour.from_now }
7
- # if use cache store
8
- # Rails.cache.fetch(key, skip_digest: true, expires_in: 10.minute) { ActiveJob::Arguments.serialize(options) }
9
- %(<div class= "related-articles lazyload" data-include="#{step_render_path(key)}">loading</div>).html_safe
5
+ key = CGI.escape(Marshal.dump(options))
6
+ path = step_render_path(key)
7
+ %(<div class= "related-articles lazyload" data-include="#{path}">loading</div>).html_safe
10
8
  end
11
9
 
12
10
  def step_cache(key, **options)
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.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - EastResident
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-06 00:00:00.000000000 Z
11
+ date: 2017-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails