Merge branch 'feature/banner' into 'main'

Add banner and additional formatting to home timeline

See merge request edent/activitypub-single-php-file!3
merge-requests/5/head
Terence Eden 2024-03-02 22:49:10 +00:00
commit 2a7d476b1c
2 zmienionych plików z 80 dodań i 45 usunięć

BIN
banner.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 126 KiB

Wyświetl plik

@ -191,6 +191,11 @@
"mediaType" => "image/png", "mediaType" => "image/png",
"url" => "https://{$server}/icon.png" "url" => "https://{$server}/icon.png"
], ],
"image" => [
"type" => "Image",
"mediaType" => "image/png",
"url" => "https://{$server}/banner.png"
],
"publicKey" => [ "publicKey" => [
"id" => "https://{$server}/{$username}#main-key", "id" => "https://{$server}/{$username}#main-key",
"owner" => "https://{$server}/{$username}", "owner" => "https://{$server}/{$username}",
@ -481,22 +486,50 @@ echo <<< HTML
<html lang="en-GB"> <html lang="en-GB">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:url" content="https://{$server}">
<meta property="og:type" content="website">
<meta property="og:title" content="{$realName}">
<meta property="og:description" content="{$summary}">
<meta property="og:image" content="https://{$server}/banner.png">
<title>{$realName}</title> <title>{$realName}</title>
<style> <style>
body { text-align: center; font-family:sans-serif; font-size:1.1em; } body { margin:0; padding: 0; font-family:sans-serif; }
ul { text-align: left; } @media screen and (max-width: 800px) { body { width: 100%; }}
@media screen and (min-width: 799px) { body { width: 800px; margin: 0 auto; }}
img { max-width: 50%; } img { max-width: 50%; }
.h-feed { margin:auto; width: 100%; }
.h-feed > .header { text-align: center; margin: 0 auto; }
.h-feed .banner { text-align: center; margin:0 auto; max-width: 650px; }
.h-feed > h1, .h-feed > h2 { margin-top: 10px; margin-bottom: 0; }
.h-feed > .header > h1:has(span.p-author), h2:has(a.p-nickname) { word-break: break-all; max-width: 90%; padding-left:20px; }
.h-feed .u-feature:first-child { margin-top: 10px; margin-bottom: -150px; max-width: 100%;}
.h-feed .u-photo { max-height: 8vw; max-width:100%; min-height: 120px; }
.h-feed .about { font-size: smaller; background-color: #F5F5F5; padding: 10px; border-top: dotted 1px #808080; border-bottom: dotted 1px #808080; }
.h-feed > ul { padding-left: 0; list-style-type: none; }
.h-feed > ul > li { padding: 10px; border-bottom: dotted 1px #808080; }
.h-entry { padding-right: 10px; }
.h-entry time.dt-published { font-weight: bold; }
.h-entry .e-content a { word-break: break-all; }
</style> </style>
</head> </head>
<body> <body>
<span class="h-card"> <div class="h-feed">
<img src="icon.png" alt="icon" class="u-photo " width="140px" /> <div class="header">
<h1><span class="p-name">{$realName}</span></h1> <div class="banner">
<h2><a class="p-nickname u-url" href="https://{$server}/{$username}">@{$username}@{$server}</a></h2> <img src="banner.png" alt="banner" class="u-feature " /><br/>
<p class="note">{$summary}</p> <img src="icon.png" alt="icon" class="u-photo " />
</span> </div>
<address>
<h1><span class="p-name p-author">{$realName}</span></h1>
<h2><a class="p-nickname u-url" rel="author" href="https://{$server}/{$username}">@{$username}@{$server}</a></h2>
</address>
<p class="p-summary">{$summary}</p>
<div class="about">
<p><a href="https://gitlab.com/edent/activitypub-single-php-file/">This software is licenced under AGPL 3.0</a>.</p> <p><a href="https://gitlab.com/edent/activitypub-single-php-file/">This software is licenced under AGPL 3.0</a>.</p>
<p>This site is a basic <a href="https://www.w3.org/TR/activitypub/">ActivityPub</a> server designed to be <a href="https://shkspr.mobi/blog/2024/02/activitypub-server-in-a-single-file/">a lightweight educational tool</a>.</p> <p>This site is a basic <a href="https://www.w3.org/TR/activitypub/">ActivityPub</a> server designed to be <a href="https://shkspr.mobi/blog/2024/02/activitypub-server-in-a-single-file/">a lightweight educational tool</a>.</p>
</div>
</div>
<ul> <ul>
HTML; HTML;
// Get all posts, most recent first // Get all posts, most recent first
@ -513,19 +546,21 @@ HTML;
$postHTML = $postData["content"]; $postHTML = $postData["content"];
// If the message has an image attached, display it. // If the message has an image attached, display it.
if ( isset($postData["attachment"]) ) { if ( isset($postData["attachment"]["url"]) ) {
$postImgUrl = $postData["attachment"]["url"]; $postImgUrl = $postData["attachment"]["url"];
$postImgAlt = $postData["attachment"]["name"]; $postImgAlt = $postData["attachment"]["name"];
$postImg = "<img src='{$postImgUrl}' alt='$postImgAlt'>"; $postImg = "<br/><img class='u-photo' src='{$postImgUrl}' alt='$postImgAlt'>";
} else { } else {
$postImg = ""; $postImg = "";
} }
// Display the post // Display the post
echo "<li><a href='/{$post}'><time datetime='{$postTime}'>$postTime</time></a><br>{$postHTML}<br>{$postImg}</li>"; echo "<li><article class='h-entry'><a class='u-url' rel='bookmark' href='/{$post}'><time class='dt-published' datetime='{$postTime}'>$postTime</time></a><br><span class='e-content'>{$postHTML}{$postImg}</span></article></li>";
} }
echo <<< HTML echo <<< HTML
</ul> </ul>
</div>
</div>
</body> </body>
</html> </html>
HTML; HTML;