From 4360165924c490ca7738b73dcfd70919c760a839 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 5 Jun 2023 21:22:34 -0500 Subject: enhancement: add support for user comments on profile page --- index.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index c1b628a..91266ec 100644 --- a/index.php +++ b/index.php @@ -183,13 +183,22 @@ function get_user(string $api_url, string $inline_title) { $sub_response_raw = file_get_contents($sub_url); $sub_response = json_decode($sub_response_raw, true); - // TODO: Create switch-case to cover a story, comment, job, poll, or pollopt - $html = '
' . $sub_response['title'] . ''; - $html .= '

by '; - $html .= $sub_response['by'] . ' | ' . $sub_response['score']; - $html .= ' points

'; + if ($sub_response['type'] == 'story' || $sub_response['type'] == 'job') { + $html = '
' . $sub_response['title'] . ''; + $html .= '

by '; + $html .= $sub_response['by'] . ' | ' . $sub_response['score']; + $html .= ' points

'; + } elseif ($sub_response['type'] == 'poll') { + // TODO: Handle polls + $html = 'TODO: Add logic to handle polls here.'; + } else { + // TODO: Add link to parent with $sub_response['parent'] + $html = '