Skip to content

Commit 65d9f18

Browse files
committed
v1.4.0
- Sending to `HtmlMin` parameters improved #4 - Added PHP 8.0 support - Updated dependencies
1 parent 3dd936a commit 65d9f18

File tree

14 files changed

+159
-53
lines changed

14 files changed

+159
-53
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ The default values of the package are:
3535
| doRemoveWhitespaceAroundTags | remove whitespace around tags (depends on "doOptimizeViaHtmlDomParser(true)") |
3636
| doOptimizeAttributes | optimize html attributes (depends on "doOptimizeViaHtmlDomParser(true)") |
3737
| doRemoveHttpPrefixFromAttributes | remove optional "http:"-prefix from attributes (depends on "doOptimizeAttributes(true)") |
38+
| doRemoveHttpsPrefixFromAttributes | remove optional "https:"-prefix from attributes (depends on "doOptimizeAttributes(true)") |
39+
| doKeepHttpAndHttpsPrefixOnExternalAttributes | keep "http:"- and "https:"-prefix for all external links |
40+
| doMakeSameDomainsLinksRelative | make some links relative, by removing the domain from attributes |
3841
| doRemoveDefaultAttributes | remove defaults (depends on "doOptimizeAttributes(true)" | disabled by default) |
3942
| doRemoveDeprecatedAnchorName | remove deprecated anchor-jump (depends on "doOptimizeAttributes(true)") |
4043
| doRemoveDeprecatedScriptCharsetAttribute | remove deprecated charset-attribute - the browser will use the charset from the HTTP-Header, anyway (depends on "doOptimizeAttributes(true)") |
4144
| doRemoveDeprecatedTypeFromScriptTag | remove deprecated script-mime-types (depends on "doOptimizeAttributes(true)") |
4245
| doRemoveDeprecatedTypeFromStylesheetLink | remove "type=text/css" for css links (depends on "doOptimizeAttributes(true)") |
46+
| doRemoveDeprecatedTypeFromStyleAndLinkTag | remove "type=text/css" from all links and styles |
47+
| doRemoveDefaultMediaTypeFromStyleAndLinkTag | remove "media="all" from all links and styles |
48+
| doRemoveDefaultTypeFromButton | remove type="submit" from button tags |
4349
| doRemoveEmptyAttributes | remove some empty attributes (depends on "doOptimizeAttributes(true)") |
4450
| doRemoveValueFromEmptyInput | remove 'value=""' from empty <input> (depends on "doOptimizeAttributes(true)") |
4551
| doSortCssClassNames | sort css-class-names, for better gzip results (depends on "doOptimizeAttributes(true)") |
@@ -63,8 +69,9 @@ https://github.com/voku/HtmlMin#options
6369
return [
6470
'afbora.kirby-minify-html.enabled' => true,
6571
'afbora.kirby-minify-html.options' => [
66-
'doOptimizeViaHtmlDomParser' => true, // set true/false or remove line to default
67-
'doRemoveSpacesBetweenTags' => false // set true/false or remove line to default
72+
'doOptimizeViaHtmlDomParser' => true,
73+
'doRemoveSpacesBetweenTags' => false,
74+
'doMakeSameDomainsLinksRelative' => ['example.com']
6875
],
6976
];
7077
````

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"kirby3-plugin",
99
"kirby-plugin"
1010
],
11-
"version": "1.3.0",
11+
"version": "1.4.0",
1212
"type": "kirby-plugin",
1313
"license": "MIT",
1414
"authors": [
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^7.3",
21+
"php": "^7.3|^8.0",
2222
"getkirby/composer-installer": "^1.2",
2323
"voku/html-min": "^4.4"
2424
},

index.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ public function render(array $data = []): string
1818

1919
$options = option('afbora.kirby-minify-html.options', []);
2020

21-
foreach ($options as $option => $status) {
22-
if (method_exists($htmlMin, $option)) {
23-
$htmlMin->{$option}((bool)$status);
21+
foreach ($options as $option => $param) {
22+
if (method_exists($htmlMin, $option) === true) {
23+
if ($param !== null) {
24+
$htmlMin->{$option}($param);
25+
} else {
26+
$htmlMin->{$option}();
27+
}
2428
}
2529
}
2630

vendor/composer/InstalledVersions.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class InstalledVersions
2424
private static $installed = array (
2525
'root' =>
2626
array (
27-
'pretty_version' => '1.3.0',
28-
'version' => '1.3.0.0',
27+
'pretty_version' => '1.4.0',
28+
'version' => '1.4.0.0',
2929
'aliases' =>
3030
array (
3131
),
@@ -36,8 +36,8 @@ class InstalledVersions
3636
array (
3737
'afbora/kirby-minify-html' =>
3838
array (
39-
'pretty_version' => '1.3.0',
40-
'version' => '1.3.0.0',
39+
'pretty_version' => '1.4.0',
40+
'version' => '1.4.0.0',
4141
'aliases' =>
4242
array (
4343
),
@@ -54,12 +54,12 @@ class InstalledVersions
5454
),
5555
'symfony/css-selector' =>
5656
array (
57-
'pretty_version' => 'v5.2.2',
58-
'version' => '5.2.2.0',
57+
'pretty_version' => 'v5.2.9',
58+
'version' => '5.2.9.0',
5959
'aliases' =>
6060
array (
6161
),
62-
'reference' => 'f65f217b3314504a1ec99c2d6ef69016bb13490f',
62+
'reference' => '5d5f97809015102116208b976eb2edb44b689560',
6363
),
6464
'voku/html-min' =>
6565
array (
@@ -72,12 +72,12 @@ class InstalledVersions
7272
),
7373
'voku/simple_html_dom' =>
7474
array (
75-
'pretty_version' => '4.7.28',
76-
'version' => '4.7.28.0',
75+
'pretty_version' => '4.7.29',
76+
'version' => '4.7.29.0',
7777
'aliases' =>
7878
array (
7979
),
80-
'reference' => '78d5894c7f0facfb4fb6369af15b1a87baea958c',
80+
'reference' => '079067c704b714b7c2813971297bb340307813e7',
8181
),
8282
),
8383
);

vendor/composer/installed.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@
5252
},
5353
{
5454
"name": "symfony/css-selector",
55-
"version": "v5.2.2",
56-
"version_normalized": "5.2.2.0",
55+
"version": "v5.2.9",
56+
"version_normalized": "5.2.9.0",
5757
"source": {
5858
"type": "git",
5959
"url": "https://github.com/symfony/css-selector.git",
60-
"reference": "f65f217b3314504a1ec99c2d6ef69016bb13490f"
60+
"reference": "5d5f97809015102116208b976eb2edb44b689560"
6161
},
6262
"dist": {
6363
"type": "zip",
64-
"url": "https://api.github.com/repos/symfony/css-selector/zipball/f65f217b3314504a1ec99c2d6ef69016bb13490f",
65-
"reference": "f65f217b3314504a1ec99c2d6ef69016bb13490f",
64+
"url": "https://api.github.com/repos/symfony/css-selector/zipball/5d5f97809015102116208b976eb2edb44b689560",
65+
"reference": "5d5f97809015102116208b976eb2edb44b689560",
6666
"shasum": ""
6767
},
6868
"require": {
6969
"php": ">=7.2.5"
7070
},
71-
"time": "2021-01-27T10:01:46+00:00",
71+
"time": "2021-05-16T13:07:46+00:00",
7272
"type": "library",
7373
"installation-source": "dist",
7474
"autoload": {
@@ -100,7 +100,7 @@
100100
"description": "Converts CSS selectors to XPath expressions",
101101
"homepage": "https://symfony.com",
102102
"support": {
103-
"source": "https://github.com/symfony/css-selector/tree/v5.2.2"
103+
"source": "https://github.com/symfony/css-selector/tree/v5.2.9"
104104
},
105105
"funding": [
106106
{
@@ -190,17 +190,17 @@
190190
},
191191
{
192192
"name": "voku/simple_html_dom",
193-
"version": "4.7.28",
194-
"version_normalized": "4.7.28.0",
193+
"version": "4.7.29",
194+
"version_normalized": "4.7.29.0",
195195
"source": {
196196
"type": "git",
197197
"url": "https://github.com/voku/simple_html_dom.git",
198-
"reference": "78d5894c7f0facfb4fb6369af15b1a87baea958c"
198+
"reference": "079067c704b714b7c2813971297bb340307813e7"
199199
},
200200
"dist": {
201201
"type": "zip",
202-
"url": "https://api.github.com/repos/voku/simple_html_dom/zipball/78d5894c7f0facfb4fb6369af15b1a87baea958c",
203-
"reference": "78d5894c7f0facfb4fb6369af15b1a87baea958c",
202+
"url": "https://api.github.com/repos/voku/simple_html_dom/zipball/079067c704b714b7c2813971297bb340307813e7",
203+
"reference": "079067c704b714b7c2813971297bb340307813e7",
204204
"shasum": ""
205205
},
206206
"require": {
@@ -216,7 +216,7 @@
216216
"suggest": {
217217
"voku/portable-utf8": "If you need e.g. UTF-8 fixed output."
218218
},
219-
"time": "2020-11-17T23:30:43+00:00",
219+
"time": "2021-03-29T14:56:56+00:00",
220220
"type": "library",
221221
"installation-source": "dist",
222222
"autoload": {
@@ -250,7 +250,7 @@
250250
],
251251
"support": {
252252
"issues": "https://github.com/voku/simple_html_dom/issues",
253-
"source": "https://github.com/voku/simple_html_dom/tree/4.7.28"
253+
"source": "https://github.com/voku/simple_html_dom/tree/4.7.29"
254254
},
255255
"funding": [
256256
{

vendor/composer/installed.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array (
22
'root' =>
33
array (
4-
'pretty_version' => '1.3.0',
5-
'version' => '1.3.0.0',
4+
'pretty_version' => '1.4.0',
5+
'version' => '1.4.0.0',
66
'aliases' =>
77
array (
88
),
@@ -13,8 +13,8 @@
1313
array (
1414
'afbora/kirby-minify-html' =>
1515
array (
16-
'pretty_version' => '1.3.0',
17-
'version' => '1.3.0.0',
16+
'pretty_version' => '1.4.0',
17+
'version' => '1.4.0.0',
1818
'aliases' =>
1919
array (
2020
),
@@ -31,12 +31,12 @@
3131
),
3232
'symfony/css-selector' =>
3333
array (
34-
'pretty_version' => 'v5.2.2',
35-
'version' => '5.2.2.0',
34+
'pretty_version' => 'v5.2.9',
35+
'version' => '5.2.9.0',
3636
'aliases' =>
3737
array (
3838
),
39-
'reference' => 'f65f217b3314504a1ec99c2d6ef69016bb13490f',
39+
'reference' => '5d5f97809015102116208b976eb2edb44b689560',
4040
),
4141
'voku/html-min' =>
4242
array (
@@ -49,12 +49,12 @@
4949
),
5050
'voku/simple_html_dom' =>
5151
array (
52-
'pretty_version' => '4.7.28',
53-
'version' => '4.7.28.0',
52+
'pretty_version' => '4.7.29',
53+
'version' => '4.7.29.0',
5454
'aliases' =>
5555
array (
5656
),
57-
'reference' => '78d5894c7f0facfb4fb6369af15b1a87baea958c',
57+
'reference' => '079067c704b714b7c2813971297bb340307813e7',
5858
),
5959
),
6060
);

vendor/symfony/css-selector/Parser/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Parser implements ParserInterface
3131

3232
public function __construct(Tokenizer $tokenizer = null)
3333
{
34-
$this->tokenizer = $tokenizer ?: new Tokenizer();
34+
$this->tokenizer = $tokenizer ?? new Tokenizer();
3535
}
3636

3737
/**

vendor/symfony/css-selector/XPath/Extension/NodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function translateElement(Node\ElementNode $node): XPathExpr
157157
{
158158
$element = $node->getElement();
159159

160-
if ($this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) {
160+
if ($element && $this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) {
161161
$element = strtolower($element);
162162
}
163163

vendor/symfony/css-selector/XPath/Translator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Translator implements TranslatorInterface
5050

5151
public function __construct(ParserInterface $parser = null)
5252
{
53-
$this->mainParser = $parser ?: new Parser();
53+
$this->mainParser = $parser ?? new Parser();
5454

5555
$this
5656
->registerExtension(new Extension\NodeExtension())
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
php: [
20+
7.0,
21+
7.1,
22+
7.2,
23+
7.3,
24+
7.4,
25+
8.0
26+
]
27+
composer: [basic]
28+
timeout-minutes: 10
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v2
32+
33+
- name: Setup PHP
34+
uses: shivammathur/[email protected]
35+
with:
36+
php-version: ${{ matrix.php }}
37+
coverage: xdebug
38+
extensions: zip
39+
tools: composer
40+
41+
- name: Determine composer cache directory
42+
id: composer-cache
43+
run: echo "::set-output name=directory::$(composer config cache-dir)"
44+
45+
- name: Cache composer dependencies
46+
uses: actions/[email protected]
47+
with:
48+
path: ${{ steps.composer-cache.outputs.directory }}
49+
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
50+
restore-keys: ${{ matrix.php }}-composer-
51+
52+
- name: Install dependencies
53+
run: |
54+
if [[ "${{ matrix.php }}" == "7.4" ]]; then
55+
composer require phpstan/phpstan --no-update
56+
fi;
57+
58+
if [[ "${{ matrix.composer }}" == "lowest" ]]; then
59+
composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable
60+
fi;
61+
62+
if [[ "${{ matrix.composer }}" == "basic" ]]; then
63+
composer update --prefer-dist --no-interaction
64+
fi;
65+
66+
composer dump-autoload -o
67+
68+
- name: Run tests
69+
run: |
70+
mkdir -p build/logs
71+
php vendor/bin/phpunit -c phpunit.xml --coverage-clover=build/logs/clover.xml
72+
73+
- name: Run phpstan
74+
continue-on-error: true
75+
if: ${{ matrix.php == '7.4' }}
76+
run: |
77+
php vendor/bin/phpstan analyse
78+
79+
- name: Upload coverage results to Coveralls
80+
env:
81+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
composer global require php-coveralls/php-coveralls
84+
php-coveralls --coverage_clover=build/logs/clover.xml -v
85+
86+
- name: Upload coverage results to Codecov
87+
uses: codecov/codecov-action@v1
88+
with:
89+
files: build/logs/clover.xml
90+
91+
- name: Upload coverage results to Scrutinizer
92+
uses: sudo-bot/action-scrutinizer@latest
93+
with:
94+
cli-args: "--format=php-clover build/logs/clover.xml"
95+
96+
- name: Archive logs artifacts
97+
if: ${{ failure() }}
98+
uses: actions/upload-artifact@v2
99+
with:
100+
name: logs_composer-${{ matrix.composer }}_php-${{ matrix.php }}
101+
path: |
102+
build/logs

0 commit comments

Comments
 (0)