Switch to new dated email format
This commit is contained in:
@@ -20,7 +20,7 @@ return function($site, $pages, $page) {
|
||||
|
||||
if(r::is('POST')) {
|
||||
$form->emailAction([
|
||||
'to' => qdated(),
|
||||
'to' => dated(),
|
||||
'from' => 'codesignd form <no-reply@codesignd.de>',
|
||||
'subject' => 'Message from the contact form (' . $site->title() . ')',
|
||||
'snippet' => 'email-templates/contact'
|
||||
|
||||
@@ -23,5 +23,3 @@ l::set('contact.heading.email', 'E-Mail');
|
||||
l::set('contact.message.name-invalid', 'Bitte gebe deinen Namen ein.');
|
||||
l::set('contact.message.email-invalid', 'Bitte gebe eine gültige E-Mail-Adresse ein.');
|
||||
l::set('contact.message.success', 'Danke für deine Nachricht, ich melde mich bald bei dir.');
|
||||
|
||||
l::set('qdated.error', 'Bei der Anzeige der E-Mail-Adresse ist ein Fehler aufgetreten. Bitte kontaktiere mich über <a href="https://twitter.com/lukasbestle">Twitter</a> und mache mich darauf aufmerksam. Danke!');
|
||||
|
||||
@@ -23,5 +23,3 @@ l::set('contact.heading.email', 'Email');
|
||||
l::set('contact.message.name-invalid', 'Please enter your name.');
|
||||
l::set('contact.message.email-invalid', 'Please enter a valid email address.');
|
||||
l::set('contact.message.success', 'Thank you for your message, I will get back to you soon.');
|
||||
|
||||
l::set('qdated.error', 'An error occured while displaying the email address. Please contact me via <a href="https://twitter.com/lukasbestle">Twitter</a> and tell me about this. Thank you!');
|
||||
|
||||
+34
-17
@@ -1,42 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns the current qdated address
|
||||
* If qdated is not available, returns null
|
||||
* Returns the current dated address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function qdated() {
|
||||
$path = $_SERVER['HOME'] . '/.config/qdated/cddmail2/current';
|
||||
if(!is_file($path)) return null;
|
||||
|
||||
return 'dated-' . trim(f::read($path)) . '@' . url::host();
|
||||
function dated(): string {
|
||||
// date in seven days
|
||||
$date = modifiedJulianDate(time() + 7 * 24 * 60 * 60);
|
||||
|
||||
return 'dated-' . $date . '@' . url::host();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an HTML a mailto tag with the current qdated address
|
||||
* If qdated is not available, returns an HTML error message
|
||||
* Returns an HTML a mailto tag with the current dated address
|
||||
* If dated is not available, returns an HTML error message
|
||||
*
|
||||
* @param mixed $text Optional text for the link
|
||||
* Can also be true to use the email
|
||||
* address but put a line break in it
|
||||
* @return string HTML code
|
||||
*/
|
||||
function qdatedHtml($text = false) {
|
||||
$email = qdated();
|
||||
if(!$email) return '<p><strong>' . l::get('qdated.error') . '</strong></p>';
|
||||
function datedHtml($text = false) {
|
||||
$email = dated();
|
||||
|
||||
if($text === true) $text = str_replace('@', '<br>@', $email);
|
||||
return str::email($email, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* qdated Kirbytag
|
||||
*
|
||||
* Usage: (qdated: Optional link text)
|
||||
* Returns the Modified Julian Date,
|
||||
* which is the Julian Date with the first two digits stripped
|
||||
* and with an offset of one day to compensate for the Julian Date
|
||||
* starting at noon instead of at midnight
|
||||
*
|
||||
* @param int $timestamp Timestamp to calculate from, defaults to the current date
|
||||
* @return int
|
||||
*/
|
||||
kirby()->set('tag', 'qdated', [
|
||||
function modifiedJulianDate(?int $timestamp = null): int {
|
||||
$timestamp = $timestamp ?? time();
|
||||
|
||||
return gregoriantojd(
|
||||
date('m', $timestamp),
|
||||
date('d', $timestamp),
|
||||
date('Y', $timestamp)
|
||||
) - 2400001;
|
||||
}
|
||||
|
||||
/**
|
||||
* dated Kirbytag
|
||||
*
|
||||
* Usage: (dated: Optional link text)
|
||||
*/
|
||||
kirby()->set('tag', 'dated', [
|
||||
'html' => function($tag) {
|
||||
return qdatedHtml($tag->attr('qdated'));
|
||||
return datedHtml($tag->attr('dated'));
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<aside class="contact__sidebar">
|
||||
<div class="contact__detail">
|
||||
<h2 class="contact__heading"><?= l::get('contact.heading.email', 'Email') ?></h2>
|
||||
<div class="contact__email"><?= qdatedHtml(true) ?> <a href="<?= url('legal') ?>#contact">?</a></div>
|
||||
<div class="contact__email"><?= datedHtml(true) ?> <a href="<?= url('legal') ?>#contact">?</a></div>
|
||||
<small><a href="<?= url('pgp.asc') ?>" rel="pgpkey" type="application/pgp-keys">PGP: 2E2A DD32 FE50 61C1</a></small>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user