jekyll-zopfli 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/jekyll/zopfli/compressor.rb +43 -3
- data/lib/jekyll/zopfli/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598d8766f62cc79eef124048f583dd598d191c57fc3cb37a789a80a3befc082d
|
4
|
+
data.tar.gz: 17fcb3e576cfc2293c3061866b5e0f967b9f0b7bd13fdfa6ce6d1ea0bd29791a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1141cadc3376282a85943ec57ac5b881e8fb46cd7f9728e77db5aa904ff6d83cd463f151bf457562f3e0acbf12671ed51873f25bf801b5ab006f3cf8e28edb8
|
7
|
+
data.tar.gz: 51656771722d6a3fc4b6dc582324a4b9dbbe2fe69eceaf017f9dad7a68f750f34f8e82c2121049cf9057998e2ba73fe7d8228e3a547e904a21cea22bef15b8b1
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.
|
3
|
+
## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...master)
|
4
4
|
|
5
5
|
...
|
6
6
|
|
7
|
+
## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.3.0...v2.4.0)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Doesn't regenerate files that haven't changed in incremental builds.
|
12
|
+
|
7
13
|
## 2.3.0 (2019-10-23) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.2.0...v2.3.0)
|
8
14
|
|
9
15
|
### Changed
|
@@ -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
|
|
@@ -45,7 +51,15 @@ module Jekyll
|
|
45
51
|
def self.compress_directory(dir, site)
|
46
52
|
extensions = zippable_extensions(site).join(',')
|
47
53
|
files = Dir.glob(dir + "/**/*{#{extensions}}")
|
48
|
-
files.each
|
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
|
##
|
@@ -67,7 +81,7 @@ module Jekyll
|
|
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
|
@@ -84,6 +98,32 @@ module Jekyll
|
|
84
98
|
replace_files = site.config.dig('zopfli', 'replace_files')
|
85
99
|
replace_files.nil? ? Jekyll::Zopfli::DEFAULT_CONFIG['replace_files'] : replace_files
|
86
100
|
end
|
101
|
+
|
102
|
+
def self.zipped(file_name, replace_file)
|
103
|
+
replace_file ? file_name : "#{file_name}.gz"
|
104
|
+
end
|
105
|
+
|
106
|
+
# Compresses the file if the site is built incrementally and the
|
107
|
+
# source was modified or the compressed file doesn't exist
|
108
|
+
def self.regenerate?(file, site)
|
109
|
+
zipped = zipped(file, replace_files(site))
|
110
|
+
|
111
|
+
# Definitely generate the file if it doesn't exist yet.
|
112
|
+
return true unless File.exist? zipped
|
113
|
+
# If we are replacing files and this file is not a gzip file, then it
|
114
|
+
# has been edited so we need to re-gzip it in place.
|
115
|
+
return !is_already_gzipped?(file) if replace_files(site)
|
116
|
+
|
117
|
+
# If the modified time of the new file is greater than the modified time
|
118
|
+
# of the old file, then we need to regenerate.
|
119
|
+
File.mtime(file) > File.mtime(zipped)
|
120
|
+
end
|
121
|
+
|
122
|
+
# First two bytes of a gzipped file are 1f and 8b. This tests for those
|
123
|
+
# bytes.
|
124
|
+
def self.is_already_gzipped?(file)
|
125
|
+
["1f", "8b"] == File.read(file, 2).unpack("H2H2")
|
126
|
+
end
|
87
127
|
end
|
88
128
|
end
|
89
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-zopfli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.0.
|
153
|
+
rubygems_version: 3.0.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Generate gzipped assets and files for your Jekyll site at build time using
|