jekyll-zopfli 2.1.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/tests.yml +25 -0
- data/.gitignore +2 -1
- data/CHANGELOG.md +45 -10
- data/Gemfile +4 -0
- data/README.md +3 -2
- data/jekyll-zopfli.gemspec +2 -2
- data/lib/jekyll/zopfli.rb +0 -5
- data/lib/jekyll/zopfli/compressor.rb +51 -7
- data/lib/jekyll/zopfli/config.rb +2 -1
- data/lib/jekyll/zopfli/version.rb +1 -1
- metadata +18 -11
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69d64e88350322aa287a04de9c9dba6d60b1588f21973a3a1f5e40b37fd6265c
|
4
|
+
data.tar.gz: cfb0d765560b20803e39f42f8e194d3f7a5e0f68fc0290b3357947c284cb3488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5cbdf255e010eaacecf8b3795ab98c1ce2cac6cb8ef603b452632823f0988498acfd036298a876fdf5fd4b3da127153d8d581e2e2e35fe062f5523f61af1b7
|
7
|
+
data.tar.gz: 908118206b320010b26e51d399dd62eab09b571c6d97347f5417641872723b0f2766e3209a1656b72f3c4b41135691634ff5fc3b294956fc58c57d51d3eec8e5
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: philnash
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.5, 2.6, 2.7, 3.0, head]
|
12
|
+
jekyll: ["3.0", "4.0"]
|
13
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
14
|
+
env:
|
15
|
+
JEKYLL_VERSION: ~> ${{ matrix.jekyll }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
- name: "Install dependencies"
|
23
|
+
run: bundle install
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,37 +1,72 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/jekyll-
|
3
|
+
## Ongoing [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.1...main)
|
4
4
|
|
5
5
|
...
|
6
6
|
|
7
|
+
## 2.5.0 (2021-02-13) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.1...v2.5.0)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Added JSON files to compressable extensions
|
12
|
+
- Moved from Travis CI to GitHub Actions
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Stop overwriting Jekyll config, which invalidates the Jekyll cache (see https://github.com/jekyll/jekyll/issues/8551)
|
17
|
+
|
18
|
+
## 2.4.1 (2020-01-30) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.0...v2.4.1)
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
- Fixes the path handed to `Dir.glob` by using `File.join` instead of string concatenation
|
23
|
+
|
24
|
+
## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.3.0...v2.4.0)
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
|
28
|
+
- Doesn't regenerate files that haven't changed in incremental builds.
|
29
|
+
|
30
|
+
## 2.3.0 (2019-10-23) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.2.0...v2.3.0)
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
|
34
|
+
- Fixed tests and actually replaces files when it is supposed to. Thanks @pat!
|
35
|
+
|
36
|
+
## 2.2.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.1.0...v2.2.0)
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- Opens up version support for Jekyll 4 (thanks [@thedanbob](https://github.com/thedanbob))
|
41
|
+
|
7
42
|
## 2.1.0 (2019-03-30) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.0.0...v2.1.0)
|
8
43
|
|
9
44
|
### Added
|
10
45
|
|
11
|
-
|
46
|
+
- Adds setting to replace original files with gzipped for serving from AWS S3
|
12
47
|
|
13
48
|
## 2.0.0 (2018-11-24) [☰](https://github.com/philnash/jekyll-zopfli/compare/v1.1.0...v2.0.0)
|
14
49
|
|
15
50
|
### Added
|
16
51
|
|
17
|
-
|
18
|
-
|
52
|
+
- Hooks into Jekyll::Assets if available
|
53
|
+
- Adds frozen string literal comment
|
19
54
|
|
20
55
|
### Changed
|
21
56
|
|
22
|
-
|
23
|
-
|
24
|
-
|
57
|
+
- Uses built in `Jekyll.env` instead of `ENV["JEKYLL_ENV"]`
|
58
|
+
- Changes `Jekyll::Zopfli::Compressor` to a module and implements a `compress_directory` method
|
59
|
+
- Moves Jekyll::Zopfli::ZIPPABLE_EXTENSIONS into plugin config that can overwritten in the site config
|
25
60
|
|
26
61
|
## 1.1.0 (2018-01-03) [☰](https://github.com/philnash/jekyll-zopfli/compare/v1.0.0...v1.1.0)
|
27
62
|
|
28
63
|
### Changed
|
29
64
|
|
30
|
-
|
65
|
+
- Only run the post write hook when the environment variable `JEKYLL_ENV` is `production`
|
31
66
|
|
32
67
|
## 1.0.0 (2018-01-02) [☰](https://github.com/philnash/jekyll-zopfli/commits/v1.0.0)
|
33
68
|
|
34
69
|
### Added
|
35
70
|
|
36
|
-
|
37
|
-
|
71
|
+
- Methods to Gzip compress text files throughout a Jekyll site using Zopfli
|
72
|
+
- Site post write hook to trigger compression
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Generate gzipped assets and files for your Jekyll site at build time using [Zopfli](https://github.com/google/zopfli) compression.
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/jekyll-zopfli.svg)](https://rubygems.org/gems/jekyll-zopfli) [![Build
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-zopfli.svg)](https://rubygems.org/gems/jekyll-zopfli) [![Build status](https://github.com/philnash/jekyll-zopfli/workflows/tests/badge.svg)](https://github.com/philnash/jekyll-zopfli/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/177f76759bc3b996e9e2/maintainability)](https://codeclimate.com/github/philnash/jekyll-zopfli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-zopfli.svg?branch=main)](https://inch-ci.org/github/philnash/jekyll-zopfli)
|
6
6
|
|
7
7
|
[API docs](http://www.rubydoc.info/gems/jekyll-zopfli/) | [GitHub repo](https://github.com/philnash/jekyll-zopfli)
|
8
8
|
|
@@ -72,6 +72,7 @@ By default, `Jekyll::Zopfli` will compress all files with the following extensio
|
|
72
72
|
- '.html'
|
73
73
|
- '.css'
|
74
74
|
- '.js'
|
75
|
+
- '.json'
|
75
76
|
- '.txt'
|
76
77
|
- '.ttf'
|
77
78
|
- '.atom'
|
@@ -146,4 +147,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
146
147
|
|
147
148
|
## Code of Conduct
|
148
149
|
|
149
|
-
Everyone interacting in the Jekyll::Zopfli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-
|
150
|
+
Everyone interacting in the Jekyll::Zopfli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-zopfli/blob/main/CODE_OF_CONDUCT.md).
|
data/jekyll-zopfli.gemspec
CHANGED
@@ -21,11 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "jekyll", "
|
24
|
+
spec.add_dependency "jekyll", ">= 3.0", "< 5.0"
|
25
25
|
spec.add_dependency "zopfli", "~> 0.0.7"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "simplecov", "~> 0.15.1"
|
31
31
|
end
|
data/lib/jekyll/zopfli.rb
CHANGED
@@ -10,11 +10,6 @@ module Jekyll
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
Jekyll::Hooks.register :site, :after_init do |site|
|
14
|
-
config = site.config['zopfli'] || {}
|
15
|
-
site.config['zopfli'] = Jekyll::Zopfli::DEFAULT_CONFIG.merge(config) || {}
|
16
|
-
end
|
17
|
-
|
18
13
|
Jekyll::Hooks.register :site, :post_write do |site|
|
19
14
|
Jekyll::Zopfli::Compressor.compress_site(site) if Jekyll.env == 'production'
|
20
15
|
end
|
@@ -25,7 +25,13 @@ module Jekyll
|
|
25
25
|
# @return void
|
26
26
|
def self.compress_site(site)
|
27
27
|
site.each_site_file do |file|
|
28
|
-
|
28
|
+
next unless regenerate? file.destination(site.dest), site
|
29
|
+
|
30
|
+
compress_file(
|
31
|
+
file.destination(site.dest),
|
32
|
+
extensions: zippable_extensions(site),
|
33
|
+
replace_file: replace_files(site)
|
34
|
+
)
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
@@ -44,8 +50,16 @@ module Jekyll
|
|
44
50
|
# @return void
|
45
51
|
def self.compress_directory(dir, site)
|
46
52
|
extensions = zippable_extensions(site).join(',')
|
47
|
-
files = Dir.glob(dir
|
48
|
-
files.each
|
53
|
+
files = Dir.glob(File.join(dir, "**", "*{#{extensions}}"))
|
54
|
+
files.each do |file|
|
55
|
+
next unless regenerate? file, site
|
56
|
+
|
57
|
+
compress_file(
|
58
|
+
file,
|
59
|
+
extensions: zippable_extensions(site),
|
60
|
+
replace_file: replace_files(site)
|
61
|
+
)
|
62
|
+
end
|
49
63
|
end
|
50
64
|
|
51
65
|
##
|
@@ -60,14 +74,14 @@ module Jekyll
|
|
60
74
|
# @param file_name [String] The file name of the file we want to compress
|
61
75
|
# @param extensions [Array<String>] The extensions of files that will be
|
62
76
|
# compressed.
|
63
|
-
# @param replace_file [Boolean] Whether the
|
77
|
+
# @param replace_file [Boolean] Whether the original file should be
|
64
78
|
# replaced or written alongside the original with a `.gz` extension
|
65
79
|
#
|
66
80
|
# @return void
|
67
81
|
def self.compress_file(file_name, extensions: [], replace_file: false)
|
68
82
|
return unless extensions.include?(File.extname(file_name))
|
69
83
|
zipped = replace_file ? file_name : "#{file_name}.gz"
|
70
|
-
contents = ::Zopfli.deflate(File.
|
84
|
+
contents = ::Zopfli.deflate(File.binread(file_name), format: :gzip)
|
71
85
|
File.open(zipped, "w+") do |file|
|
72
86
|
file << contents
|
73
87
|
end
|
@@ -77,8 +91,38 @@ module Jekyll
|
|
77
91
|
private
|
78
92
|
|
79
93
|
def self.zippable_extensions(site)
|
80
|
-
site.config
|
94
|
+
site.config.dig("zopfli", "extensions") || Jekyll::Zopfli::DEFAULT_CONFIG.fetch("extensions")
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.replace_files(site)
|
98
|
+
site.config.dig("zopfli", "replace_files") || Jekyll::Zopfli::DEFAULT_CONFIG.fetch("replace_files")
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.zipped(file_name, replace_file)
|
102
|
+
replace_file ? file_name : "#{file_name}.gz"
|
103
|
+
end
|
104
|
+
|
105
|
+
# Compresses the file if the site is built incrementally and the
|
106
|
+
# source was modified or the compressed file doesn't exist
|
107
|
+
def self.regenerate?(file, site)
|
108
|
+
zipped = zipped(file, replace_files(site))
|
109
|
+
|
110
|
+
# Definitely generate the file if it doesn't exist yet.
|
111
|
+
return true unless File.exist? zipped
|
112
|
+
# If we are replacing files and this file is not a gzip file, then it
|
113
|
+
# has been edited so we need to re-gzip it in place.
|
114
|
+
return !is_already_gzipped?(file) if replace_files(site)
|
115
|
+
|
116
|
+
# If the modified time of the new file is greater than the modified time
|
117
|
+
# of the old file, then we need to regenerate.
|
118
|
+
File.mtime(file) > File.mtime(zipped)
|
119
|
+
end
|
120
|
+
|
121
|
+
# First two bytes of a gzipped file are 1f and 8b. This tests for those
|
122
|
+
# bytes.
|
123
|
+
def self.is_already_gzipped?(file)
|
124
|
+
["1f", "8b"] == File.read(file, 2).unpack("H2H2")
|
81
125
|
end
|
82
126
|
end
|
83
127
|
end
|
84
|
-
end
|
128
|
+
end
|
data/lib/jekyll/zopfli/config.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-zopfli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-13 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.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: zopfli
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,14 +70,14 @@ dependencies:
|
|
64
70
|
requirements:
|
65
71
|
- - "~>"
|
66
72
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
73
|
+
version: '13.0'
|
68
74
|
type: :development
|
69
75
|
prerelease: false
|
70
76
|
version_requirements: !ruby/object:Gem::Requirement
|
71
77
|
requirements:
|
72
78
|
- - "~>"
|
73
79
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
80
|
+
version: '13.0'
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: rspec
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,9 +114,10 @@ executables: []
|
|
108
114
|
extensions: []
|
109
115
|
extra_rdoc_files: []
|
110
116
|
files:
|
117
|
+
- ".github/FUNDING.yml"
|
118
|
+
- ".github/workflows/tests.yml"
|
111
119
|
- ".gitignore"
|
112
120
|
- ".rspec"
|
113
|
-
- ".travis.yml"
|
114
121
|
- CHANGELOG.md
|
115
122
|
- CODE_OF_CONDUCT.md
|
116
123
|
- Gemfile
|
@@ -129,7 +136,7 @@ homepage: https://github.com/philnash/jekyll-zopfli
|
|
129
136
|
licenses:
|
130
137
|
- MIT
|
131
138
|
metadata: {}
|
132
|
-
post_install_message:
|
139
|
+
post_install_message:
|
133
140
|
rdoc_options: []
|
134
141
|
require_paths:
|
135
142
|
- lib
|
@@ -144,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
151
|
- !ruby/object:Gem::Version
|
145
152
|
version: '0'
|
146
153
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
154
|
+
rubygems_version: 3.1.4
|
155
|
+
signing_key:
|
149
156
|
specification_version: 4
|
150
157
|
summary: Generate gzipped assets and files for your Jekyll site at build time using
|
151
158
|
Zopfli compression.
|