jekyll-lazy-load-image 0.2.0 → 0.3.3
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/.github/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +41 -0
- data/.github/workflows/publish.yml +105 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +73 -0
- data/Gemfile +3 -3
- data/README.md +16 -9
- data/Rakefile +14 -0
- data/jekyll-lazy-load-image.gemspec +2 -2
- data/lib/jekyll-lazy-load-image/config.rb +1 -0
- data/lib/jekyll-lazy-load-image/translator.rb +5 -8
- data/lib/jekyll-lazy-load-image/version.rb +1 -1
- metadata +11 -9
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 015f44f3c7da3bcea4c9a3708776f1963c55e8c71cfc935cf5d90d63b599dee1
|
4
|
+
data.tar.gz: 26d1b442cc72a9313442eee304dafde45afe53033e7a7c5ff235dcd87d46c988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8567dfc004fa09a664bb94e4c89610365d0617006b3bdb1b107d0cc08b66d148eb4d0c14766c221affdd0404eace829ca190b6835aa30369309221adb18b2127
|
7
|
+
data.tar.gz: 337768cf0d90471da3ea433a8e76ed182e0a9d918bc5517656edbcd891b1484e3c65d8d9742f640e4b4b559b85d8cfbbd19d3894bc2f1941593db550134e3257
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
schedule:
|
5
|
+
- cron: '0 0 * * *'
|
6
|
+
|
7
|
+
env:
|
8
|
+
BUNDLE_RETRY: 3
|
9
|
+
BUNDLE_PATH: vendor/bundle
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ["2.6", "2.7", "3.0"]
|
16
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: kenchan0130/actions-system-info@v1.0.0
|
21
|
+
id: system-info
|
22
|
+
- name: Cache Ruby dependencies
|
23
|
+
uses: actions/cache@v2.1.4
|
24
|
+
with:
|
25
|
+
path: ${{ env.BUNDLE_PATH }}
|
26
|
+
key: cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.release }}-${{ matrix.ruby }}-${{ github.sha }}
|
27
|
+
restore-keys: |
|
28
|
+
cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.release }}-${{ matrix.ruby }}-
|
29
|
+
- name: Setup Ruby ${{ matrix.ruby-version }}
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
- name: Install ruby gems
|
34
|
+
run: |
|
35
|
+
bundle install --jobs=${{ steps.system-info.outputs.cpu-core }}
|
36
|
+
- name: Run lint
|
37
|
+
run: |
|
38
|
+
bundle exec rubocop
|
39
|
+
- name: Run test
|
40
|
+
run: |
|
41
|
+
bundle exec rake spec
|
@@ -0,0 +1,105 @@
|
|
1
|
+
name: Publish
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
workflow_dispatch:
|
7
|
+
|
8
|
+
env:
|
9
|
+
BUNDLE_RETRY: 3
|
10
|
+
BUNDLE_PATH: vendor/bundle
|
11
|
+
PUBLISH_RUBY_VERSION: "2.6"
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
build:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
outputs:
|
17
|
+
publish: ${{ ! steps.publish.outputs.skip }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: kenchan0130/actions-system-info@v1.0.0
|
21
|
+
id: system-info
|
22
|
+
- name: Cache Ruby dependencies
|
23
|
+
uses: actions/cache@v2.1.4
|
24
|
+
with:
|
25
|
+
path: ${{ env.BUNDLE_PATH }}
|
26
|
+
key: cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ env.PUBLISH_RUBY_VERSION }}-${{ github.sha }}
|
27
|
+
restore-keys: |
|
28
|
+
cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ env.PUBLISH_RUBY_VERSION }}-
|
29
|
+
- name: Setup Ruby ${{ env.PUBLISH_RUBY_VERSION }}
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ env.PUBLISH_RUBY_VERSION }}
|
33
|
+
- name: Install ruby gems
|
34
|
+
run: |
|
35
|
+
bundle install --jobs=${{ steps.system-info.outputs.cpu-core }}
|
36
|
+
- name: Run lint
|
37
|
+
run: |
|
38
|
+
bundle exec rubocop
|
39
|
+
- name: Run test
|
40
|
+
run: |
|
41
|
+
bundle exec rake spec
|
42
|
+
- name: Get latest tag
|
43
|
+
id: latest-tag
|
44
|
+
uses: oprypin/find-latest-tag@v1
|
45
|
+
with:
|
46
|
+
repository: ${{ github.repository }}
|
47
|
+
- name: Check to skip publish
|
48
|
+
id: publish
|
49
|
+
run: |
|
50
|
+
if [[ "${{ steps.latest-tag.outputs.tag }}" = "v$(bundle exec rake version)" ]]; then
|
51
|
+
echo "::set-output name=skip::true"
|
52
|
+
else
|
53
|
+
echo "::set-output name=skip::false"
|
54
|
+
fi
|
55
|
+
|
56
|
+
publish:
|
57
|
+
needs: build
|
58
|
+
if: ${{ needs.build.outputs.publish }}
|
59
|
+
runs-on: ubuntu-latest
|
60
|
+
steps:
|
61
|
+
- uses: actions/checkout@v2
|
62
|
+
- uses: kenchan0130/actions-system-info@v1.0.0
|
63
|
+
id: system-info
|
64
|
+
- name: Cache Ruby dependencies
|
65
|
+
uses: actions/cache@v2.1.4
|
66
|
+
with:
|
67
|
+
path: ${{ env.BUNDLE_PATH }}
|
68
|
+
key: cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ env.PUBLISH_RUBY_VERSION }}-${{ github.sha }}
|
69
|
+
restore-keys: |
|
70
|
+
cache-${{ runner.os }}-${{ steps.system-info.outputs.release }}-${{ env.PUBLISH_RUBY_VERSION }}-
|
71
|
+
- name: Setup Ruby ${{ env.PUBLISH_RUBY_VERSION }}
|
72
|
+
uses: ruby/setup-ruby@v1
|
73
|
+
with:
|
74
|
+
ruby-version: ${{ env.PUBLISH_RUBY_VERSION }}
|
75
|
+
- name: Install ruby gems
|
76
|
+
run: |
|
77
|
+
bundle install --jobs=${{ steps.system-info.outputs.cpu-core }}
|
78
|
+
- name: Set committer identity
|
79
|
+
run: |
|
80
|
+
git config --local user.name "${GITHUB_ACTOR}"
|
81
|
+
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
82
|
+
- name: Create tag
|
83
|
+
run: |
|
84
|
+
bundle exec rake tag
|
85
|
+
- name: Publish to GPR
|
86
|
+
run: |
|
87
|
+
mkdir -p $HOME/.gem
|
88
|
+
touch $HOME/.gem/credentials
|
89
|
+
chmod 0600 $HOME/.gem/credentials
|
90
|
+
printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
91
|
+
gem build *.gemspec
|
92
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
93
|
+
env:
|
94
|
+
GEM_HOST_API_KEY: ${{ secrets.GPR_AUTH_TOKEN }}
|
95
|
+
OWNER: kenchan0130
|
96
|
+
- name: Publish gem to rubygems
|
97
|
+
run: |
|
98
|
+
mkdir -p $HOME/.gem
|
99
|
+
touch $HOME/.gem/credentials
|
100
|
+
chmod 0600 $HOME/.gem/credentials
|
101
|
+
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
|
102
|
+
gem build *.gemspec
|
103
|
+
gem push *.gem
|
104
|
+
env:
|
105
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
### Added
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
### Deprecated
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
### Security
|
19
|
+
|
20
|
+
## [0.3.2] - 2019-12-20
|
21
|
+
### Added
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- FIX jekyll dependences [#15](https://github.com/kenchan0130/jekyll-lazy-load-image/pull/15) from @kenchan0130
|
26
|
+
|
27
|
+
### Deprecated
|
28
|
+
|
29
|
+
### Removed
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
### Security
|
34
|
+
|
35
|
+
## [0.3.1] - 2019-12-20
|
36
|
+
### Added
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- weak jekyll version dependency [#11](https://github.com/kenchan0130/jekyll-lazy-load-image/pull/11) from @j1n6
|
41
|
+
- Apply rubocop [#12](https://github.com/kenchan0130/jekyll-lazy-load-image/pull/12) from @kenchan0130
|
42
|
+
- Support to deploy by CI [#13](https://github.com/kenchan0130/jekyll-lazy-load-image/pull/13) [#14](https://github.com/kenchan0130/jekyll-lazy-load-image/pull/14) from @kenchan0130
|
43
|
+
|
44
|
+
### Deprecated
|
45
|
+
|
46
|
+
### Removed
|
47
|
+
|
48
|
+
### Fixed
|
49
|
+
|
50
|
+
### Security
|
51
|
+
|
52
|
+
## [0.3.0] - 2018-07-29
|
53
|
+
### Added
|
54
|
+
|
55
|
+
- This `CHANGELOG.md` file.
|
56
|
+
|
57
|
+
### Changed
|
58
|
+
|
59
|
+
- `JekyllLazyLoadImage::Translator#translate` returns html which is non removed new line.
|
60
|
+
|
61
|
+
### Deprecated
|
62
|
+
|
63
|
+
### Removed
|
64
|
+
|
65
|
+
### Fixed
|
66
|
+
|
67
|
+
### Security
|
68
|
+
|
69
|
+
|
70
|
+
[unreleased]: https://github.com/kenchan0130/jekyll-lazy-load-image/compare/v0.3.2...HEAD
|
71
|
+
[0.3.2]: https://github.com/kenchan0130/jekyll-lazy-load-image/compare/v0.3.1...v0.3.2
|
72
|
+
[0.3.1]: https://github.com/kenchan0130/jekyll-lazy-load-image/compare/v0.3.0...v0.3.1
|
73
|
+
[0.3.0]: https://github.com/kenchan0130/jekyll-lazy-load-image/compare/v0.2.1...v0.3.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
# Jekyll
|
1
|
+
# Jekyll Lazy Load Image
|
2
2
|
|
3
|
-
|
3
|
+
[](https://github.com/kenchan0130/jekyll-lazy-load-image/actions/workflows/ci.yml)
|
4
|
+
|
5
|
+
Edit img tag optimized lazy load images for your Jekyll site
|
4
6
|
|
5
7
|
## Usage
|
8
|
+
|
6
9
|
### `Gemfile`
|
7
10
|
|
8
11
|
Add the following to your site's `Gemfile`:
|
9
12
|
|
10
13
|
```ruby
|
11
|
-
|
14
|
+
group :jekyll_plugins do
|
15
|
+
gem 'jekyll-lazy-load-image', require: 'jekyll-lazy-load-image/auto-execution'
|
16
|
+
end
|
12
17
|
```
|
13
18
|
|
14
19
|
and run bundle.
|
@@ -27,23 +32,25 @@ lazy_load_image:
|
|
27
32
|
- ".ignore-lazy-image-load"
|
28
33
|
- "/*[@class='ignore-lazy-image-load']"
|
29
34
|
additional_attrs: # [optional] if you want to add attributes, please add key value
|
30
|
-
"data-size": auto
|
35
|
+
"data-size": auto
|
31
36
|
```
|
32
37
|
|
33
38
|
### Select lazy load library
|
34
39
|
|
35
40
|
Select your favorite library and add your site. For example:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
|
42
|
+
* [lazysizes](https://github.com/aFarkas/lazysizes) [Recommend]
|
43
|
+
* [Echo.js](https://github.com/toddmotto/echo)
|
44
|
+
* [TADA](https://github.com/fallroot/tada)
|
45
|
+
|
40
46
|
## Custom
|
47
|
+
|
41
48
|
### Customize container
|
42
49
|
|
43
50
|
You can change applying jekyll hook container.
|
44
51
|
This library is `:posts` by default.
|
45
52
|
|
46
|
-
See also: https://jekyllrb.com/docs/plugins/#hooks
|
53
|
+
See also: [https://jekyllrb.com/docs/plugins/#hooks](https://jekyllrb.com/docs/plugins/#hooks)
|
47
54
|
|
48
55
|
#### `Gemfile`
|
49
56
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
+
require "bundler/gem_helper"
|
4
5
|
require "rspec/core/rake_task"
|
6
|
+
require "jekyll-lazy-load-image/version"
|
5
7
|
|
6
8
|
RSpec::Core::RakeTask.new(:spec)
|
7
9
|
|
10
|
+
t = Bundler::GemHelper.new
|
11
|
+
|
12
|
+
desc "Display this gemspec version"
|
13
|
+
task :version do
|
14
|
+
puts JekyllLazyLoadImage::VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Create tag #{t.send(:version_tag)}"
|
18
|
+
task :tag do
|
19
|
+
t.send(:tag_version) { t.send(:git_push) } unless t.send(:already_tagged?)
|
20
|
+
end
|
21
|
+
|
8
22
|
task default: :spec
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.required_ruby_version = ">= 2.4.0"
|
24
24
|
|
25
|
-
spec.add_dependency "jekyll", "
|
25
|
+
spec.add_dependency "jekyll", ">= 3.8"
|
26
26
|
spec.add_dependency "nokogiri", "~> 1.8"
|
27
27
|
|
28
|
-
spec.add_development_dependency "bundler", "~>
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
29
29
|
end
|
@@ -11,6 +11,7 @@ module JekyllLazyLoadImage
|
|
11
11
|
|
12
12
|
def owners=(value)
|
13
13
|
return if value.nil? || value.empty?
|
14
|
+
|
14
15
|
@owners = Array(value).map(&:to_sym).tap do |owners_prospective|
|
15
16
|
not_allowed_hooks = ALLOWED_JEKYLL_HOOK_CONTAINERS & owners_prospective
|
16
17
|
raise ArgumentError, "The owners option must be #{ALLOWED_JEKYLL_HOOK_CONTAINERS.join(" or ")}." if not_allowed_hooks.size.zero?
|
@@ -12,11 +12,12 @@ module JekyllLazyLoadImage
|
|
12
12
|
def translate
|
13
13
|
nokogiri_doc.xpath("//img").each do |node|
|
14
14
|
next if ignore_node?(node)
|
15
|
+
|
15
16
|
apply_lazy_image_setting(node)
|
16
17
|
inject_class_attr(node)
|
17
18
|
inject_additional_attrs(node)
|
18
19
|
end
|
19
|
-
nokogiri_doc.to_html
|
20
|
+
nokogiri_doc.to_html
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -45,12 +46,8 @@ module JekyllLazyLoadImage
|
|
45
46
|
|
46
47
|
node.set_attribute("class", "") if class_value.nil?
|
47
48
|
node_class_attr = node.attributes["class"]
|
48
|
-
|
49
|
-
|
50
|
-
class_name.nil? || class_name.empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
node_class_attr.value = normalize_class_array(class_array)
|
49
|
+
class_array = [node_class_attr.value, @site_config.class_attr_values].flatten
|
50
|
+
node_class_attr.value = normalize_class_array(class_array).join(" ")
|
54
51
|
end
|
55
52
|
|
56
53
|
def inject_additional_attrs(node)
|
@@ -64,7 +61,7 @@ module JekyllLazyLoadImage
|
|
64
61
|
end
|
65
62
|
|
66
63
|
def normalize_class_array(array)
|
67
|
-
array.map(&:strip).
|
64
|
+
array.compact.uniq.map(&:strip).reject(&:empty?)
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-lazy-load-image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadayuki Onishi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- tt.tanishi100@gmail.com
|
@@ -59,10 +59,13 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/dependabot.yml"
|
63
|
+
- ".github/workflows/ci.yml"
|
64
|
+
- ".github/workflows/publish.yml"
|
62
65
|
- ".gitignore"
|
63
66
|
- ".rspec"
|
64
67
|
- ".rubocop.yml"
|
65
|
-
-
|
68
|
+
- CHANGELOG.md
|
66
69
|
- Gemfile
|
67
70
|
- LICENSE.txt
|
68
71
|
- README.md
|
@@ -95,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '0'
|
97
100
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.7.7
|
101
|
+
rubygems_version: 3.0.3
|
100
102
|
signing_key:
|
101
103
|
specification_version: 4
|
102
104
|
summary: Edit img tag optimized lazy load images for your Jekyll site
|
data/.travis.yml
DELETED