Minify support
This commit is contained in:
parent
1eefeb6954
commit
1efce0ad7b
|
@ -2,6 +2,12 @@
|
|||
"name": "allerta-vvf/allerta-vvf",
|
||||
"description": "Un software di allertamento per i vvf",
|
||||
"type": "project",
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/allerta-vvf/tiny-html-minifier"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"twig/twig": "^3.2.1",
|
||||
"delight-im/auth": "^8.3.0",
|
||||
|
@ -12,7 +18,8 @@
|
|||
"brick/phonenumber": "^0.2.2",
|
||||
"sentry/sdk": "^3.1",
|
||||
"maximebf/debugbar": "^1.16",
|
||||
"ministryofweb/php-osm-tiles": "^2.0"
|
||||
"ministryofweb/php-osm-tiles": "^2.0",
|
||||
"jenstornell/tiny-html-minifier": "dev-master"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"authors": [
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "990b7f16635b967bd1cafc536774530d",
|
||||
"content-hash": "c59f5a601b2cf561d3a7d98c6e145afd",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/phonenumber",
|
||||
|
@ -393,16 +393,16 @@
|
|||
},
|
||||
{
|
||||
"name": "giggsey/libphonenumber-for-php",
|
||||
"version": "8.12.20",
|
||||
"version": "8.12.21",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/giggsey/libphonenumber-for-php.git",
|
||||
"reference": "743585979ef96f2be123518c0a58083cf678bd47"
|
||||
"reference": "272b8123ba7f1b7975620c6389e7206281b4a3ce"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/743585979ef96f2be123518c0a58083cf678bd47",
|
||||
"reference": "743585979ef96f2be123518c0a58083cf678bd47",
|
||||
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/272b8123ba7f1b7975620c6389e7206281b4a3ce",
|
||||
"reference": "272b8123ba7f1b7975620c6389e7206281b4a3ce",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -462,7 +462,7 @@
|
|||
"issues": "https://github.com/giggsey/libphonenumber-for-php/issues",
|
||||
"source": "https://github.com/giggsey/libphonenumber-for-php"
|
||||
},
|
||||
"time": "2021-03-17T11:05:55+00:00"
|
||||
"time": "2021-04-06T08:37:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "giggsey/locale",
|
||||
|
@ -760,6 +760,47 @@
|
|||
},
|
||||
"time": "2021-02-22T10:52:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jenstornell/tiny-html-minifier",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/allerta-vvf/tiny-html-minifier.git",
|
||||
"reference": "5e997f570fe637a4c1c996bdcc8f9beaa26940a2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/allerta-vvf/tiny-html-minifier/zipball/5e997f570fe637a4c1c996bdcc8f9beaa26940a2",
|
||||
"reference": "5e997f570fe637a4c1c996bdcc8f9beaa26940a2",
|
||||
"shasum": ""
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Minifier\\": "src/"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jens Törnell",
|
||||
"email": "webblayout@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Minify HTML in PHP with just a single class",
|
||||
"keywords": [
|
||||
"html",
|
||||
"minifier",
|
||||
"minify"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/allerta-vvf/tiny-html-minifier/tree/master"
|
||||
},
|
||||
"time": "2021-04-27T22:20:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "v1.16.5",
|
||||
|
@ -884,26 +925,26 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/FastRoute.git",
|
||||
"reference": "7723b1dcb0084baaa1f36df25d5720b7b85b62d6"
|
||||
"reference": "b5543adef5e16738471a52fdf55ff802edf1141d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/7723b1dcb0084baaa1f36df25d5720b7b85b62d6",
|
||||
"reference": "7723b1dcb0084baaa1f36df25d5720b7b85b62d6",
|
||||
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5543adef5e16738471a52fdf55ff802edf1141d",
|
||||
"reference": "b5543adef5e16738471a52fdf55ff802edf1141d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.0"
|
||||
"php": ">=7.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^6.0 || ^7.0",
|
||||
"phpbench/phpbench": "^0.16.9",
|
||||
"doctrine/coding-standard": "^9.0",
|
||||
"phpbench/phpbench": "^1.0@beta",
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "^0.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^0.12",
|
||||
"phpstan/phpstan-phpunit": "^0.12",
|
||||
"phpstan/phpstan-strict-rules": "^0.12",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5"
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
|
@ -939,7 +980,7 @@
|
|||
"issues": "https://github.com/nikic/FastRoute/issues",
|
||||
"source": "https://github.com/nikic/FastRoute/tree/master"
|
||||
},
|
||||
"time": "2020-09-28T10:21:28+00:00"
|
||||
"time": "2021-04-27T09:57:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/client-common",
|
||||
|
@ -1692,16 +1733,16 @@
|
|||
},
|
||||
{
|
||||
"name": "sentry/sentry",
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/getsentry/sentry-php.git",
|
||||
"reference": "899b0de58c1e01feb54829b3094af74252aff385"
|
||||
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/899b0de58c1e01feb54829b3094af74252aff385",
|
||||
"reference": "899b0de58c1e01feb54829b3094af74252aff385",
|
||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
|
||||
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1780,7 +1821,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/getsentry/sentry-php/issues",
|
||||
"source": "https://github.com/getsentry/sentry-php/tree/3.2.0"
|
||||
"source": "https://github.com/getsentry/sentry-php/tree/3.2.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1792,7 +1833,7 @@
|
|||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-03T11:54:34+00:00"
|
||||
"time": "2021-04-06T07:55:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/array-to-xml",
|
||||
|
@ -2896,16 +2937,16 @@
|
|||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.5.8",
|
||||
"version": "3.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
|
||||
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
|
||||
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
|
||||
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2948,13 +2989,14 @@
|
|||
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"time": "2020-10-23T02:01:07+00:00"
|
||||
"time": "2021-04-09T00:54:41+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"nikic/fast-route": 20
|
||||
"nikic/fast-route": 20,
|
||||
"jenstornell/tiny-html-minifier": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% apply minimize %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
|
@ -96,4 +97,5 @@
|
|||
{% endblock %}
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
{% endapply %}
|
|
@ -22,18 +22,20 @@ try {
|
|||
} catch (Exception $e) {
|
||||
$loader = new \Twig\Loader\FilesystemLoader('../templates');
|
||||
}
|
||||
$filter = new \Twig\TwigFilter(
|
||||
't', function ($string) {
|
||||
global $translations;
|
||||
return $translations->translate($string);
|
||||
}
|
||||
);
|
||||
$twig = new \Twig\Environment(
|
||||
$loader, [
|
||||
//'cache' => 'compilation'
|
||||
]
|
||||
);
|
||||
$twig->addFilter($filter);
|
||||
|
||||
$filter_translate = new \Twig\TwigFilter(
|
||||
't', function ($string) {
|
||||
global $translations;
|
||||
return $translations->translate($string);
|
||||
}
|
||||
);
|
||||
$twig->addFilter($filter_translate);
|
||||
|
||||
$function_option = new \Twig\TwigFunction(
|
||||
'option', function ($option) {
|
||||
global $database;
|
||||
|
@ -41,6 +43,7 @@ $function_option = new \Twig\TwigFunction(
|
|||
}
|
||||
);
|
||||
$twig->addFunction($function_option);
|
||||
|
||||
$function_username = new \Twig\TwigFunction(
|
||||
'username', function ($id) {
|
||||
global $user;
|
||||
|
@ -48,6 +51,7 @@ $function_username = new \Twig\TwigFunction(
|
|||
}
|
||||
);
|
||||
$twig->addFunction($function_username);
|
||||
|
||||
$function_resource = new \Twig\TwigFunction(
|
||||
'resource', function ($file) {
|
||||
global $webpack_manifest;
|
||||
|
@ -55,6 +59,20 @@ $function_resource = new \Twig\TwigFunction(
|
|||
}
|
||||
);
|
||||
$twig->addFunction($function_resource);
|
||||
|
||||
$filter_minimize = new \Twig\TwigFilter(
|
||||
'minimize', function ($content) {
|
||||
if(isset($_REQUEST["skip_minify"])){
|
||||
return $content;
|
||||
} else {
|
||||
return Minifier\TinyMinify::html($content, [
|
||||
'collapse_whitespace' => true,
|
||||
'disable_comments' => true,
|
||||
]);
|
||||
}
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
$twig->addFilter($filter_minimize);
|
||||
p_stop();
|
||||
|
||||
$template = null;
|
||||
|
|
Loading…
Reference in New Issue