From 12863dd293b84ef2d7f74120623d55e6254b7d5b Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 28 Nov 2023 11:29:45 +0100 Subject: add title and head --- index.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.php b/index.php index 069e1bc..20a663c 100644 --- a/index.php +++ b/index.php @@ -15,6 +15,8 @@ $url['query'] ??= ''; $client = new Client($geminiHost); $response = $client->request("$url[path]$url[query]"); +$title = ''; + if ($response->getStatusCode()->value == 20) { ob_start(); $mime = explode(';', $response->getMeta())[0]; @@ -45,6 +47,10 @@ if ($response->getStatusCode()->value == 20) { echo ""; } else if ($line['type'] === 'heading') { + if (empty($title)) { + $title = $line['text']; + } + echo "$line[text]"; } else if ($line['type'] === 'listitem') { @@ -98,6 +104,7 @@ if ($response->getStatusCode()->value == 20) { echo "Unhandled MIME type: $mime"; } } else { + $title = $response->getHeader(); echo $response->getHeader(); } @@ -109,6 +116,9 @@ $content = ob_get_clean(); + + + <?php echo $title; ?> -- cgit v1.2.3