jekyll-brotli 2.2.1 → 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: 73109bbbd64c95c1e4faf0942548d26408cf49eae0daf2208889bc347bd09875
4
- data.tar.gz: db719fab85a82b51265f2184f5698265b041e321783148446c86109fe8e287a9
3
+ metadata.gz: 3c64a996a9fe2af91db335a3a66c6d5aeef748c0c58b0f5c9a5b2f995b28ab00
4
+ data.tar.gz: 69564e1e0da087c05028b8f3668718ccd102e7da04e692f7d8a9b13f46cfb78b
5
5
  SHA512:
6
- metadata.gz: b5ad5ec86cd1b3fae3611f932ca3c66a536d54c061e231a12b4ad72b14b5a6b7db1b307307590f99da07ebffe90f7df797be0daa79ac9467588681d94490c51b
7
- data.tar.gz: 5b768f537e61b0e8729e8fe801f55e3ca1d0106a159add09cac7495c19d1e0c3f7eaed99b1b7a6d9578cceb41aed68e55e5bb878e46c187781515771eb69e95a
6
+ metadata.gz: 3c7f4f353f34de9557b80780acfcfb8230a0ea45568cc5e7b06bff14b8049d77eede4da9e814d9ae749224134eac3ef8c61bb709db7a559ef6a53667199edcf1
7
+ data.tar.gz: 10fac03e16ae9e6db997cb231fe2ce8f3bc1a01eaa03e542d8ce655c6fbcbc376098f3e5057e9f54e36f8288a4256a143864b71e57b0c302bd5eb3b3e597b5d2
@@ -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", 3.1, 3.2, 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/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Changelog
2
2
 
3
- ## Ongoing [☰](https://github.com/philnash/jekyll-brotli/compare/v2.2.1...master)
3
+ ## Ongoing [☰](https://github.com/philnash/jekyll-brotli/compare/v2.3.0...main)
4
+
5
+ ...
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
+
13
+ ## 2.3.0 (2021-02-13) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.2.1...v2.3.0)
14
+
15
+ ### Fixed
16
+
17
+ - Stop overwriting Jekyll config, which invalidates the Jekyll cache (see https://github.com/jekyll/jekyll/issues/8551)
18
+
19
+ ### Changed
20
+
21
+ - Added JSON files to compressable extensions
22
+ - Moved from Travis CI to GitHub Actions
4
23
 
5
24
  ## 2.2.1 (2020-01-30) [☰](https://github.com/philnash/jekyll-brotli/compare/v2.2.0...v2.2.1)
6
25
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generate compressed assets and files for your Jekyll site at build time using [Brotli](https://github.com/google/brotli) compression.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/jekyll-brotli.svg)](https://rubygems.org/gems/jekyll-brotli) [![Build Status](https://travis-ci.org/philnash/jekyll-brotli.svg?branch=master)](https://travis-ci.org/philnash/jekyll-brotli) [![Maintainability](https://api.codeclimate.com/v1/badges/9deb43d992a0c47a55e4/maintainability)](https://codeclimate.com/github/philnash/jekyll-brotli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-brotli.svg?branch=master)](https://inch-ci.org/github/philnash/jekyll-brotli)
5
+ [![Gem Version](https://badge.fury.io/rb/jekyll-brotli.svg)](https://rubygems.org/gems/jekyll-brotli) [![Build status](https://github.com/philnash/jekyll-brotli/workflows/tests/badge.svg)](https://github.com/philnash/jekyll-brotli/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/9deb43d992a0c47a55e4/maintainability)](https://codeclimate.com/github/philnash/jekyll-brotli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-brotli.svg?branch=main)](https://inch-ci.org/github/philnash/jekyll-brotli)
6
6
 
7
7
  [API docs](http://www.rubydoc.info/gems/jekyll-brotli/) | [GitHub repo](https://github.com/philnash/jekyll-brotli)
8
8
 
@@ -38,6 +38,45 @@ Once you have the gem installed, run `JEKYLL_ENV=production bundle exec jekyll b
38
38
 
39
39
  Jekyll::Brotli only runs when the environment variable `JEKYLL_ENV` is set to `production` as dealing with compressing files is unnecessary in development mode and just slows down the site build.
40
40
 
41
+ ### Configuration
42
+
43
+ #### Extensions
44
+
45
+ By default, `Jekyll::Brotli` will compress all files with the following extensions:
46
+
47
+ - '.html'
48
+ - '.css'
49
+ - '.js'
50
+ - '.json'
51
+ - '.txt'
52
+ - '.ttf'
53
+ - '.atom'
54
+ - '.stl'
55
+ - '.xml'
56
+ - '.svg'
57
+ - '.eot'
58
+
59
+ You can supply your own extensions by adding a `brotli` key to your site's `_config.yml` listing the extensions that you want to compress. For example to only compress HTML, CSS and JavaScript files, add the following to `_config.yml`:
60
+
61
+ ```yml
62
+ brotli:
63
+ extensions:
64
+ - '.html'
65
+ - '.css'
66
+ - '.js
67
+ ```
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
+
41
80
  ### Serving pre-compiled gzip files
42
81
 
43
82
  You will likely need to adjust your web server config to serve these precomputed gzip files. See below for common server configurations:
@@ -68,4 +107,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
68
107
 
69
108
  ## Code of Conduct
70
109
 
71
- Everyone interacting in the Jekyll::Brotli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-gzip/blob/master/CODE_OF_CONDUCT.md).
110
+ Everyone interacting in the Jekyll::Brotli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-gzip/blob/main/CODE_OF_CONDUCT.md).
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "brotli", "~> 0.2.0"
26
26
 
27
27
  spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
28
- spec.add_development_dependency "rake", "~> 10.0"
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
@@ -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
 
@@ -91,7 +95,11 @@ module Jekyll
91
95
  end
92
96
 
93
97
  def self.compressable_extensions(site)
94
- site.config['brotli'] && site.config['brotli']['extensions'] || Jekyll::Brotli::DEFAULT_CONFIG['extensions']
98
+ site.config.dig("brotli", "extensions") || Jekyll::Brotli::DEFAULT_CONFIG.fetch("extensions")
99
+ end
100
+
101
+ def self.compression_quality(site)
102
+ site.config.dig("brotli", "quality") || Jekyll::Brotli::DEFAULT_CONFIG.fetch("quality")
95
103
  end
96
104
 
97
105
  # Compresses the file if the site is built incrementally and the
@@ -3,10 +3,12 @@
3
3
  module Jekyll
4
4
  module Brotli
5
5
  DEFAULT_CONFIG = {
6
+ 'quality' => 11,
6
7
  'extensions' => [
7
8
  '.html',
8
9
  '.css',
9
10
  '.js',
11
+ '.json',
10
12
  '.txt',
11
13
  '.ttf',
12
14
  '.atom',
@@ -17,4 +19,4 @@ module Jekyll
17
19
  ].freeze
18
20
  }.freeze
19
21
  end
20
- end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Brotli
5
- VERSION = "2.2.1"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  end
data/lib/jekyll/brotli.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['brotli'] || {}
15
- site.config['brotli'] = Jekyll::Brotli::DEFAULT_CONFIG.merge(config) || {}
16
- end
17
-
18
13
  Jekyll::Hooks.register :site, :post_write do |site|
19
14
  Jekyll::Brotli::Compressor.compress_site(site) if Jekyll.env == 'production'
20
15
  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.2.1
4
+ version: 2.4.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: 2020-01-30 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
@@ -70,14 +70,14 @@ dependencies:
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '10.0'
73
+ version: '13.0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '10.0'
80
+ version: '13.0'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +114,10 @@ executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
+ - ".github/FUNDING.yml"
118
+ - ".github/workflows/tests.yml"
117
119
  - ".gitignore"
118
120
  - ".rspec"
119
- - ".travis.yml"
120
121
  - CHANGELOG.md
121
122
  - CODE_OF_CONDUCT.md
122
123
  - Gemfile
@@ -135,7 +136,7 @@ homepage: https://github.com/philnash/jekyll-brotli
135
136
  licenses:
136
137
  - MIT
137
138
  metadata: {}
138
- post_install_message:
139
+ post_install_message:
139
140
  rdoc_options: []
140
141
  require_paths:
141
142
  - lib
@@ -150,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  - !ruby/object:Gem::Version
151
152
  version: '0'
152
153
  requirements: []
153
- rubygems_version: 3.0.3
154
- signing_key:
154
+ rubygems_version: 3.3.3
155
+ signing_key:
155
156
  specification_version: 4
156
157
  summary: Generate brotli compressed assets and files for your Jekyll site at build
157
158
  time.
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.7
5
- - 2.6
6
- - 2.5
7
- - 2.4
8
- - ruby-head
9
- env:
10
- - 'JEKYLL_VERSION="~> 3.0"'
11
- - 'JEKYLL_VERSION="~> 4.0"'
12
- matrix:
13
- allow_failures:
14
- - rvm: ruby-head
15
- script: bundle exec rspec