Show follower/following count

main
Terence Eden 2024-03-03 14:39:12 +00:00
rodzic 8c93c008e0
commit 9b1c494b03
1 zmienionych plików z 28 dodań i 2 usunięć

Wyświetl plik

@ -484,6 +484,7 @@
global $username, $server, $realName, $summary, $directories;
$rawUsername = rawurldecode( $username );
// What sort of viewable page is this?
switch ( $style ) {
case "home":
$h1 = "HomePage";
@ -494,6 +495,13 @@
$directory = "inbox";
break;
}
// Counters for followers, following, and posts
$follower_files = glob( $directories["followers"] . "/*.json");
$totalFollowers = count( $follower_files );
$following_files = glob( $directories["following"] . "/*.json");
$totalFollowing = count( $following_files );
echo <<< HTML
<!DOCTYPE html>
@ -540,6 +548,7 @@ echo <<< HTML
<h2><a class="p-nickname u-url" rel="author" href="https://{$server}/{$username}">@{$rawUsername}@{$server}</a></h2>
</address>
<p class="p-summary">{$summary}</p>
<p>Following: {$totalFollowing} | Followers: {$totalFollowers}</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>
@ -587,12 +596,29 @@ HTML;
if ( isset( $message["object"]["id"] ) ) {
$id = $message["object"]["id"];
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\"><a href=\"{$id}\">{$published}</a></time>";
} else if ( isset( $message["id"] ) ) {
$id = $message["id"];
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\"><a href=\"{$id}\">{$published}</a></time>";
} else {
$id = "";
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\">{$published}</time>";
}
$actor = $message["actor"];
$actorName = end( explode("/", $actor ) );
// Get the actor who authored the message
if ( isset( $message["actor"] ) ) {
// Usually found in Inbox messages
$actor = $message["actor"];
} else if ( isset( $message["attributedTo"] ) ) {
// Usually found in sent messages
$actor = $message["attributedTo"];
} else {
// Should never happen!
$actor = "https://example.com/anonymous";
}
// Assume that what comes after the final `/` in the URl is the name
$actorName = end( explode( "/", $actor ) );
// Make i18n usernames readable and safe.
$actorName = htmlspecialchars( rawurldecode( $actorName ) );
$actorHTML = "<a href=\"$actor\">@{$actorName}</a>";
// What type of message is this?