From dba330bcb3b881308313a34ca4911ebb527b1b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 13 Apr 2021 16:43:35 +0200 Subject: [PATCH] wip --- .../Designs/Utilities/DesignHelpers.php | 10 + app/Utils/TemplateEngine.php | 18 +- composer.json | 1 + composer.lock | 159 +------- .../views/email/template/master.blade.php | 353 +++++++++++++----- 5 files changed, 291 insertions(+), 250 deletions(-) diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 3081a0c5595a..9f9e2e9033ed 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -16,6 +16,7 @@ use App\Utils\Traits\MakesHash; use DOMDocument; use DOMXPath; use Exception; +use League\CommonMark\CommonMarkConverter; trait DesignHelpers { @@ -308,4 +309,13 @@ trait DesignHelpers $this->client ); } + + public static function parseMarkdownToHtml(string $markdown): ?string + { + $converter = new CommonMarkConverter([ + 'allow_unsafe_links' => false, + ]); + + return $converter->convertToHtml($markdown); + } } diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index fb9b863e0949..31637e83853a 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -16,11 +16,13 @@ use App\Models\Client; use App\Models\ClientContact; use App\Models\Invoice; use App\Models\InvoiceInvitation; +use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesInvoiceHtml; use App\Utils\Traits\MakesTemplateData; use DB; use League\CommonMark\CommonMarkConverter; +use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles; class TemplateEngine { @@ -162,17 +164,12 @@ class TemplateEngine $this->body = strtr($this->body, $data['labels']); $this->body = strtr($this->body, $data['values']); - $this->body = str_replace("\n", "
", $this->body); - +// $this->body = str_replace("\n", "
", $this->body); $this->subject = strtr($this->subject, $data['labels']); $this->subject = strtr($this->subject, $data['values']); - $converter = new CommonMarkConverter([ - 'allow_unsafe_links' => false, - ]); - - $this->body = $converter->convertToHtml($this->body); + $this->body = DesignHelpers::parseMarkdownToHtml($this->body); } private function renderTemplate() @@ -256,4 +253,11 @@ class TemplateEngine { DB::rollBack(); } + + private static function inlineMarkupCss(string $css, string $html): ?string + { + $inliner = new CssToInlineStyles(); + + return $inliner->convert($html, $css); + } } diff --git a/composer.json b/composer.json index 29da3c0fb585..12254fd48628 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "sentry/sentry-laravel": "^2", "stripe/stripe-php": "^7.50", "symfony/http-client": "^5.2", + "tijsverkoyen/css-to-inline-styles": "^2.2", "turbo124/beacon": "^1.0", "turbo124/laravel-gmail": "^5", "webpatser/laravel-countries": "dev-master#75992ad", diff --git a/composer.lock b/composer.lock index 27906d3c6663..25bd1c789eee 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": "7ccb8d2434343dfb0ba62866f0ee919a", + "content-hash": "f01381d3d00f0bd84acbda078ad1b99e", "packages": [ { "name": "authorizenet/authorizenet", @@ -11718,103 +11718,6 @@ ], "time": "2021-01-25T15:34:13+00:00" }, - { - "name": "nunomaduro/larastan", - "version": "v0.7.3", - "source": { - "type": "git", - "url": "https://github.com/nunomaduro/larastan.git", - "reference": "9c515d46851dca5a99fc82c0a69392c362b7affd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/9c515d46851dca5a99fc82c0a69392c362b7affd", - "reference": "9c515d46851dca5a99fc82c0a69392c362b7affd", - "shasum": "" - }, - "require": { - "composer/composer": "^1.0 || ^2.0", - "ext-json": "*", - "illuminate/console": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/container": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/contracts": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/database": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/http": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/pipeline": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "mockery/mockery": "^0.9 || ^1.0", - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^0.12.83", - "symfony/process": "^4.3 || ^5.0" - }, - "require-dev": { - "orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0", - "phpunit/phpunit": "^7.3 || ^8.2 || ^9.3" - }, - "suggest": { - "orchestra/testbench": "^4.0 || ^5.0" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.6-dev" - }, - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "NunoMaduro\\Larastan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel", - "keywords": [ - "PHPStan", - "code analyse", - "code analysis", - "larastan", - "laravel", - "package", - "php", - "static analysis" - ], - "support": { - "issues": "https://github.com/nunomaduro/larastan/issues", - "source": "https://github.com/nunomaduro/larastan/tree/v0.7.3" - }, - "funding": [ - { - "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", - "type": "custom" - }, - { - "url": "https://github.com/canvural", - "type": "github" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], - "time": "2021-04-12T11:01:46+00:00" - }, { "name": "openlss/lib-array2xml", "version": "1.0.0", @@ -12259,66 +12162,6 @@ }, "time": "2021-03-17T13:42:18+00:00" }, - { - "name": "phpstan/phpstan", - "version": "0.12.83", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "4a967cec6efb46b500dd6d768657336a3ffe699f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a967cec6efb46b500dd6d768657336a3ffe699f", - "reference": "4a967cec6efb46b500dd6d768657336a3ffe699f", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.83" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "time": "2021-04-03T15:35:45+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "9.2.6", diff --git a/resources/views/email/template/master.blade.php b/resources/views/email/template/master.blade.php index c9cfad3a08cb..05304d60fe0c 100644 --- a/resources/views/email/template/master.blade.php +++ b/resources/views/email/template/master.blade.php @@ -2,113 +2,296 @@ if(!isset($design)) { $design = 'light'; } + $primary_color = isset($settings) ? $settings->primary_color : '#4caf50'; @endphp - - - + + - - + + + + + + + - + + + + +
+ {{ $header }} +
- - - - - - - @isset($whitelabel) - @if(!$whitelabel) - - @endif - @endif - -
- - - - - - - -
- {{ $header }} -
- - - + + +
- @yield('greeting') +
+ + + + + + + + + + + + +
+
+
+ + + +
+
+
{{ $slot }} - @yield('signature') - @yield('footer') -
-
-

- - Invoice Ninja - -

-
+{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{-- Visit portal--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} + +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{--

If you can't click on button copy following link: https://invoiceninja.com/example-url-to-copy

--}} +{{--
--}} + +{{--
--}} + + + + + + + + +
+ + + + + + + +
+   +
+ +
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + + + + + + + + + + + + + +