From d8adc26b0397c15273602d36e7d3735be3c6dd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 7 May 2020 23:35:20 +0200 Subject: [PATCH] Use twigs builtin filter to inline data urls, instead of a custom one. --- composer.json | 1 + composer.lock | 97 ++++++++++++++----- src/Twig/DataInlinerExtension.php | 40 -------- symfony.lock | 3 + .../AdminPages/LabelProfileAdmin.html.twig | 2 +- templates/LabelSystem/dialog.html.twig | 2 +- .../labels/label_page_1d.html.twig | 2 +- .../labels/label_page_qr.html.twig | 2 +- 8 files changed, 83 insertions(+), 66 deletions(-) delete mode 100644 src/Twig/DataInlinerExtension.php diff --git a/composer.json b/composer.json index 7225ddbd..4cbd0449 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "tecnickcom/tc-lib-barcode": "^1.15", "twig/cssinliner-extra": "^3.0", "twig/extra-bundle": "^3.0", + "twig/html-extra": "^3.0", "twig/inky-extra": "^3.0", "twig/intl-extra": "^3.0", "twig/markdown-extra": "^3.0", diff --git a/composer.lock b/composer.lock index ed25d70e..bd29c3d6 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "c0b791f7fcf138f1677c99085ca3488d", + "content-hash": "08c388456fd013cb56d78205a1d8002c", "packages": [ { "name": "beberlei/assert", @@ -8824,6 +8824,59 @@ ], "time": "2020-01-01T17:11:09+00:00" }, + { + "name": "twig/html-extra", + "version": "v3.0.3", + "source": { + "type": "git", + "url": "https://github.com/twigphp/html-extra.git", + "reference": "0a0340aaba8c09e1c899d81fce6d45a1d6e448d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/html-extra/zipball/0a0340aaba8c09e1c899d81fce6d45a1d6e448d5", + "reference": "0a0340aaba8c09e1c899d81fce6d45a1d6e448d5", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/mime": "^4.3|^5.0", + "twig/twig": "^2.4|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\Extra\\Html\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for HTML", + "homepage": "https://twig.symfony.com", + "keywords": [ + "html", + "twig" + ], + "time": "2020-01-01T17:11:09+00:00" + }, { "name": "twig/inky-extra", "version": "v3.0.3", @@ -11605,12 +11658,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/auto-bind-parameter.git", - "reference": "de96bbe22df7d5693f07afb3ff49fd83a36b9118" + "reference": "893c54b7607bec7d54e2aa3eec49b6a557117dcd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/auto-bind-parameter/zipball/de96bbe22df7d5693f07afb3ff49fd83a36b9118", - "reference": "de96bbe22df7d5693f07afb3ff49fd83a36b9118", + "url": "https://api.github.com/repos/symplify/auto-bind-parameter/zipball/893c54b7607bec7d54e2aa3eec49b6a557117dcd", + "reference": "893c54b7607bec7d54e2aa3eec49b6a557117dcd", "shasum": "" }, "require": { @@ -11647,12 +11700,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/autowire-array-parameter.git", - "reference": "24c0249263a3b3201bd4026e942358a3bb8b6a27" + "reference": "669bc52f154bb170734623d6df6fbc489d362d73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/autowire-array-parameter/zipball/24c0249263a3b3201bd4026e942358a3bb8b6a27", - "reference": "24c0249263a3b3201bd4026e942358a3bb8b6a27", + "url": "https://api.github.com/repos/symplify/autowire-array-parameter/zipball/669bc52f154bb170734623d6df6fbc489d362d73", + "reference": "669bc52f154bb170734623d6df6fbc489d362d73", "shasum": "" }, "require": { @@ -11688,12 +11741,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/coding-standard.git", - "reference": "0a964b7c8fba99ebd5e7280fba27304b3603157b" + "reference": "7a807c6bbfe70fd99f1803ee4b04e6374fc71b84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/coding-standard/zipball/0a964b7c8fba99ebd5e7280fba27304b3603157b", - "reference": "0a964b7c8fba99ebd5e7280fba27304b3603157b", + "url": "https://api.github.com/repos/symplify/coding-standard/zipball/7a807c6bbfe70fd99f1803ee4b04e6374fc71b84", + "reference": "7a807c6bbfe70fd99f1803ee4b04e6374fc71b84", "shasum": "" }, "require": { @@ -11738,12 +11791,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/easy-coding-standard.git", - "reference": "1bfbcac5f9d09e8128962372f0dad54f5c310091" + "reference": "bd48e4a92271545a9e09d760de7fc4048828ba34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/1bfbcac5f9d09e8128962372f0dad54f5c310091", - "reference": "1bfbcac5f9d09e8128962372f0dad54f5c310091", + "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/bd48e4a92271545a9e09d760de7fc4048828ba34", + "reference": "bd48e4a92271545a9e09d760de7fc4048828ba34", "shasum": "" }, "require": { @@ -11806,12 +11859,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/package-builder.git", - "reference": "e99dd64a9d14defd8217e4671d555d24eab80196" + "reference": "608528685d82919e47d5b30873f46d563a39dcb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/package-builder/zipball/e99dd64a9d14defd8217e4671d555d24eab80196", - "reference": "e99dd64a9d14defd8217e4671d555d24eab80196", + "url": "https://api.github.com/repos/symplify/package-builder/zipball/608528685d82919e47d5b30873f46d563a39dcb8", + "reference": "608528685d82919e47d5b30873f46d563a39dcb8", "shasum": "" }, "require": { @@ -11852,12 +11905,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/set-config-resolver.git", - "reference": "bd8fe245c0dbdc358416919239f2fa86ecb0afe4" + "reference": "07bfa46ba78ec952ee27b6c0b38aedf580cc8c10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/set-config-resolver/zipball/bd8fe245c0dbdc358416919239f2fa86ecb0afe4", - "reference": "bd8fe245c0dbdc358416919239f2fa86ecb0afe4", + "url": "https://api.github.com/repos/symplify/set-config-resolver/zipball/07bfa46ba78ec952ee27b6c0b38aedf580cc8c10", + "reference": "07bfa46ba78ec952ee27b6c0b38aedf580cc8c10", "shasum": "" }, "require": { @@ -11895,12 +11948,12 @@ "source": { "type": "git", "url": "https://github.com/symplify/smart-file-system.git", - "reference": "c231445db395a33c222ca1ccf7f63857c2fc45d3" + "reference": "f22a5a0a868131ba0af5700766eddd1cfa4bda15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/smart-file-system/zipball/c231445db395a33c222ca1ccf7f63857c2fc45d3", - "reference": "c231445db395a33c222ca1ccf7f63857c2fc45d3", + "url": "https://api.github.com/repos/symplify/smart-file-system/zipball/f22a5a0a868131ba0af5700766eddd1cfa4bda15", + "reference": "f22a5a0a868131ba0af5700766eddd1cfa4bda15", "shasum": "" }, "require": { diff --git a/src/Twig/DataInlinerExtension.php b/src/Twig/DataInlinerExtension.php deleted file mode 100644 index 0676abaf..00000000 --- a/src/Twig/DataInlinerExtension.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -namespace App\Twig; - - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -class DataInlinerExtension extends AbstractExtension -{ - public function getFunctions() - { - return [ - new TwigFunction('inlineData', [$this, 'inlineData']) - ]; - } - - public function inlineData(string $data, string $mime_type) - { - return 'data:' . $mime_type . ';base64,' . base64_encode($data); - } -} \ No newline at end of file diff --git a/symfony.lock b/symfony.lock index 3fcecf9d..98ba90c5 100644 --- a/symfony.lock +++ b/symfony.lock @@ -866,6 +866,9 @@ "twig/extra-bundle": { "version": "v3.0.0" }, + "twig/html-extra": { + "version": "v3.0.3" + }, "twig/inky-extra": { "version": "v3.0.0" }, diff --git a/templates/AdminPages/LabelProfileAdmin.html.twig b/templates/AdminPages/LabelProfileAdmin.html.twig index ec4f18b2..b4e8977e 100644 --- a/templates/AdminPages/LabelProfileAdmin.html.twig +++ b/templates/AdminPages/LabelProfileAdmin.html.twig @@ -45,7 +45,7 @@ {% block additional_content %} {% if pdf_data is defined and pdf_data is not empty %}
- + {% endif %} diff --git a/templates/LabelSystem/dialog.html.twig b/templates/LabelSystem/dialog.html.twig index a093fc7d..a8dcedb5 100644 --- a/templates/LabelSystem/dialog.html.twig +++ b/templates/LabelSystem/dialog.html.twig @@ -58,7 +58,7 @@ {% block additional_content %} {% if pdf_data %}
- + {% endif %} diff --git a/templates/LabelSystem/labels/label_page_1d.html.twig b/templates/LabelSystem/labels/label_page_1d.html.twig index f8c856c1..ffdc8d5c 100644 --- a/templates/LabelSystem/labels/label_page_1d.html.twig +++ b/templates/LabelSystem/labels/label_page_1d.html.twig @@ -3,7 +3,7 @@ {{ element.lines | raw }}
- + {{ element.barcode_content }}
diff --git a/templates/LabelSystem/labels/label_page_qr.html.twig b/templates/LabelSystem/labels/label_page_qr.html.twig index a46a97e3..bc144b0b 100644 --- a/templates/LabelSystem/labels/label_page_qr.html.twig +++ b/templates/LabelSystem/labels/label_page_qr.html.twig @@ -3,7 +3,7 @@
{#{{ element.barcode | raw }} #}