Commit f727585399

f7275853993e4b01793bc9078f7a0a4865aaf334

parent: aa0739f782

Unsigned

cmc <hello@cleberg.net> · 2023-06-01 15:11 UTC

enhancement: add links to user profiles

Layout: unified · split

index.php +4 −2
@@ -138,11 +138,12 @@ function get_stories($api_url, $inline_title) {
138 $sub_response_raw = file_get_contents($sub_url); 138 $sub_response_raw = file_get_contents($sub_url);
139 $sub_response = json_decode($sub_response_raw, true); 139 $sub_response = json_decode($sub_response_raw, true);
140 140
141 // TODO: Can this be converted to a heredoc string with variables?
141 $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>'; 142 $html = '<div><a href="' . $sub_response['url'] . '">' . $sub_response['title'] . '</a>';
142 $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">'; 143 $html .= '<p><time datetime="' . date('Y-m-d h:m:s', $sub_response['time']) . '">';
143 $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a'; 144 $html .= date('Y-m-d h:m:s', $sub_response['time']) . '</time> by <a';
144 $html .= 'href="/user/'. $sub_response['by'] . '">'; 145 $html .= 'href="/user/'. $sub_response['by'] . '">';
145 $html .= $sub_response['by'] . ' | ' . $sub_response['score']; 146 $html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
146 $html .= ' points</p></div>'; 147 $html .= ' points</p></div>';
147 $html_output .= $html; 148 $html_output .= $html;
148 } 149 }
@@ -168,6 +169,7 @@ function get_user(string $api_url, string $inline_title) {
168 $response = json_decode($response_raw, true); 169 $response = json_decode($response_raw, true);
169 } 170 }
170 171
172 // TODO: Can this be converted to a heredoc string with variables?
171 $html_output = '<h1>' . $inline_title . '</h1>'; 173 $html_output = '<h1>' . $inline_title . '</h1>';
172 $html_output .= '<p>About: ' . $response['about'] . '</p>'; 174 $html_output .= '<p>About: ' . $response['about'] . '</p>';
173 $html_output .= '<p>Karma: ' . $response['karma'] . '</p>'; 175 $html_output .= '<p>Karma: ' . $response['karma'] . '</p>';
@@ -186,7 +188,7 @@ function get_user(string $api_url, string $inline_title) {
186 $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']) . '">';
187 $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';
188 $html .= 'href="/user/'. $sub_response['by'] . '">'; 190 $html .= 'href="/user/'. $sub_response['by'] . '">';
189 $html .= $sub_response['by'] . ' | ' . $sub_response['score']; 191 $html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
190 $html .= ' points</p></div>'; 192 $html .= ' points</p></div>';
191 $html_output .= $html; 193 $html_output .= $html;
192 } 194 }