camaleon_lazy_loader 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f426fa9caa76c77ffd1ced9f64be9d9fc3dab772d2051526fd712ea0ed1ed747
|
4
|
+
data.tar.gz: eff7d6be109a7dc8b5f9e4f7c272c9c0702b6b625723bd190a49aff68775a65f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ece0294e728f5e36d6bd6b0daa38b641b81860457b985940a9b4a4ec5fb0f8cfb00bb3f7ff2f0a59983f8c9b0a2b98cb4edb06ef3308969c6b48b5debe00466
|
7
|
+
data.tar.gz: 4804db6afd5de13430a0d16cc415485cf424ecf706d8bf9f8efc49ff861da6b48a84ab5a9307cae1ad112344246b734df08d00e482a1d22773b97fb5ecda2e23
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
![](https://img.shields.io/badge/ruby-2.5%2B-red.svg)
|
2
|
-
![Gem Version](https://img.shields.io/gem/v/
|
2
|
+
![Gem Version](https://img.shields.io/gem/v/camaleon_lazy_loader.svg?colorB=blue)
|
3
3
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
4
4
|
[![Build Status](https://travis-ci.com/brian-kephart/camaleon_lazy_loader.svg?branch=master)](https://travis-ci.org/brian-kephart/camaleon_lazy_loader)
|
5
5
|
|
@@ -9,7 +9,7 @@ This plugin adds a `loading="lazy"` attribute to `<img>` and `<iframe>` tags ren
|
|
9
9
|
- Existing loading attributes will not be overwritten, so you can still set individual tags to `loading="eager"` or `loading="auto"`
|
10
10
|
|
11
11
|
## How it works
|
12
|
-
This plugin updates the body of the http response using the `front_after_load` hook provided by Camaleon, unless the page is cached with the Front Cache plugin.
|
12
|
+
This plugin updates the body of the http response using the `front_after_load` hook provided by Camaleon, unless the page is cached with the Front Cache plugin. Nokogiri is used to add the `loading` attribute.
|
13
13
|
|
14
14
|
### If the Front Cache plugin is active
|
15
15
|
- For pages that are not cached, this plugin works as described above.
|
@@ -33,9 +33,14 @@ And then execute:
|
|
33
33
|
$ bundle
|
34
34
|
```
|
35
35
|
|
36
|
+
## Limitations
|
37
|
+
This gem uses Nokogiri, which in turn wraps underlying parsers. Some characters can be altered by these parsers when used in element attributes. Known cases include:
|
38
|
+
- The AMP lightning bolt ⚡
|
39
|
+
- Characters that are escaped in HTML, such as endash or ampersand
|
40
|
+
|
36
41
|
## Contributing
|
37
42
|
- Fork the repo.
|
38
|
-
- Make your changes and add tests as necessary.
|
43
|
+
- Make your changes and add tests as necessary. (Run tests with `rails test`)
|
39
44
|
- Run `standardrb` to lint your code.
|
40
45
|
- Submit a pull request.
|
41
46
|
|
@@ -14,7 +14,7 @@ module Plugins::CamaleonLazyLoader::MainHelper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def camaleon_lazy_loader_front_after_load
|
17
|
-
return if @
|
17
|
+
return if @skip_lazy_loader || @_plugin_do_cache
|
18
18
|
response.body = apply_lazy_loading response.body
|
19
19
|
end
|
20
20
|
|
@@ -22,4 +22,8 @@ module Plugins::CamaleonLazyLoader::MainHelper
|
|
22
22
|
args[:data] = apply_lazy_loading args[:data] # Save processed HTML to cache.
|
23
23
|
response.body = apply_lazy_loading response.body
|
24
24
|
end
|
25
|
+
|
26
|
+
def camaleon_lazy_loader_skip_lazy_loader(_args)
|
27
|
+
@skip_lazy_loader = true
|
28
|
+
end
|
25
29
|
end
|
data/config/camaleon_plugin.json
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
"on_active": ["clear_front_cache"],
|
10
10
|
"on_inactive": ["clear_front_cache"],
|
11
11
|
"front_cache_writing_cache": ["camaleon_lazy_loader_front_cache_writing_cache"],
|
12
|
-
"front_after_load": ["camaleon_lazy_loader_front_after_load"]
|
12
|
+
"front_after_load": ["camaleon_lazy_loader_front_after_load"],
|
13
|
+
"on_render_sitemap": ["camaleon_lazy_loader_skip_lazy_loader"],
|
14
|
+
"on_render_robots": ["camaleon_lazy_loader_skip_lazy_loader"],
|
15
|
+
"on_render_rss": ["camaleon_lazy_loader_skip_lazy_loader"]
|
13
16
|
}
|
14
17
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camaleon_lazy_loader
|
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
|
- Brian Kephart
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: camaleon_cms
|
@@ -87,7 +87,7 @@ homepage: https://github.com/brian-kephart/camaleon_lazy_loader
|
|
87
87
|
licenses:
|
88
88
|
- MIT
|
89
89
|
metadata: {}
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubygems_version: 3.1.4
|
106
|
-
signing_key:
|
106
|
+
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Adds browser-native loading="lazy" attribute to images and iframes rendered
|
109
109
|
by Camaleon CMS.
|