krz/hn

A brutalist web client for Hacker News.

clone: git clone https://gitbay.org/krz/hn.git

f7275853993e4b01793bc9078f7a0a4865aaf334

unsigned

author: Christian Cleberg <hello@cleberg.net> · 2023-06-01T15:11:12Z

enhancement: add links to user profiles
 index.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/index.php b/index.php
index a45b5ae..56553a2 100644
--- a/index.php
+++ b/index.php
@@ -138,11 +138,12 @@ function get_stories($api_url, $inline_title) {
 		$sub_response_raw = file_get_contents($sub_url);
 		$sub_response = json_decode($sub_response_raw, true);
 
+		// TODO: Can this be converted to a heredoc string with variables?
 		$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'] . ' | ' . $sub_response['score'];
+		$html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
 		$html .= ' points</p></div>';
 		$html_output .= $html;
 	}
@@ -168,6 +169,7 @@ function get_user(string $api_url, string $inline_title) {
 		$response = json_decode($response_raw, true);
 	}
 
+	// TODO: Can this be converted to a heredoc string with variables?
 	$html_output = '<h1>' . $inline_title . '</h1>';
 	$html_output .= '<p>About: ' . $response['about']  . '</p>';
 	$html_output .= '<p>Karma: ' . $response['karma']  . '</p>';
@@ -186,7 +188,7 @@ function get_user(string $api_url, string $inline_title) {
 			$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'] . ' | ' . $sub_response['score'];
+			$html .= $sub_response['by'] . '</a> | ' . $sub_response['score'];
 			$html .= ' points</p></div>';
 			$html_output .= $html;
 		}