jekyll-brotli 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33b59dc1c8f31a07b8775952290fb96e5685595adf2cd66fd49ace40ef8651f6
4
- data.tar.gz: 3de63515bffa570a09dc045c9395309f6b38dab6021694aafbdc007599a883a2
3
+ metadata.gz: 3c64a996a9fe2af91db335a3a66c6d5aeef748c0c58b0f5c9a5b2f995b28ab00
4
+ data.tar.gz: 69564e1e0da087c05028b8f3668718ccd102e7da04e692f7d8a9b13f46cfb78b
5
5
  SHA512:
6
- metadata.gz: 61fcaa61cc32ed1fa008ea36752ddb3a0d86be1353e60c79c4812fad81d06d33bda20f57aa4052d37cfcd901ec866af36367ed38fec1af06a284e6bd1e2a87ea
7
- data.tar.gz: 4c2b873ed1072ab6d2aa693fc1ec7ef77860acc68ca2a985e17407b0e2b72c82b71494b6e0f1702c4d62930b6278e6be29a5196e6522c8c14b8cf3123829b638
6
+ metadata.gz: 3c7f4f353f34de9557b80780acfcfb8230a0ea45568cc5e7b06bff14b8049d77eede4da9e814d9ae749224134eac3ef8c61bb709db7a559ef6a53667199edcf1
7
+ data.tar.gz: 10fac03e16ae9e6db997cb231fe2ce8f3bc1a01eaa03e542d8ce655c6fbcbc376098f3e5057e9f54e36f8288a4256a143864b71e57b0c302bd5eb3b3e597b5d2
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [2.5, 2.6, 2.7, 3.0, head]
11
+ ruby: [2.5, 2.6, 2.7, "3.0", 3.1, 3.2, head]
12
12
  jekyll: ["3.0", "4.0"]
13
13
  continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
14
14
  env:
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ...
6
6
 
7
+ ## 2.4.0 (2023-08-29) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.3.0...v2.4.0)
8
+
9
+ ### Changed
10
+
11
+ - Added config to set the Brotli compression level (thanks [@fauno](https://github.com/fauno))
12
+
7
13
  ## 2.3.0 (2021-02-13) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.2.1...v2.3.0)
8
14
 
9
15
  ### Fixed
data/README.md CHANGED
@@ -66,6 +66,17 @@ brotli:
66
66
  - '.js
67
67
  ```
68
68
 
69
+ #### Compression quality
70
+
71
+ By default, `Jekyll::Brotli` uses the maximum compression quality
72
+ supported by Brotli, which is 11. You can supply your own compression
73
+ quality by setting a number between 0 and 11 on `_config.yml`.
74
+
75
+ ```yml
76
+ brotli:
77
+ quality: 9
78
+ ```
79
+
69
80
  ### Serving pre-compiled gzip files
70
81
 
71
82
  You will likely need to adjust your web server config to serve these precomputed gzip files. See below for common server configurations:
@@ -24,12 +24,15 @@ module Jekyll
24
24
  #
25
25
  # @return void
26
26
  def self.compress_site(site)
27
+ quality = compression_quality(site)
28
+
27
29
  site.each_site_file do |file|
28
30
  next unless regenerate? file.destination(site.dest), site
29
31
 
30
32
  compress_file(
31
33
  file.destination(site.dest),
32
- compressable_extensions(site)
34
+ compressable_extensions(site),
35
+ quality
33
36
  )
34
37
  end
35
38
  end
@@ -50,10 +53,11 @@ module Jekyll
50
53
  def self.compress_directory(dir, site)
51
54
  extensions = compressable_extensions(site).join(',')
52
55
  files = Dir.glob(File.join(dir, "**", "*{#{extensions}}"))
56
+ quality = compression_quality(site)
53
57
  files.each do |file|
54
58
  next unless regenerate? file, site
55
59
 
56
- compress_file(file, compressable_extensions(site))
60
+ compress_file(file, compressable_extensions(site), quality)
57
61
  end
58
62
  end
59
63
 
@@ -71,10 +75,10 @@ module Jekyll
71
75
  # compressed.
72
76
  #
73
77
  # @return void
74
- def self.compress_file(file_name, extensions)
78
+ def self.compress_file(file_name, extensions, quality = 11)
75
79
  return unless extensions.include?(File.extname(file_name))
76
80
  compressed = compressed(file_name)
77
- contents = ::Brotli.deflate(File.read(file_name), quality: 11)
81
+ contents = ::Brotli.deflate(File.read(file_name), quality: quality)
78
82
 
79
83
  Jekyll.logger.debug "Brotli: #{compressed}"
80
84
 
@@ -94,6 +98,10 @@ module Jekyll
94
98
  site.config.dig("brotli", "extensions") || Jekyll::Brotli::DEFAULT_CONFIG.fetch("extensions")
95
99
  end
96
100
 
101
+ def self.compression_quality(site)
102
+ site.config.dig("brotli", "quality") || Jekyll::Brotli::DEFAULT_CONFIG.fetch("quality")
103
+ end
104
+
97
105
  # Compresses the file if the site is built incrementally and the
98
106
  # source was modified or the compressed file doesn't exist
99
107
  def self.regenerate?(file, site)
@@ -3,6 +3,7 @@
3
3
  module Jekyll
4
4
  module Brotli
5
5
  DEFAULT_CONFIG = {
6
+ 'quality' => 11,
6
7
  'extensions' => [
7
8
  '.html',
8
9
  '.css',
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Brotli
5
- VERSION = "2.3.0"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  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.3.0
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: 2021-02-13 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
- rubygems_version: 3.1.4
154
+ rubygems_version: 3.3.3
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Generate brotli compressed assets and files for your Jekyll site at build