GithubHelp home page GithubHelp logo

Ugly text/plain part about webtrees-reminder HOT 10 OPEN

uksusoff avatar uksusoff commented on June 30, 2024
Ugly text/plain part

from webtrees-reminder.

Comments (10)

UksusoFF avatar UksusoFF commented on June 30, 2024

I didn't think anyone else was using plain text in emails.
Will check it but not now.

Also pull request welcome :)

from webtrees-reminder.

slavkoja avatar slavkoja commented on June 30, 2024

Anyone, who cares about own privacy uses plain text at least as default or even disables HTML at all...

I tried two html2text libraries https://github.com/mtibben/html2text and https://github.com/soundasleep/html2text both are able to create plain text results from your HTML like mails, with slightly better results in first library but at cost of XML dependency. Using these libraries will allow to use real HTML, for more compatibility with different clients...

from webtrees-reminder.

slavkoja avatar slavkoja commented on June 30, 2024

I am able to get desired output with this:

<?php
/** @var string $subject */
/** @var \Illuminate\Support\Collection $items */
/** @var \Fisharebest\Webtrees\Fact $fact */

echo "<h2>$subject</h2>\n\n";

foreach ($items as $group => $facts) :
    echo "<h3>$group</h3>\n";
    echo "<ul>\n";
    foreach ($facts as $fact) :
        $record = $fact->record();
        echo "  <li>" . $fact->label() . ': ';
        echo '<a href="' . e($record->url()) . '" style="text-decoration:none;">' . strip_tags($record->fullName()) . "</a> ";

        $year = $fact->date()->display(false, '%Y');
        if (!empty($year))
            echo "(" . strip_tags($year) . " / " . strip_tags($fact->anniv) . ")";
        echo "</li>\n";
    endforeach;
    echo "</ul><hr />\n";
endforeach;

// signature
echo '<p style="color:#444;">-- <br />'."\n";
echo "webtres</p>";

Notice, i changed the HTML slightly, i use unordered list of group's facts (ul), h2/h3 tags for titles and some styles are added. With this i got plain text:

4 apríla

  Narodenie: Name Hidden (1962 / 59)

At end i add signature placeholder. IMO, here have to be info about unsubscribe, or at least link to webtrees, but i do not know how to get this URL.

I will suggest to add List-ID and List-Unsibscribe headers too, but i will create separate issue for this latter.

from webtrees-reminder.

UksusoFF avatar UksusoFF commented on June 30, 2024

List-ID and List-Unsibscribe is webtrees issue. Modules can't attach this headers.

from webtrees-reminder.

slavkoja avatar slavkoja commented on June 30, 2024

Not really ;-) only its send method is not suitable for purpose of this module. Because its transport method (thus mail settings) is reusable, it seems to be simple to implement...

I will try it latter as i recently did little play with SwitMailer, but my PHP knowledge are (very) limited (e.g. no OOP), it will need to be polished...

from webtrees-reminder.

UksusoFF avatar UksusoFF commented on June 30, 2024

@slavkoja try latest master version. Seems plain text message looks fine now.

from webtrees-reminder.

slavkoja avatar slavkoja commented on June 30, 2024

I will try soon.

But are you sure, that it is better to fix ugly HTML by calling four functions (including expensive regexp) instead of fixing HTML and stay on one function call?

from webtrees-reminder.

UksusoFF avatar UksusoFF commented on June 30, 2024

No ;)

from webtrees-reminder.

slavkoja avatar slavkoja commented on June 30, 2024

Do you want to help with HTML?

from webtrees-reminder.

UksusoFF avatar UksusoFF commented on June 30, 2024

You can use own html if you wish. For me prefer more readable variant without closing tags far away from opened :)

from webtrees-reminder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.