Commit 4360165924

4360165924c490ca7738b73dcfd70919c760a839

parent: 410c478091

Unsigned

cmc <hello@cleberg.net> · 2023-06-06 02:22 UTC

enhancement: add support for user comments on profile page

Layout: unified · split

index.php +16 −7
@@ -183,13 +183,22 @@ function get_user(string $api_url, string $inline_title) {
183183 $sub_response_raw = file_get_contents($sub_url);
184184 $sub_response = json_decode($sub_response_raw, true);
185185
186 // TODO: Create switch-case to cover a story, comment, job, poll, or pollopt
187 $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>';
188 $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">';
189 $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a';
190 $html .= ' href="/user/'. $sub_response['by'] . '">';
191 $html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
192 $html .= ' points</p></div>';
186 if ($sub_response['type'] == 'story' || $sub_response['type'] == 'job') {
187 $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>';
188 $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">';
189 $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a';
190 $html .= ' href="/user/'. $sub_response['by'] . '">';
191 $html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
192 $html .= ' points</p></div>';
193 } elseif ($sub_response['type'] == 'poll') {
194 // TODO: Handle polls
195 $html = 'TODO: Add logic to handle polls here.';
196 } else {
197 // TODO: Add link to parent with $sub_response['parent']
198 $html = '<div><timedatetime="' . date('Y-m-d h:m:s', $sub_response['time']);
199 $html .= '">' . date('Y-m-d h:m:s', $sub_response['time']);
200 $html .= '</time><br><p>' . $sub_response['text']; $html .= '</p></div>';
201 }
193202 $html_output .= $html;
194203 }
195204 } else {