summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-11-28 11:29:45 +0100
committerDaniel Weipert <code@drogueronin.de>2023-11-28 11:29:45 +0100
commit12863dd293b84ef2d7f74120623d55e6254b7d5b (patch)
tree3d5b5d59589c02f7c5f180b317127b3af18aa79b
parent602edf5aaabc3fcaecfc9885d699156de089f8b0 (diff)
add title and head
-rw-r--r--index.php10
1 files changed, 10 insertions, 0 deletions
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 "</pre>";
}
else if ($line['type'] === 'heading') {
+ if (empty($title)) {
+ $title = $line['text'];
+ }
+
echo "<h$line[size]>$line[text]</h$line[size]>";
}
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();
<!doctype html>
<html>
<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title><?php echo $title; ?></title>
</head>
<body>
<?php echo $content; ?>