jekyll-brotli 2.1.0 → 2.2.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 +4 -4
- data/CHANGELOG.md +7 -3
- data/lib/jekyll/brotli.rb +6 -0
- data/lib/jekyll/brotli/compressor.rb +27 -4
- data/lib/jekyll/brotli/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: c01d2370e43402384f97385984ba919730c8b35957ba7eca72d29c3d0806dd1a
|
4
|
+
data.tar.gz: 66cff3b96e22a3bc0b20a60872c6f97d67bd335e0b427352b014bb0f581d5e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1913dccb152cf9e6877fb70107af32bd078c19baf9ef2f947a727c8b2b4215430dd8ad9246baaa8162a35636d06703bc29ccfc182578d12c5eb85585376ae09e
|
7
|
+
data.tar.gz: 63e03d5ee66bfa73444917abafefcb9f3bd01344502b1f5769d5bf65843c8692769eb4b069d05d4cd53452917749ddb0d4d7ff7dd2db652ebbbd4483b89d5804
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/jekyll-brotli/compare/v2.
|
3
|
+
## Ongoing [☰](https://github.com/philnash/jekyll-brotli/compare/v2.2.0...master)
|
4
4
|
|
5
|
-
...
|
5
|
+
## 2.2.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.1.0...v2.2.0)
|
6
6
|
|
7
|
-
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- - Doesn't regenerate files that haven't changed in incremental builds (thanks [@fauno](https://github.com/fauno))
|
10
|
+
|
11
|
+
## 2.1.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.0.0...v2.1.0)
|
8
12
|
|
9
13
|
### Changed
|
10
14
|
|
data/lib/jekyll/brotli.rb
CHANGED
@@ -19,6 +19,12 @@ Jekyll::Hooks.register :site, :post_write do |site|
|
|
19
19
|
Jekyll::Brotli::Compressor.compress_site(site) if Jekyll.env == 'production'
|
20
20
|
end
|
21
21
|
|
22
|
+
Jekyll::Hooks.register :clean, :on_obsolete do |obsolete|
|
23
|
+
obsolete.delete_if do |path|
|
24
|
+
path.end_with? '.br'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
begin
|
23
29
|
require 'jekyll-assets'
|
24
30
|
|
@@ -25,6 +25,8 @@ module Jekyll
|
|
25
25
|
# @return void
|
26
26
|
def self.compress_site(site)
|
27
27
|
site.each_site_file do |file|
|
28
|
+
next unless regenerate? file.destination(site.dest), site
|
29
|
+
|
28
30
|
compress_file(
|
29
31
|
file.destination(site.dest),
|
30
32
|
compressable_extensions(site)
|
@@ -47,8 +49,12 @@ module Jekyll
|
|
47
49
|
# @return void
|
48
50
|
def self.compress_directory(dir, site)
|
49
51
|
extensions = compressable_extensions(site).join(',')
|
50
|
-
files = Dir.glob(dir + "
|
51
|
-
files.each
|
52
|
+
files = Dir.glob(dir + "/**/*{#{extensions}}")
|
53
|
+
files.each do |file|
|
54
|
+
next unless regenerate? file, site
|
55
|
+
|
56
|
+
compress_file(file, compressable_extensions(site))
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
##
|
@@ -67,8 +73,11 @@ module Jekyll
|
|
67
73
|
# @return void
|
68
74
|
def self.compress_file(file_name, extensions)
|
69
75
|
return unless extensions.include?(File.extname(file_name))
|
70
|
-
compressed =
|
76
|
+
compressed = compressed(file_name)
|
71
77
|
contents = ::Brotli.deflate(File.read(file_name), quality: 11)
|
78
|
+
|
79
|
+
Jekyll.logger.debug "Brotli: #{compressed}"
|
80
|
+
|
72
81
|
File.open(compressed, "w+") do |file|
|
73
82
|
file << contents
|
74
83
|
end
|
@@ -77,9 +86,23 @@ module Jekyll
|
|
77
86
|
|
78
87
|
private
|
79
88
|
|
89
|
+
def self.compressed(file_name)
|
90
|
+
"#{file_name}.br"
|
91
|
+
end
|
92
|
+
|
80
93
|
def self.compressable_extensions(site)
|
81
94
|
site.config['brotli'] && site.config['brotli']['extensions'] || Jekyll::Brotli::DEFAULT_CONFIG['extensions']
|
82
95
|
end
|
96
|
+
|
97
|
+
# Compresses the file if the site is built incrementally and the
|
98
|
+
# source was modified or the compressed file doesn't exist
|
99
|
+
def self.regenerate?(file, site)
|
100
|
+
compressed = compressed(file)
|
101
|
+
|
102
|
+
return true unless File.exist? compressed
|
103
|
+
|
104
|
+
File.mtime(file) > File.mtime(compressed)
|
105
|
+
end
|
83
106
|
end
|
84
107
|
end
|
85
|
-
end
|
108
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-brotli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.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-30 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 brotli compressed assets and files for your Jekyll site at build
|