Merge branch 'feature/banner' into 'main'
Add banner and additional formatting to home timeline See merge request edent/activitypub-single-php-file!3main
commit
2a7d476b1c
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 126 KiB |
57
index.php
57
index.php
|
@ -191,6 +191,11 @@
|
|||
"mediaType" => "image/png",
|
||||
"url" => "https://{$server}/icon.png"
|
||||
],
|
||||
"image" => [
|
||||
"type" => "Image",
|
||||
"mediaType" => "image/png",
|
||||
"url" => "https://{$server}/banner.png"
|
||||
],
|
||||
"publicKey" => [
|
||||
"id" => "https://{$server}/{$username}#main-key",
|
||||
"owner" => "https://{$server}/{$username}",
|
||||
|
@ -481,22 +486,50 @@ echo <<< HTML
|
|||
<html lang="en-GB">
|
||||
<head>
|
||||
<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>
|
||||
<style>
|
||||
body { text-align: center; font-family:sans-serif; font-size:1.1em; }
|
||||
ul { text-align: left; }
|
||||
body { margin:0; padding: 0; font-family:sans-serif; }
|
||||
@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%; }
|
||||
.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>
|
||||
</head>
|
||||
<body>
|
||||
<span class="h-card">
|
||||
<img src="icon.png" alt="icon" class="u-photo " width="140px" />
|
||||
<h1><span class="p-name">{$realName}</span></h1>
|
||||
<h2><a class="p-nickname u-url" href="https://{$server}/{$username}">@{$username}@{$server}</a></h2>
|
||||
<p class="note">{$summary}</p>
|
||||
</span>
|
||||
<div class="h-feed">
|
||||
<div class="header">
|
||||
<div class="banner">
|
||||
<img src="banner.png" alt="banner" class="u-feature " /><br/>
|
||||
<img src="icon.png" alt="icon" class="u-photo " />
|
||||
</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>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>
|
||||
HTML;
|
||||
// Get all posts, most recent first
|
||||
|
@ -513,19 +546,21 @@ HTML;
|
|||
$postHTML = $postData["content"];
|
||||
|
||||
// If the message has an image attached, display it.
|
||||
if ( isset($postData["attachment"]) ) {
|
||||
if ( isset($postData["attachment"]["url"]) ) {
|
||||
$postImgUrl = $postData["attachment"]["url"];
|
||||
$postImgAlt = $postData["attachment"]["name"];
|
||||
$postImg = "<img src='{$postImgUrl}' alt='$postImgAlt'>";
|
||||
$postImg = "<br/><img class='u-photo' src='{$postImgUrl}' alt='$postImgAlt'>";
|
||||
} else {
|
||||
$postImg = "";
|
||||
}
|
||||
|
||||
// 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
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
|
Ładowanie…
Reference in New Issue