From c384c7369a962ccf8667434cba39ea7532b7687b Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Wed, 18 Aug 2021 21:35:04 +0200 Subject: [PATCH] Switch to new dated email format --- content/legal/default.de.txt | 2 +- content/legal/default.en.txt | 2 +- site/controllers/contact.php | 2 +- site/languages/de.php | 2 -- site/languages/en.php | 2 -- site/plugins/qdated.php | 49 +++++++++++++++++++---------- site/snippets/templates/contact.php | 2 +- 7 files changed, 37 insertions(+), 24 deletions(-) diff --git a/content/legal/default.de.txt b/content/legal/default.de.txt index 9da722b..268cdec 100644 --- a/content/legal/default.de.txt +++ b/content/legal/default.de.txt @@ -23,7 +23,7 @@ USt-IdNr.: DE 300 983 590

Kontakt

-(qdated:) +(dated:) Diese E-Mail-Adresse ist eine Woche lang gültig und verfällt anschließend. E-Mails an diese Adresse erreichen mich persönlich und werden schnellstmöglich beantwortet. Mit der Antwort erhältst du meine dauerhaft gültige E-Mail-Adresse. Durch dieses Verfahren wird die E-Mail-Adresse vor automatisiertem Spam geschützt. Vielen Dank für dein Verständnis. diff --git a/content/legal/default.en.txt b/content/legal/default.en.txt index 67f9746..33afd14 100644 --- a/content/legal/default.en.txt +++ b/content/legal/default.en.txt @@ -21,7 +21,7 @@ USt-IdNr.: DE 300 983 590

Contact

-(qdated:) +(dated:) This email address is valid for one week, after which it expires. Emails to this address are received by me personally and are responded to as fast as possible. Together with my reply, you will get my permanently valid email address. This process protects the email address against automated spam. Thank you for your understanding. diff --git a/site/controllers/contact.php b/site/controllers/contact.php index be0f585..2f44d21 100644 --- a/site/controllers/contact.php +++ b/site/controllers/contact.php @@ -20,7 +20,7 @@ return function($site, $pages, $page) { if(r::is('POST')) { $form->emailAction([ - 'to' => qdated(), + 'to' => dated(), 'from' => 'codesignd form ', 'subject' => 'Message from the contact form (' . $site->title() . ')', 'snippet' => 'email-templates/contact' diff --git a/site/languages/de.php b/site/languages/de.php index 9c14b87..01a2a8f 100644 --- a/site/languages/de.php +++ b/site/languages/de.php @@ -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 Twitter und mache mich darauf aufmerksam. Danke!'); diff --git a/site/languages/en.php b/site/languages/en.php index 74d8be8..933e809 100644 --- a/site/languages/en.php +++ b/site/languages/en.php @@ -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 Twitter and tell me about this. Thank you!'); diff --git a/site/plugins/qdated.php b/site/plugins/qdated.php index 30b3a68..fb3f155 100644 --- a/site/plugins/qdated.php +++ b/site/plugins/qdated.php @@ -1,42 +1,59 @@ ' . l::get('qdated.error') . '

'; +function datedHtml($text = false) { + $email = dated(); if($text === true) $text = str_replace('@', '
@', $email); return str::email($email, $text); } /** - * qdated Kirbytag + * 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 + */ +function modifiedJulianDate(?int $timestamp = null): int { + $timestamp = $timestamp ?? time(); + + return gregoriantojd( + date('m', $timestamp), + date('d', $timestamp), + date('Y', $timestamp) + ) - 2400001; +} + +/** + * dated Kirbytag * - * Usage: (qdated: Optional link text) + * Usage: (dated: Optional link text) */ -kirby()->set('tag', 'qdated', [ +kirby()->set('tag', 'dated', [ 'html' => function($tag) { - return qdatedHtml($tag->attr('qdated')); + return datedHtml($tag->attr('dated')); } ]); diff --git a/site/snippets/templates/contact.php b/site/snippets/templates/contact.php index 5c5161c..bffa003 100644 --- a/site/snippets/templates/contact.php +++ b/site/snippets/templates/contact.php @@ -40,7 +40,7 @@