step_render 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +53 -0
- data/Rakefile +36 -0
- data/app/assets/config/step_render_manifest.js +0 -0
- data/app/controllers/step_load_controller.rb +8 -0
- data/config/routes.rb +3 -0
- data/lib/step_render/engine.rb +10 -0
- data/lib/step_render/version.rb +3 -0
- data/lib/step_render/view_helper.rb +19 -0
- data/lib/step_render.rb +8 -0
- data/lib/tasks/step_render_tasks.rake +4 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1dbac8447ea28251a3dfd1c2495681bbb9cc576a
|
4
|
+
data.tar.gz: 14ba0115c59490d1bb9464ef9fa827b5736eb3fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a23a1c1d8d18f9dcff748baaa41b217c181780d874517eb00aadb096992a64b62e5cca13c5614382a6ce1fbc28ced59fef0de0500c9541e3d4b9c325899c229
|
7
|
+
data.tar.gz: 49a2d59fda93f573b882d8ffab21f5e5dfb772e29c0e36c4a212b490f2573c66015cb2d08e51ee68e1045380ad7f5603c4b685bf38bfb84092f31ef0522463c4
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# StepRender
|
2
|
+
It is very easy to enable lazy loading of partial with scroll in views.
|
3
|
+
|
4
|
+
You only use `step_render` method instead of `render` method.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'step_render'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```bash
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### 1. Load javascript library
|
21
|
+
|
22
|
+
This plugin depends on [lazysizes](https://github.com/aFarkas/lazysizes).
|
23
|
+
If you do not import lazysizes to your application, load `import_step_render` method in required view.
|
24
|
+
|
25
|
+
#### Example
|
26
|
+
|
27
|
+
`application.html.erb`
|
28
|
+
```html
|
29
|
+
<head>
|
30
|
+
~~~
|
31
|
+
~~~
|
32
|
+
<%= import_step_render %>
|
33
|
+
~~~
|
34
|
+
</head>
|
35
|
+
```
|
36
|
+
|
37
|
+
### 2. Use `step_render` method instead of `render` method
|
38
|
+
|
39
|
+
Replace `render` helper method used to rendering the partial with `step_render`.
|
40
|
+
Partial must be specified as an absolute path.
|
41
|
+
|
42
|
+
#### Example
|
43
|
+
|
44
|
+
`app/views/top/index.html.erb`
|
45
|
+
```html
|
46
|
+
<%= step_render 'top/partial_name' %>
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
Contribution directions go here.
|
51
|
+
|
52
|
+
## License
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'StepRender'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
File without changes
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'step_render/view_helper'
|
2
|
+
module StepRender
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
initializer 'step_render.action_controller_helpers' do
|
5
|
+
ActiveSupport.on_load :action_controller do
|
6
|
+
ActionView::Base.send :include, StepRender::ViewHelper
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module StepRender
|
3
|
+
module ViewHelper
|
4
|
+
def step_render(*options)
|
5
|
+
if Rails.cache.is_a?(ActiveSupport::Cache::NullStore)
|
6
|
+
render *options
|
7
|
+
else
|
8
|
+
key = "lazy-partial-#{SecureRandom.hex(12)}"
|
9
|
+
cookies.signed[key] = { value: Marshal.dump(ActiveJob::Arguments.serialize(options)), expires: 2.hour.from_now }
|
10
|
+
# if use cache store
|
11
|
+
# Rails.cache.fetch(key, skip_digest: true, expires_in: 10.minute) { ActiveJob::Arguments.serialize(options) }
|
12
|
+
%(<div class= "related-articles lazyload" data-include="#{step_render_path(key)}">loading</div>).html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def import_step_render
|
16
|
+
'<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/3.0.0/lazysizes.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/3.0.0/plugins/include/ls.include.min.js"></script>'.html_safe
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/step_render.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: step_render
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- EastResident
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: It is very easy to enable lazy loading of partial with scroll in views
|
42
|
+
email:
|
43
|
+
- eastresident@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/config/step_render_manifest.js
|
52
|
+
- app/controllers/step_load_controller.rb
|
53
|
+
- config/routes.rb
|
54
|
+
- lib/step_render.rb
|
55
|
+
- lib/step_render/engine.rb
|
56
|
+
- lib/step_render/version.rb
|
57
|
+
- lib/step_render/view_helper.rb
|
58
|
+
- lib/tasks/step_render_tasks.rake
|
59
|
+
homepage: https://github.com/EastResident/step_render
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.5.1
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: It is very easy to enable lazy loading of partial with scroll in views
|
83
|
+
test_files: []
|