Add NodeInfo
rodzic
a463087ec4
commit
edbf35c4d3
71
index.php
71
index.php
|
@ -112,6 +112,7 @@
|
||||||
case ".well-known/webfinger":
|
case ".well-known/webfinger":
|
||||||
webfinger(); // Mandatory. Static.
|
webfinger(); // Mandatory. Static.
|
||||||
case rawurldecode( $username ):
|
case rawurldecode( $username ):
|
||||||
|
case "@" . rawurldecode( $username ): // Some software assumes usernames start with an `@`
|
||||||
username(); // Mandatory. Static
|
username(); // Mandatory. Static
|
||||||
case "following":
|
case "following":
|
||||||
following(); // Mandatory. Can be static or dynamic.
|
following(); // Mandatory. Can be static or dynamic.
|
||||||
|
@ -119,18 +120,22 @@
|
||||||
followers(); // Mandatory. Can be static or dynamic.
|
followers(); // Mandatory. Can be static or dynamic.
|
||||||
case "inbox":
|
case "inbox":
|
||||||
inbox(); // Mandatory.
|
inbox(); // Mandatory.
|
||||||
|
case "outbox":
|
||||||
|
outbox(); // Optional. Dynamic.
|
||||||
case "write":
|
case "write":
|
||||||
write(); // User interface for writing posts
|
write(); // User interface for writing posts
|
||||||
case "send":
|
case "send":
|
||||||
send(); // API for posting content to the Fediverse
|
send(); // API for posting content to the Fediverse
|
||||||
case "outbox":
|
|
||||||
outbox(); // Optional. Dynamic.
|
|
||||||
case "follow":
|
case "follow":
|
||||||
follow(); // User interface for following an external user
|
follow(); // User interface for following an external user
|
||||||
case "follow_user":
|
case "follow_user":
|
||||||
follow_user(); // API for following a user
|
follow_user(); // API for following a user
|
||||||
case "read":
|
case "read":
|
||||||
read(); // User interface for reading posts
|
read(); // User interface for reading posts
|
||||||
|
case ".well-known/nodeinfo":
|
||||||
|
wk_nodeinfo(); // Optional. Static.
|
||||||
|
case "nodeinfo/2.1":
|
||||||
|
nodeinfo(); // Optional. Static.
|
||||||
case "/":
|
case "/":
|
||||||
home(); // Optional. Can be dynamic
|
home(); // Optional. Can be dynamic
|
||||||
default:
|
default:
|
||||||
|
@ -1258,6 +1263,68 @@ HTML;
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The NodeInfo Protocol is used to identify servers.
|
||||||
|
// It is looked up with `example.com/.well-known/nodeinfo`
|
||||||
|
// See https://nodeinfo.diaspora.software/
|
||||||
|
function wk_nodeinfo() {
|
||||||
|
global $server;
|
||||||
|
|
||||||
|
$nodeinfo = array(
|
||||||
|
"links" => array(
|
||||||
|
array(
|
||||||
|
"rel" => "self",
|
||||||
|
"type" => "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
||||||
|
"href" => "https://{$server}/nodeinfo/2.1"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
header( "Content-Type: application/json" );
|
||||||
|
echo json_encode( $nodeinfo );
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The NodeInfo Protocol is used to identify servers.
|
||||||
|
// It is looked up with `example.com/.well-known/nodeinfo` which points to this resource
|
||||||
|
// See http://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.0#$$expand
|
||||||
|
function nodeinfo() {
|
||||||
|
global $server, $directories;
|
||||||
|
|
||||||
|
// Get all posts
|
||||||
|
$posts = glob( $directories["posts"] . "/*.json") ;
|
||||||
|
// Number of posts
|
||||||
|
$totalItems = count( $posts );
|
||||||
|
|
||||||
|
$nodeinfo = array(
|
||||||
|
"version" => "2.1", // Version of the schema, not the software
|
||||||
|
"software" => array(
|
||||||
|
"name" => "Single File ActivityPub Server in PHP",
|
||||||
|
"version" => "0.000000001",
|
||||||
|
"repository" => "https://gitlab.com/edent/activitypub-single-php-file/"
|
||||||
|
),
|
||||||
|
"protocols" => array( "activitypub"),
|
||||||
|
"services" => array(
|
||||||
|
"inbound" => array(),
|
||||||
|
"outbound" => array()
|
||||||
|
),
|
||||||
|
"openRegistrations" => false,
|
||||||
|
"usage" => array(
|
||||||
|
"users" => array(
|
||||||
|
"total" => 1
|
||||||
|
),
|
||||||
|
"localPosts" => $totalItems
|
||||||
|
),
|
||||||
|
"metadata"=> array(
|
||||||
|
"nodeName" => "activitypub-single-php-file",
|
||||||
|
"nodeDescription" => "This is a single PHP file which acts as an extremely basic ActivityPub server.",
|
||||||
|
"spdx" => "AGPL-3.0-or-later"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
header( "Content-Type: application/json" );
|
||||||
|
echo json_encode( $nodeinfo );
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// "One to stun, two to kill, three to make sure"
|
// "One to stun, two to kill, three to make sure"
|
||||||
die();
|
die();
|
||||||
die();
|
die();
|
||||||
|
|
Ładowanie…
Reference in New Issue