From 35033e50a6c99663af0823beee7ebe8211ec1cda Mon Sep 17 00:00:00 2001 From: Greg Sarjeant <1686767+gsarjeant@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:06:55 -0400 Subject: [PATCH] Add tick mood display. --- src/Controller/AdminController/AdminController.php | 2 +- src/Controller/HomeController/HomeController.php | 2 +- src/Model/ConfigModel/ConfigModel.php | 2 +- src/Model/TickModel/TickModel.php | 7 ++++--- src/View/HomeView/HomeView.php | 4 ++++ templates/partials/home.php | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Controller/AdminController/AdminController.php b/src/Controller/AdminController/AdminController.php index 0ed2182..9b38efd 100644 --- a/src/Controller/AdminController/AdminController.php +++ b/src/Controller/AdminController/AdminController.php @@ -65,7 +65,7 @@ class AdminController extends Controller { $basePath = trim($_POST['base_path'] ?? '/'); $itemsPerPage = (int) ($_POST['items_per_page'] ?? 25); $strictAccessibility = isset($_POST['strict_accessibility']); - $showTickMood = isset($_POST['strict_accessibility']); + $showTickMood = isset($_POST['show_tick_mood']); // Password $password = $_POST['password'] ?? ''; diff --git a/src/Controller/HomeController/HomeController.php b/src/Controller/HomeController/HomeController.php index 107a30f..0af4235 100644 --- a/src/Controller/HomeController/HomeController.php +++ b/src/Controller/HomeController/HomeController.php @@ -29,7 +29,7 @@ class HomeController extends Controller { if ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_POST['new_tick'])) { // save the tick if (trim($_POST['new_tick'])){ - TickModel::save($_POST['new_tick']); + TickModel::save($_POST['new_tick'], $_POST['tick_mood']); } } diff --git a/src/Model/ConfigModel/ConfigModel.php b/src/Model/ConfigModel/ConfigModel.php index c7fe667..8c86b11 100644 --- a/src/Model/ConfigModel/ConfigModel.php +++ b/src/Model/ConfigModel/ConfigModel.php @@ -72,7 +72,7 @@ class ConfigModel { strict_accessibility, show_tick_mood ) - VALUES (1, ?, ?, ?, ?, ?, ?)"); + VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?)"); } else { $stmt = $db->prepare("UPDATE settings SET site_title=?, diff --git a/src/Model/TickModel/TickModel.php b/src/Model/TickModel/TickModel.php index ab472a8..03a820d 100644 --- a/src/Model/TickModel/TickModel.php +++ b/src/Model/TickModel/TickModel.php @@ -34,13 +34,14 @@ class TickModel { // Ticks are pipe-delimited: timestamp|text // But just in case a tick contains a pipe, only split on the first one that occurs - list($time, $emoji, $tick) = explode('|', $line, 3); + list($time, $mood, $tick) = explode('|', $line, 3); // Build the timestamp from the date and time // Ticks are always stored in UTC $timestampUTC = "$year-$month-$day $time"; yield [ 'timestamp' => $timestampUTC, + 'mood' => $mood, 'tick' => $tick, ]; @@ -51,7 +52,7 @@ class TickModel { } } - public static function save(string $tick): void { + public static function save(string $tick, string $mood=''): void { // build the tick path and filename from the current time $now = new DateTime('now', new DateTimeZone('UTC')); @@ -70,7 +71,7 @@ class TickModel { } // write the tick to the file (the file will be created if it doesn't exist) - $content = $time . "|" . $tick . "\n"; + $content = $time . '|' . $mood . '|' . $tick . "\n"; file_put_contents($filename, $content, FILE_APPEND); } diff --git a/src/View/HomeView/HomeView.php b/src/View/HomeView/HomeView.php index 0b9056a..45444e7 100644 --- a/src/View/HomeView/HomeView.php +++ b/src/View/HomeView/HomeView.php @@ -1,6 +1,7 @@ @@ -12,6 +13,9 @@ class HomeView { ?>
  • + showTickMood): ?> + +
  • diff --git a/templates/partials/home.php b/templates/partials/home.php index 352bdbf..2647474 100644 --- a/templates/partials/home.php +++ b/templates/partials/home.php @@ -32,6 +32,7 @@
    +