Show follower/following count
rodzic
8c93c008e0
commit
9b1c494b03
26
index.php
26
index.php
|
@ -484,6 +484,7 @@
|
||||||
global $username, $server, $realName, $summary, $directories;
|
global $username, $server, $realName, $summary, $directories;
|
||||||
$rawUsername = rawurldecode( $username );
|
$rawUsername = rawurldecode( $username );
|
||||||
|
|
||||||
|
// What sort of viewable page is this?
|
||||||
switch ( $style ) {
|
switch ( $style ) {
|
||||||
case "home":
|
case "home":
|
||||||
$h1 = "HomePage";
|
$h1 = "HomePage";
|
||||||
|
@ -495,6 +496,13 @@
|
||||||
break;
|
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
|
echo <<< HTML
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en-GB">
|
<html lang="en-GB">
|
||||||
|
@ -540,6 +548,7 @@ echo <<< HTML
|
||||||
<h2><a class="p-nickname u-url" rel="author" href="https://{$server}/{$username}">@{$rawUsername}@{$server}</a></h2>
|
<h2><a class="p-nickname u-url" rel="author" href="https://{$server}/{$username}">@{$rawUsername}@{$server}</a></h2>
|
||||||
</address>
|
</address>
|
||||||
<p class="p-summary">{$summary}</p>
|
<p class="p-summary">{$summary}</p>
|
||||||
|
<p>Following: {$totalFollowing} | Followers: {$totalFollowers}</p>
|
||||||
<div class="about">
|
<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>
|
||||||
|
@ -587,12 +596,29 @@ HTML;
|
||||||
if ( isset( $message["object"]["id"] ) ) {
|
if ( isset( $message["object"]["id"] ) ) {
|
||||||
$id = $message["object"]["id"];
|
$id = $message["object"]["id"];
|
||||||
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\"><a href=\"{$id}\">{$published}</a></time>";
|
$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 {
|
} else {
|
||||||
$id = "";
|
$id = "";
|
||||||
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\">{$published}</time>";
|
$timeHTML = "<time datetime=\"{$published}\" class=\"u-url\" rel=\"bookmark\">{$published}</time>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the actor who authored the message
|
||||||
|
if ( isset( $message["actor"] ) ) {
|
||||||
|
// Usually found in Inbox messages
|
||||||
$actor = $message["actor"];
|
$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 ) );
|
$actorName = end( explode( "/", $actor ) );
|
||||||
|
// Make i18n usernames readable and safe.
|
||||||
|
$actorName = htmlspecialchars( rawurldecode( $actorName ) );
|
||||||
$actorHTML = "<a href=\"$actor\">@{$actorName}</a>";
|
$actorHTML = "<a href=\"$actor\">@{$actorName}</a>";
|
||||||
|
|
||||||
// What type of message is this?
|
// What type of message is this?
|
||||||
|
|
Ładowanie…
Reference in New Issue