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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba6f547ad110f7ade5623bf045adb5ae2aab594
4
- data.tar.gz: 6af12bfab5fa1c24dda036dbac35056feb9a0efe
3
+ metadata.gz: 7b7796af471880e0e3213065c60c05fc56ca3a1e
4
+ data.tar.gz: 2ec679a13154dc67b7bc5cc08fc0ff03330e5f0d
5
5
  SHA512:
6
- metadata.gz: d558f6d89e80bb8e6e5ac831cb462a294dd48a428619f0cecb7dadd7be90d32ddbe95d68caeffee24b898b230f2f8926967e239489bc7308a03cd697dc7684f8
7
- data.tar.gz: eb38b11ae4f5b4b391274b8638c614e7125e95fff1b788c1ed31e790d332fa19673c58c1c1eb6c165098d437d37ed88bae385c2320724836c6c3709add6f4eee
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. Use `step_render` method instead of `render` method
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. Use `step_cache` method instead of `cache` method
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
@@ -1,4 +1,2 @@
1
1
  Rails.application.routes.draw do
2
- get 'step_render/:key', to: 'step_load#partial', as: 'step_render'
3
- get 'step_cache/:key', to: 'step_load#fetch', as: 'step_cache'
4
2
  end
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
@@ -1,3 +1,3 @@
1
1
  module StepRender
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -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.0
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-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails