uSked / mosaico-php-backend

A PHP backend for Mosaico
GNU General Public License v3.0
32 stars 34 forks source link

Integrate https://github.com/christiaan/InlineStyle #7

Closed bwl21 closed 8 years ago

bwl21 commented 8 years ago

Hi,

as I had trouble to get premailer working safely, I have integrated https://github.com/christiaan/InlineStyle. It seems to work properly with mosaico, but this needs to be verified.

It also solves the issues in https://github.com/ainterpreting/mosaico-php-backend/issues/6.

On the first hand I made it configurable, which inliner to be used.

I also updated Readme.md to make it a bit more clear for beginners (as I am ).

I furtheron ignore some generated files and folders.

mherbold commented 8 years ago

Awesome! I will look at this next week and integrate your changes with my main branch.

bwl21 commented 8 years ago

Marvin, I have trouble if the template or the content of the email contains UTF-8 characters such as umlauts (öäüß). see https://github.com/voidlabs/mosaico/issues/56. When I invoke downlaod and try to debug dl/index.php, the i can see that the $html variable is not in UTF-8. This makes InlineStyle fail.

Could you try if you have the same issue.

bago commented 8 years ago

PHP is not good at working with UTF-8.... In our proprietary code we have plenty of iconv conversions around, for example:

$encoding = $config->get("edit.encoding", "utf-8");
if ($encoding != "utf-8") $content = iconv($encoding, "utf-8", $content);

or, in our inliner we use Sabberworm parser, that have a lot of weird code to correctly parse non-ascii chars: https://github.com/sabberworm/PHP-CSS-Parser/blob/master/lib/Sabberworm/CSS/Parser.php#L221

What does it happen if you REMOVE the inliner? Do the php backend "break" the encoding when "alone" or you isolated the encoding issue in the inliner?

bwl21 commented 8 years ago

@bago: I agree, that PHP is not good at working with UTF-8. (To be honest: I consider PHP as really bad, but am very impressed that people manage to implement Typo3, Wordpress and Moodle with it).

Nevertheless:

bwl21 commented 8 years ago

I close this PR. It was not considered by ainterpreting and is now out of date.

NJseo commented 8 years ago

Well after integrating Mosaico, I too have come to the problems with Premailer. Was this a good solution to integrate this inliner, or do you recommend something else?

bwl21 commented 8 years ago

@NJseo

John, please have a look on https://github.com/ainterpreting/mosaico-php-backend/pull/13. The inliner works very well there.

But you need to ensure that the result of mosaico is wellformed xml. That means, that for example parameters in url - links are already encoded as entities.