From debe285cf5db3f5eb6d42aa45ae421dd9324532c Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Wed, 14 Dec 2022 22:50:55 +0100 Subject: [PATCH] Clean up interface --- composer.json | 2 +- composer.lock | Bin 77391 -> 77391 bytes package-lock.json | Bin 226174 -> 226174 bytes package.json | 2 +- src/main/css/main.css | 41 ++++----- src/main/index.html | 85 ++++++++++-------- src/main/js/Main.ts | 20 +++-- .../fwdekker/deathnotifier/mailer/Email.php | 4 +- .../deathnotifier/mailer/EmailQueue.php | 8 +- .../tracking/AddTrackingAction.php | 13 +-- .../tracking/UpdateTrackingsAction.php | 6 +- .../deathnotifier/user/ChangeEmailAction.php | 4 +- .../user/ChangePasswordAction.php | 2 +- .../deathnotifier/user/RegisterAction.php | 2 +- .../user/ResendVerifyEmailAction.php | 2 +- .../user/ResetPasswordAction.php | 2 +- .../user/SendPasswordResetAction.php | 2 +- .../deathnotifier/wikipedia/Wikipedia.php | 2 +- 18 files changed, 105 insertions(+), 92 deletions(-) diff --git a/composer.json b/composer.json index 2448ab4..5ce7476 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "fwdekker/death-notifier", "description": "Get notified when a famous person dies.", - "version": "0.19.4", "_comment_version": "Also update version in `package.json`!", + "version": "0.19.5", "_comment_version": "Also update version in `package.json`!", "type": "project", "license": "MIT", "homepage": "https://git.fwdekker.com/tools/death-notifier", diff --git a/composer.lock b/composer.lock index c8b8fccc2addc50103edbb0f1846db40268a0cc6..fcc8499780ec8322f3a46db6c69bc2a94b7e0439 100644 GIT binary patch delta 449 zcma)%yGjE=7=;-Pq>;^vkTy{e(**XP+s-Vaq_VOI1RIUGbL&LAfFjsw?Jq>I@D&o) zI$~=R(KZl#10TWl4ffRM<9uhnsLdC($p&dtMFRuyAy4x}SeE2m3oy#2)CfFz?TgYkPr7{*SmP#8mljPUb(9lzXmhXtjX2c5#dy;a64 zDWz~AB=tHtk!Z_(NHA|*P1^SRR{V9LyWOqyoQH*sfj;t%LvL7d;lz? ZG7}u9qdok1j4dgZz;Gs$REwBO4@@$xV&$DtOd2CnuxohydQ?36w^sGC>X-*mHKcPQS8a_q=`n_P>ZIhMa
-
+
- +
- +
@@ -241,7 +241,11 @@ - + + + + +
@@ -272,39 +276,48 @@ -
- +
+ + - - + + - - -
- + +
+
+ - - -
+ + + + +

Password

-
Last changed: ...
+ Last changed: + +

+ @@ -351,20 +364,20 @@
-

Delete account

-

- If you no longer want to use Death Notifier, you can permanently delete your account. - This choice is permanent and cannot be reverted. -

-
- +

Delete account

+

+ If you no longer want to use Death Notifier, you can permanently delete your account. + This choice is permanent and cannot be reverted. +

+ + - - -
+ + +
diff --git a/src/main/js/Main.ts b/src/main/js/Main.ts index 45913d8..bccc180 100644 --- a/src/main/js/Main.ts +++ b/src/main/js/Main.ts @@ -1,7 +1,8 @@ // @ts-ignore const {$, $a, doAfterLoad} = window.fwdekker; const { - clearFormValidity, clearMessageStatus, showMessageInfo, showMessageError, showMessageSuccess, showMessageWarning + clearFormValidity, clearMessageStatus, showInputValid, showMessageInfo, showMessageError, showMessageSuccess, + showMessageWarning // @ts-ignore } = window.fwdekker.validation; @@ -150,20 +151,24 @@ function refreshUserData(): void { // Email $("#update-email-email").value = userData.email; $("#email-verified-checkbox").checked = userData.email_verified; - if (!userData.email_verified) + if (!userData.email_verified) { showMessageWarning( sharedMessageElement, "You will not receive any email notifications until you verify your email address. " + "Check your inbox for further instructions." ); - else + } else { clearMessageStatus(sharedMessageElement); + } $("#resend-email-verification-submit").classList.toggle("hidden", userData.email_verified); // Notifications const notificationsCheckbox = $("#notifications-enabled-checkbox"); notificationsCheckbox.disabled = !userData.email_verified; notificationsCheckbox.checked = userData.email_verified && userData.email_notifications_enabled; + if (!userData.email_verified) + $("#notifications-enabled-checkbox-hint").innerText = + "You cannot enable notifications until you verify your email address."; // Password update time const today = new Date(); @@ -504,13 +509,14 @@ doAfterLoad(() => { refreshUserData(); if (enableNotifications) - showMessageSuccess(toggleNotificationsForm, "Notifications have been enabled."); + showInputValid($("#notifications-enabled-checkbox"), "Notifications have been enabled."); else - showMessageSuccess( - toggleNotificationsForm, + showInputValid( + $("#notifications-enabled-checkbox"), "Notifications have been disabled. " + "You will still receive security notifications, for example if you change your email address " + - "or password."); + "or password." + ); } ); }); diff --git a/src/main/php/com/fwdekker/deathnotifier/mailer/Email.php b/src/main/php/com/fwdekker/deathnotifier/mailer/Email.php index d012f50..d9b4da0 100644 --- a/src/main/php/com/fwdekker/deathnotifier/mailer/Email.php +++ b/src/main/php/com/fwdekker/deathnotifier/mailer/Email.php @@ -18,7 +18,7 @@ abstract class Email */ public readonly string $type_key; /** - * @var string the intended recipient of the email + * @var string the intended recipient of this email */ public readonly string $recipient; @@ -27,7 +27,7 @@ abstract class Email * Constructs a new `Email`. * * @param string $type_key the identifier of this email - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email */ public function __construct(string $type_key, string $recipient) { diff --git a/src/main/php/com/fwdekker/deathnotifier/mailer/EmailQueue.php b/src/main/php/com/fwdekker/deathnotifier/mailer/EmailQueue.php index 4492b3d..85d56a9 100644 --- a/src/main/php/com/fwdekker/deathnotifier/mailer/EmailQueue.php +++ b/src/main/php/com/fwdekker/deathnotifier/mailer/EmailQueue.php @@ -36,8 +36,8 @@ class EmailQueue public function install(): void { $conn = $this->database->conn; - $conn->exec("CREATE TABLE email_tasks(recipient TEXT NOT NULL, - type_key TEXT NOT NULL, + $conn->exec("CREATE TABLE email_tasks(type_key TEXT NOT NULL, + recipient TEXT NOT NULL, subject TEXT NOT NULL, body TEXT NOT NULL, PRIMARY KEY (type_key, recipient));"); @@ -68,8 +68,8 @@ class EmailQueue */ public function queue_emails(array $emails): void { - $stmt = $this->database->conn->prepare("INSERT OR REPLACE INTO email_tasks (recipient, type_key, subject, body) - VALUES (:recipient, :type_key, :subject, :body);"); + $stmt = $this->database->conn->prepare("INSERT OR REPLACE INTO email_tasks (type_key, recipient, subject, body) + VALUES (:type_key, :recipient, :subject, :body);"); $stmt->bindParam(":recipient", $recipient); $stmt->bindParam(":type_key", $type_key); $stmt->bindParam(":subject", $subject); diff --git a/src/main/php/com/fwdekker/deathnotifier/tracking/AddTrackingAction.php b/src/main/php/com/fwdekker/deathnotifier/tracking/AddTrackingAction.php index d905886..38b6133 100644 --- a/src/main/php/com/fwdekker/deathnotifier/tracking/AddTrackingAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/tracking/AddTrackingAction.php @@ -97,8 +97,6 @@ class AddTrackingAction extends Action $info = $this->wikipedia->query_person_info([$person_name]); $normalized_name = $info->redirects[$person_name]; - $type = $info->results[$normalized_name]["type"]; - $status = $info->results[$normalized_name]["status"]; } catch (WikipediaException $exception) { throw new UnexpectedException( "Could not reach Wikipedia. Maybe the website is down?", @@ -115,7 +113,11 @@ class AddTrackingAction extends Action "Maybe you need to capitalise the surname?", "person_name" ); - } else if ($type === ArticleType::Disambiguation) { + } + + $type = $info->results[$normalized_name]["type"]; + $status = $info->results[$normalized_name]["status"]; + if ($type === ArticleType::Disambiguation) { throw new InvalidValueException( $this->override_message ?? "" . @@ -132,10 +134,9 @@ class AddTrackingAction extends Action htmlentities($normalized_name) . " is not about a real-world person.", "person_name" ); - } - - if ($status === null) + } else if ($status === null) { throw new IllegalStateError("Person page does not have a status."); + } return [$normalized_name, $status]; } diff --git a/src/main/php/com/fwdekker/deathnotifier/tracking/UpdateTrackingsAction.php b/src/main/php/com/fwdekker/deathnotifier/tracking/UpdateTrackingsAction.php index 5c3fac4..e9be73c 100644 --- a/src/main/php/com/fwdekker/deathnotifier/tracking/UpdateTrackingsAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/tracking/UpdateTrackingsAction.php @@ -163,7 +163,7 @@ class NotifyStatusChangedEmail extends Email /** * Constructs a new `NotifyStatusChangedEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $name the name of the person who died * @param string $new_status the new status of the person */ @@ -219,7 +219,7 @@ class NotifyArticleDeletedEmail extends Email /** * Constructs a new `NotifyArticleDeletedEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $name the name of the article that was deleted */ public function __construct(string $recipient, string $name) @@ -274,7 +274,7 @@ class NotifyArticleUndeletedEmail extends Email /** * Constructs a new `NotifyArticleUndeletedEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $name the name of the article that was re-created */ public function __construct(string $recipient, string $name) diff --git a/src/main/php/com/fwdekker/deathnotifier/user/ChangeEmailAction.php b/src/main/php/com/fwdekker/deathnotifier/user/ChangeEmailAction.php index 65b433e..16001ff 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/ChangeEmailAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/ChangeEmailAction.php @@ -112,7 +112,7 @@ class ChangeEmailFromEmail extends Email /** * Constructs a new `ChangeEmailFromEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $new_email the new email address */ public function __construct(string $recipient, string $new_email) @@ -170,7 +170,7 @@ class ChangeEmailToEmail extends Email /** * Constructs a new `ChangeEmailEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $old_email the old email address * @param string $token the token to verify the email address with */ diff --git a/src/main/php/com/fwdekker/deathnotifier/user/ChangePasswordAction.php b/src/main/php/com/fwdekker/deathnotifier/user/ChangePasswordAction.php index 8d712d1..a4d1e24 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/ChangePasswordAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/ChangePasswordAction.php @@ -101,7 +101,7 @@ class ChangePasswordEmail extends Email /** * Constructs a new `ChangedPasswordEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email */ public function __construct(string $recipient) { diff --git a/src/main/php/com/fwdekker/deathnotifier/user/RegisterAction.php b/src/main/php/com/fwdekker/deathnotifier/user/RegisterAction.php index 68a7f81..79593a6 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/RegisterAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/RegisterAction.php @@ -100,7 +100,7 @@ class RegisterEmail extends Email /** * Constructs a new `RegisterEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $token the token to verify the email address with */ public function __construct(string $recipient, string $token) diff --git a/src/main/php/com/fwdekker/deathnotifier/user/ResendVerifyEmailAction.php b/src/main/php/com/fwdekker/deathnotifier/user/ResendVerifyEmailAction.php index 742aa1c..f58e79e 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/ResendVerifyEmailAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/ResendVerifyEmailAction.php @@ -111,7 +111,7 @@ class ResendVerifyEmailEmail extends Email /** * Constructs a new `ResendVerifyEmailEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $token the token to verify the email address with */ public function __construct(string $recipient, string $token) diff --git a/src/main/php/com/fwdekker/deathnotifier/user/ResetPasswordAction.php b/src/main/php/com/fwdekker/deathnotifier/user/ResetPasswordAction.php index bb0db9f..1e97b86 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/ResetPasswordAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/ResetPasswordAction.php @@ -105,7 +105,7 @@ class ResetPasswordEmail extends Email /** * Constructs a new `ChangedPasswordEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email */ public function __construct(string $recipient) { diff --git a/src/main/php/com/fwdekker/deathnotifier/user/SendPasswordResetAction.php b/src/main/php/com/fwdekker/deathnotifier/user/SendPasswordResetAction.php index b2a453f..98b0a79 100644 --- a/src/main/php/com/fwdekker/deathnotifier/user/SendPasswordResetAction.php +++ b/src/main/php/com/fwdekker/deathnotifier/user/SendPasswordResetAction.php @@ -109,7 +109,7 @@ class SendPasswordResetEmail extends Email /** * Constructs a new `ResetPasswordEmail`. * - * @param string $recipient the intended recipient of the email + * @param string $recipient the intended recipient of this email * @param string $token the token to reset the password with */ public function __construct(string $recipient, string $token) diff --git a/src/main/php/com/fwdekker/deathnotifier/wikipedia/Wikipedia.php b/src/main/php/com/fwdekker/deathnotifier/wikipedia/Wikipedia.php index 24bdf8b..07de1ca 100644 --- a/src/main/php/com/fwdekker/deathnotifier/wikipedia/Wikipedia.php +++ b/src/main/php/com/fwdekker/deathnotifier/wikipedia/Wikipedia.php @@ -202,7 +202,7 @@ class Wikipedia foreach ($output_base->missing as $missing_title) { $title_after_move = $this->api_query_title_after_move($missing_title); if ($title_after_move === null) - $not_moved[] = $title_after_move; + $not_moved[] = $missing_title; else $moves[$missing_title] = $title_after_move; }