diff options
author | Christian Cleberg <hello@cleberg.net> | 2023-06-05 21:22:34 -0500 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2023-06-05 21:22:34 -0500 |
commit | 4360165924c490ca7738b73dcfd70919c760a839 (patch) | |
tree | f4e31f4aef4291b0fb824487cfc469092a720dc5 | |
parent | 410c478091562b8b05ab0226931c196d94dcc712 (diff) | |
download | hn-4360165924c490ca7738b73dcfd70919c760a839.tar.gz hn-4360165924c490ca7738b73dcfd70919c760a839.tar.bz2 hn-4360165924c490ca7738b73dcfd70919c760a839.zip |
enhancement: add support for user comments on profile page
-rw-r--r-- | index.php | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -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 = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>'; - $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">'; - $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a'; - $html .= ' href="/user/'. $sub_response['by'] . '">'; - $html .= $sub_response['by'] . '</a> | ' . $sub_response['score']; - $html .= ' points</p></div>'; + if ($sub_response['type'] == 'story' || $sub_response['type'] == 'job') { + $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>'; + $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">'; + $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a'; + $html .= ' href="/user/'. $sub_response['by'] . '">'; + $html .= $sub_response['by'] . '</a> | ' . $sub_response['score']; + $html .= ' points</p></div>'; + } 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 = '<div><timedatetime="' . date('Y-m-d h:m:s', $sub_response['time']); + $html .= '">' . date('Y-m-d h:m:s', $sub_response['time']); + $html .= '</time><br><p>' . $sub_response['text']; $html .= '</p></div>'; + } $html_output .= $html; } } else { |