Commit 4360165924
Unsigned
Layout: unified · split
index.php +16 −7
| @@ -183,13 +183,22 @@ function get_user(string $api_url, string $inline_title) { | |||
| 183 | $sub_response_raw = file_get_contents($sub_url); | 183 | $sub_response_raw = file_get_contents($sub_url); |
| 184 | $sub_response = json_decode($sub_response_raw, true); | 184 | $sub_response = json_decode($sub_response_raw, true); |
| 185 | 185 | ||
| 186 | // TODO: Create switch-case to cover a story, comment, job, poll, or pollopt | 186 | if ($sub_response['type'] == 'story' || $sub_response['type'] == 'job') { |
| 187 | $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>'; | 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']) . '">'; | 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'; | 189 | $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a'; |
| 190 | $html .= ' href="/user/'. $sub_response['by'] . '">'; | 190 | $html .= ' href="/user/'. $sub_response['by'] . '">'; |
| 191 | $html .= $sub_response['by'] . '</a> | ' . $sub_response['score']; | 191 | $html .= $sub_response['by'] . '</a> | ' . $sub_response['score']; |
| 192 | $html .= ' points</p></div>'; | 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 | } | ||
| 193 | $html_output .= $html; | 202 | $html_output .= $html; |
| 194 | } | 203 | } |
| 195 | } else { | 204 | } else { |