bridgetown-minify-html 0.1.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 +7 -0
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +21 -0
- data/.github/workflows/changelog.yml +38 -0
- data/.github/workflows/gempush.yml +29 -0
- data/.github/workflows/rspec.yml +37 -0
- data/.gitignore +38 -0
- data/.rspec +2 -0
- data/.rubocop.yml +22 -0
- data/CHANGELOG.md +13 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +39 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +55 -0
- data/Rakefile +8 -0
- data/bridgetown-minify-html.gemspec +28 -0
- data/docker-compose.yml +24 -0
- data/lib/bridgetown-minify-html.rb +6 -0
- data/lib/bridgetown-minify-html/builder.rb +16 -0
- data/lib/bridgetown-minify-html/minifier.rb +68 -0
- data/lib/bridgetown-minify-html/version.rb +5 -0
- metadata +173 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c6a57d61db7ff8bd32025ce24450ec588b8b7537a85d2c3e9a5b00e549403a79
|
|
4
|
+
data.tar.gz: e1f8a7f2560c5356c440ba1b1569ab2457ee9b7625258536fef24cae671fc7b6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 53b9cd28f9803b548e07cbe99b13dbfd051f75070eeaff8ef77cdc96d7ef26e390abb6f3924820037d27d776f94358db1af23d59f1f1fa6054026f82b99e6855
|
|
7
|
+
data.tar.gz: 862364452a15dda77e8df622818c234c3646a1553bf816779c0dea3d3054652427c766907d9b480e219e6cd7fbfb85cccfbc0fbe21aac7b889167f1bf3d97aac
|
data/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
updates:
|
|
4
|
+
|
|
5
|
+
# Maintain dependencies for GitHub Actions
|
|
6
|
+
- package-ecosystem: "github-actions"
|
|
7
|
+
directory: "/"
|
|
8
|
+
schedule:
|
|
9
|
+
interval: "daily"
|
|
10
|
+
|
|
11
|
+
# Maintain dependencies for Bundler
|
|
12
|
+
- package-ecosystem: "bundler"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "daily"
|
|
16
|
+
|
|
17
|
+
# Maintain dependencies for Docker
|
|
18
|
+
- package-ecosystem: "docker"
|
|
19
|
+
directory: "/"
|
|
20
|
+
schedule:
|
|
21
|
+
interval: "daily"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# From: https://github.com/hopsoft/stimulus_reflex/blob/master/.github/workflows/changelog.yml
|
|
2
|
+
name: Changelog
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- master
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
timeout-minutes: 4
|
|
13
|
+
if: "!contains(github.event.head_commit.message, '[nodoc]')"
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@master
|
|
16
|
+
- name: Set up Ruby 2.7
|
|
17
|
+
uses: ruby/setup-ruby@v1
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: 2.7.1
|
|
20
|
+
- uses: actions/cache@v2
|
|
21
|
+
with:
|
|
22
|
+
path: vendor/bundle
|
|
23
|
+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
|
24
|
+
restore-keys: |
|
|
25
|
+
${{ runner.os }}-gem-
|
|
26
|
+
- name: Create local changes
|
|
27
|
+
run: |
|
|
28
|
+
gem install github_changelog_generator
|
|
29
|
+
github_changelog_generator -u MikeRogers0 -p bridgetown-minify-html --token ${{ secrets.GITHUB_TOKEN }} --exclude-labels duplicate,question,invalid,wontfix,nodoc
|
|
30
|
+
- name: Commit files
|
|
31
|
+
run: |
|
|
32
|
+
git config --local user.email "github-actions@example.com"
|
|
33
|
+
git config --local user.name "GitHub Actions"
|
|
34
|
+
git commit -am "[nodoc] Update Changelog" || echo "No changes to commit"
|
|
35
|
+
- name: Push changes
|
|
36
|
+
uses: ad-m/github-push-action@master
|
|
37
|
+
with:
|
|
38
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Build & Publish Ruby Gem
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Build + Publish
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
- name: Set up Ruby 2.6
|
|
15
|
+
uses: actions/setup-ruby@v1
|
|
16
|
+
with:
|
|
17
|
+
ruby-version: 2.6.x
|
|
18
|
+
|
|
19
|
+
- name: Publish to GPR
|
|
20
|
+
run: |
|
|
21
|
+
mkdir -p $HOME/.gem
|
|
22
|
+
touch $HOME/.gem/credentials
|
|
23
|
+
chmod 0600 $HOME/.gem/credentials
|
|
24
|
+
printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
25
|
+
gem build *.gemspec
|
|
26
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
|
27
|
+
env:
|
|
28
|
+
GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
|
|
29
|
+
OWNER: MikeRogers0
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: RSpec
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v1
|
|
16
|
+
|
|
17
|
+
- name: Set up Ruby 2.7
|
|
18
|
+
uses: ruby/setup-ruby@v1
|
|
19
|
+
with:
|
|
20
|
+
ruby-version: 2.7.1
|
|
21
|
+
|
|
22
|
+
- uses: actions/cache@v1
|
|
23
|
+
with:
|
|
24
|
+
path: vendor/bundle
|
|
25
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
|
26
|
+
restore-keys: |
|
|
27
|
+
${{ runner.os }}-gems-
|
|
28
|
+
- name: Build
|
|
29
|
+
env:
|
|
30
|
+
RAILS_ENV: test
|
|
31
|
+
run: |
|
|
32
|
+
gem install bundler
|
|
33
|
+
bundle config path vendor/bundle
|
|
34
|
+
bundle install --jobs 4 --retry 3
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: |
|
|
37
|
+
bundle exec rake spec
|
data/.gitignore
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/vendor
|
|
2
|
+
/.bundle/
|
|
3
|
+
/.yardoc
|
|
4
|
+
/Gemfile.lock
|
|
5
|
+
/_yardoc/
|
|
6
|
+
/coverage/
|
|
7
|
+
/doc/
|
|
8
|
+
/pkg/
|
|
9
|
+
/spec/reports/
|
|
10
|
+
/tmp/
|
|
11
|
+
*.bundle
|
|
12
|
+
*.so
|
|
13
|
+
*.o
|
|
14
|
+
*.a
|
|
15
|
+
mkmf.log
|
|
16
|
+
*.gem
|
|
17
|
+
Gemfile.lock
|
|
18
|
+
.bundle
|
|
19
|
+
.ruby-version
|
|
20
|
+
|
|
21
|
+
# Node
|
|
22
|
+
node_modules
|
|
23
|
+
.npm
|
|
24
|
+
.node_repl_history
|
|
25
|
+
|
|
26
|
+
# Yarn
|
|
27
|
+
yarn-error.log
|
|
28
|
+
yarn-debug.log*
|
|
29
|
+
.pnp/
|
|
30
|
+
.pnp.js
|
|
31
|
+
|
|
32
|
+
# Yarn Integrity file
|
|
33
|
+
.yarn-integrity
|
|
34
|
+
|
|
35
|
+
spec/dest
|
|
36
|
+
.bridgetown-metadata
|
|
37
|
+
.bridgetown-cache
|
|
38
|
+
.bridgetown-webpack
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require: rubocop-bridgetown
|
|
2
|
+
|
|
3
|
+
inherit_gem:
|
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
|
5
|
+
|
|
6
|
+
AllCops:
|
|
7
|
+
TargetRubyVersion: 2.5
|
|
8
|
+
Include:
|
|
9
|
+
- lib/**/*.rb
|
|
10
|
+
|
|
11
|
+
Exclude:
|
|
12
|
+
- .gitignore
|
|
13
|
+
- .rspec
|
|
14
|
+
- .rubocop.yml
|
|
15
|
+
|
|
16
|
+
- Gemfile.lock
|
|
17
|
+
- CHANGELOG.md
|
|
18
|
+
- LICENSE.txt
|
|
19
|
+
- README.md
|
|
20
|
+
|
|
21
|
+
- script/**/*
|
|
22
|
+
- vendor/**/*
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased](https://github.com/MikeRogers0/bridgetown-minify-html/tree/HEAD)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/MikeRogers0/bridgetown-minify-html/compare/5ce9f22631f178ecf164501e7d28d6dee902ce9c...HEAD)
|
|
6
|
+
|
|
7
|
+
**Implemented enhancements:**
|
|
8
|
+
|
|
9
|
+
- Preparing for 0.1.0 release [\#3](https://github.com/MikeRogers0/bridgetown-minify-html/pull/3) ([MikeRogers0](https://github.com/MikeRogers0))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at me@mikerogers.io. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
FROM ruby:2.7.1-alpine AS builder
|
|
2
|
+
|
|
3
|
+
LABEL maintainer="Mike Rogers <me@mikerogers.io>"
|
|
4
|
+
|
|
5
|
+
RUN apk add --no-cache \
|
|
6
|
+
#
|
|
7
|
+
# required
|
|
8
|
+
build-base libffi-dev \
|
|
9
|
+
nodejs-dev yarn tzdata \
|
|
10
|
+
zlib-dev libxml2-dev libxslt-dev readline-dev bash \
|
|
11
|
+
# Nice to haves
|
|
12
|
+
git vim \
|
|
13
|
+
#
|
|
14
|
+
# Fixes watch file issues with things like HMR
|
|
15
|
+
libnotify-dev
|
|
16
|
+
|
|
17
|
+
FROM builder as development
|
|
18
|
+
|
|
19
|
+
# Add the current apps files into docker image
|
|
20
|
+
RUN mkdir -p /usr/src/app
|
|
21
|
+
WORKDIR /usr/src/app
|
|
22
|
+
|
|
23
|
+
ENV PATH /usr/src/app/bin:$PATH
|
|
24
|
+
|
|
25
|
+
# Install latest bundler
|
|
26
|
+
RUN bundle config --global silence_root_warning 1
|
|
27
|
+
|
|
28
|
+
EXPOSE 4000
|
|
29
|
+
CMD ["rspec"]
|
|
30
|
+
|
|
31
|
+
FROM development AS production
|
|
32
|
+
|
|
33
|
+
# Install Ruby Gems
|
|
34
|
+
COPY Gemfile /usr/src/app
|
|
35
|
+
COPY Gemfile.lock /usr/src/app
|
|
36
|
+
RUN bundle check || bundle install --jobs=$(nproc)
|
|
37
|
+
|
|
38
|
+
# Copy the rest of the app
|
|
39
|
+
COPY . /usr/src/app
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Mike Rogers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Bridgetown Minify HTML
|
|
2
|
+
|
|
3
|
+
A Bridgetown plugin to Minify your outputted HTML.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Run this command to add this plugin to your site's Gemfile:
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
bundle add bridgetown-minify-html -g bridgetown_plugins
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Once you've added the plugin, it'll automatically compress your outputted HTML without any additional configuration required.
|
|
16
|
+
|
|
17
|
+
### Optional configuration options
|
|
18
|
+
|
|
19
|
+
Within your `bridgetown.config.yml` file, you have the options:
|
|
20
|
+
|
|
21
|
+
```yml
|
|
22
|
+
minify_html:
|
|
23
|
+
enabled: true
|
|
24
|
+
remove_spaces_inside_tags: true
|
|
25
|
+
remove_multi_spaces: true
|
|
26
|
+
remove_comments: true
|
|
27
|
+
remove_intertag_spaces: false
|
|
28
|
+
remove_quotes: false
|
|
29
|
+
simple_doctype: false
|
|
30
|
+
remove_script_attributes: false
|
|
31
|
+
remove_style_attributes: false
|
|
32
|
+
remove_link_attributes: false
|
|
33
|
+
remove_form_attributes: false
|
|
34
|
+
remove_input_attributes: false
|
|
35
|
+
remove_javascript_protocol: false
|
|
36
|
+
remove_http_protocol: false
|
|
37
|
+
remove_https_protocol: false
|
|
38
|
+
preserve_line_breaks: false
|
|
39
|
+
simple_boolean_attributes: false
|
|
40
|
+
compress_js_templates: false
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Testing
|
|
44
|
+
|
|
45
|
+
* Run `bundle exec rspec` to run the test suite
|
|
46
|
+
* Or run `script/cibuild` to validate with Rubocop and test with rspec together.
|
|
47
|
+
|
|
48
|
+
## Contributing
|
|
49
|
+
|
|
50
|
+
1. Fork it (https://github.com/MikeRogers0/bridgetown-minify-html/fork)
|
|
51
|
+
2. Clone the fork using `git clone` to your local development machine.
|
|
52
|
+
3. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
|
53
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
54
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
|
55
|
+
6. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/bridgetown-minify-html/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "bridgetown-minify-html"
|
|
7
|
+
spec.version = BridgetownMinifyHtml::VERSION
|
|
8
|
+
spec.author = "Mike Rogers"
|
|
9
|
+
spec.email = "me@mikerogers.io"
|
|
10
|
+
spec.summary = "Minify Outputted HTML in Bridgetown"
|
|
11
|
+
spec.homepage = "https://github.com/MikeRogers0/bridgetown-minify-html"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
|
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
|
|
15
|
+
spec.test_files = spec.files.grep(%r!^spec/!)
|
|
16
|
+
spec.require_paths = ["lib"]
|
|
17
|
+
|
|
18
|
+
spec.required_ruby_version = ">= 2.5.0"
|
|
19
|
+
|
|
20
|
+
spec.add_dependency "bridgetown", ">= 0.15", "< 2.0"
|
|
21
|
+
spec.add_dependency "htmlcompressor", ">= 0.4", "< 1.0"
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler"
|
|
24
|
+
spec.add_development_dependency "nokogiri", "~> 1.6"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
|
|
28
|
+
end
|
data/docker-compose.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Docker Compose 2.4 is for local development
|
|
3
|
+
# https://www.heroku.com/podcasts/codeish/57-discussing-docker-containers-and-kubernetes-with-a-docker-captain - Source on that.
|
|
4
|
+
version: '2.4'
|
|
5
|
+
|
|
6
|
+
x-app: &app
|
|
7
|
+
image: bridetown-minify-html:latest
|
|
8
|
+
mem_limit: 512m
|
|
9
|
+
build:
|
|
10
|
+
context: .
|
|
11
|
+
dockerfile: Dockerfile
|
|
12
|
+
target: development
|
|
13
|
+
volumes:
|
|
14
|
+
- .:/usr/src/app:cached
|
|
15
|
+
- bundler:/usr/local/bundle:delegated
|
|
16
|
+
|
|
17
|
+
services:
|
|
18
|
+
web:
|
|
19
|
+
<<: *app
|
|
20
|
+
command: >
|
|
21
|
+
bash -c "bundle check || bundle install &&
|
|
22
|
+
rspec"
|
|
23
|
+
volumes:
|
|
24
|
+
bundler:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This add the hook for when the site has been built & is ready for compression.
|
|
4
|
+
module BridgetownMinifyHtml
|
|
5
|
+
class Builder < Bridgetown::Builder
|
|
6
|
+
def build
|
|
7
|
+
return if config[:watch]
|
|
8
|
+
|
|
9
|
+
hook :site, :post_render, priority: :low do |site|
|
|
10
|
+
BridgetownMinifyHtml::Minifier.new(site).call!
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
BridgetownMinifyHtml::Builder.register
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This actually does the Minification. It gets passed the site object, then it'll just loop through all the pages
|
|
4
|
+
# and documents.
|
|
5
|
+
module BridgetownMinifyHtml
|
|
6
|
+
class Minifier
|
|
7
|
+
DEFAULT_OPTIONS = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
remove_spaces_inside_tags: true,
|
|
10
|
+
remove_multi_spaces: true,
|
|
11
|
+
remove_comments: true,
|
|
12
|
+
remove_intertag_spaces: false,
|
|
13
|
+
remove_quotes: false,
|
|
14
|
+
simple_doctype: false,
|
|
15
|
+
remove_script_attributes: false,
|
|
16
|
+
remove_style_attributes: false,
|
|
17
|
+
remove_link_attributes: false,
|
|
18
|
+
remove_form_attributes: false,
|
|
19
|
+
remove_input_attributes: false,
|
|
20
|
+
remove_javascript_protocol: false,
|
|
21
|
+
remove_http_protocol: false,
|
|
22
|
+
remove_https_protocol: false,
|
|
23
|
+
preserve_line_breaks: false,
|
|
24
|
+
simple_boolean_attributes: false,
|
|
25
|
+
compress_js_templates: false,
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
def initialize(site)
|
|
29
|
+
@site = site
|
|
30
|
+
@minified_count = 0
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def call!
|
|
34
|
+
(@site.pages + @site.documents).each do |page|
|
|
35
|
+
minify_page(page)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Bridgetown.logger.info "Minify HTML:", "Complete, Processed #{@minified_count} file(s)"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def minify_page(page)
|
|
44
|
+
return unless compressible?(page.output_ext)
|
|
45
|
+
|
|
46
|
+
page.output = compressor.compress(page.output)
|
|
47
|
+
@minified_count += 1
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def compressible?(extension)
|
|
51
|
+
[".html", ".svg", ".xml"].include?(extension)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def compressor
|
|
55
|
+
@compressor ||= HtmlCompressor::Compressor.new(options)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def options
|
|
59
|
+
@options ||= DEFAULT_OPTIONS.merge(options_overrides)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def options_overrides
|
|
63
|
+
@options_overrides ||= (@site.config["minify_html"] || {})
|
|
64
|
+
.each_with_object({}) { |(k, v), new_config| new_config[k.to_sym] = v; }
|
|
65
|
+
.compact
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bridgetown-minify-html
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mike Rogers
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bridgetown
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.15'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '2.0'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0.15'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: htmlcompressor
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.4'
|
|
40
|
+
- - "<"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '1.0'
|
|
43
|
+
type: :runtime
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0.4'
|
|
50
|
+
- - "<"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '1.0'
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: bundler
|
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
type: :development
|
|
61
|
+
prerelease: false
|
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: nokogiri
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '1.6'
|
|
74
|
+
type: :development
|
|
75
|
+
prerelease: false
|
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '1.6'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: rake
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '12.0'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '12.0'
|
|
95
|
+
- !ruby/object:Gem::Dependency
|
|
96
|
+
name: rspec
|
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - "~>"
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '3.0'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - "~>"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '3.0'
|
|
109
|
+
- !ruby/object:Gem::Dependency
|
|
110
|
+
name: rubocop-bridgetown
|
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - "~>"
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0.2'
|
|
116
|
+
type: :development
|
|
117
|
+
prerelease: false
|
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - "~>"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0.2'
|
|
123
|
+
description:
|
|
124
|
+
email: me@mikerogers.io
|
|
125
|
+
executables: []
|
|
126
|
+
extensions: []
|
|
127
|
+
extra_rdoc_files: []
|
|
128
|
+
files:
|
|
129
|
+
- ".github/FUNDING.yml"
|
|
130
|
+
- ".github/dependabot.yml"
|
|
131
|
+
- ".github/workflows/changelog.yml"
|
|
132
|
+
- ".github/workflows/gempush.yml"
|
|
133
|
+
- ".github/workflows/rspec.yml"
|
|
134
|
+
- ".gitignore"
|
|
135
|
+
- ".rspec"
|
|
136
|
+
- ".rubocop.yml"
|
|
137
|
+
- CHANGELOG.md
|
|
138
|
+
- CODE_OF_CONDUCT.md
|
|
139
|
+
- Dockerfile
|
|
140
|
+
- Gemfile
|
|
141
|
+
- LICENSE
|
|
142
|
+
- README.md
|
|
143
|
+
- Rakefile
|
|
144
|
+
- bridgetown-minify-html.gemspec
|
|
145
|
+
- docker-compose.yml
|
|
146
|
+
- lib/bridgetown-minify-html.rb
|
|
147
|
+
- lib/bridgetown-minify-html/builder.rb
|
|
148
|
+
- lib/bridgetown-minify-html/minifier.rb
|
|
149
|
+
- lib/bridgetown-minify-html/version.rb
|
|
150
|
+
homepage: https://github.com/MikeRogers0/bridgetown-minify-html
|
|
151
|
+
licenses:
|
|
152
|
+
- MIT
|
|
153
|
+
metadata: {}
|
|
154
|
+
post_install_message:
|
|
155
|
+
rdoc_options: []
|
|
156
|
+
require_paths:
|
|
157
|
+
- lib
|
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
|
+
requirements:
|
|
160
|
+
- - ">="
|
|
161
|
+
- !ruby/object:Gem::Version
|
|
162
|
+
version: 2.5.0
|
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
|
+
requirements:
|
|
165
|
+
- - ">="
|
|
166
|
+
- !ruby/object:Gem::Version
|
|
167
|
+
version: '0'
|
|
168
|
+
requirements: []
|
|
169
|
+
rubygems_version: 3.1.2
|
|
170
|
+
signing_key:
|
|
171
|
+
specification_version: 4
|
|
172
|
+
summary: Minify Outputted HTML in Bridgetown
|
|
173
|
+
test_files: []
|