From aafbcc8fc1a07872fffa4d669117f41148e509a8 Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 23 Dec 2024 22:26:46 +0000 Subject: rename "user" to actor and "post" to note everywhere --- routes/actor.php | 18 +++++++++--------- routes/actor_profile.php | 19 +++++++++++++++++++ routes/homepage.php | 2 +- routes/note.php | 4 ++-- routes/user.php | 19 ------------------- routes/webfinger.php | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 routes/actor_profile.php delete mode 100644 routes/user.php (limited to 'routes') diff --git a/routes/actor.php b/routes/actor.php index 8ebf1e2..d453a11 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -7,18 +7,18 @@ use Digitigrade\Model\Actor; use Digitigrade\Model\Note; use Digitigrade\Router; -Router::getInstance()->mount('/user/:handle', function (array $args) { +Router::getInstance()->mount('/actor/:handle', function (array $args) { $actor = Actor::findLocalByHandle($args['handle']); if ($actor == null || $actor->deleted) { - throw new NotFound("i don't know any local user called " . $args['handle']); + throw new NotFound("i don't know any local actor called " . $args['handle']); } if (isset($_SERVER['HTTP_ACCEPT']) && str_contains($_SERVER['HTTP_ACCEPT'], 'text/html')) { - throw new TemporaryRedirect(path_to_uri("/@/$actor->handle")); + throw new TemporaryRedirect("/@/$actor->handle"); } json_response($actor); }); -Router::getInstance()->mount('/user/:handle/basicFeed', function (array $args) { +Router::getInstance()->mount('/actor/:handle/basicFeed', function (array $args) { $actor = Actor::findLocalByHandle($args['handle']); $notes = Note::findAllWithAuthor($actor); // TODO: implement pagination @@ -33,7 +33,7 @@ Router::getInstance()->mount('/user/:handle/basicFeed', function (array $args) { ]); }); -Router::getInstance()->mount('/user/:handle/fullFeed', function (array $args) { +Router::getInstance()->mount('/actor/:handle/fullFeed', function (array $args) { $actor = Actor::findLocalByHandle($args['handle']); $notes = Note::findAllWithAuthor($actor); // TODO: implement pagination here as well @@ -46,7 +46,7 @@ Router::getInstance()->mount('/user/:handle/fullFeed', function (array $args) { ]); }); -Router::getInstance()->mount('/user/:handle/follow', function (array $args) { +Router::getInstance()->mount('/actor/:handle/follow', function (array $args) { $target = Actor::findLocalByHandle($args['handle']); if ($target == null) { throw new NotFound(); @@ -58,7 +58,7 @@ Router::getInstance()->mount('/user/:handle/follow', function (array $args) { $initiator->follow($target); }); -Router::getInstance()->mount('/user/:handle/unfollow', function (array $args) { +Router::getInstance()->mount('/actor/:handle/unfollow', function (array $args) { $target = Actor::findLocalByHandle($args['handle']); if ($target == null) { throw new NotFound(); @@ -70,7 +70,7 @@ Router::getInstance()->mount('/user/:handle/unfollow', function (array $args) { $initiator->unfollow($target); }); -Router::getInstance()->mount('/user/:handle/acceptedFollow', function (array $args) { +Router::getInstance()->mount('/actor/:handle/acceptedFollow', function (array $args) { $initiator = Actor::findLocalByHandle($args['handle']); if ($initiator == null) { throw new NotFound(); @@ -82,7 +82,7 @@ Router::getInstance()->mount('/user/:handle/acceptedFollow', function (array $ar $target->acceptPendingFollowFrom($initiator); }); -Router::getInstance()->mount('/user/:handle/rejectedFollow', function (array $args) { +Router::getInstance()->mount('/actor/:handle/rejectedFollow', function (array $args) { $initiator = Actor::findLocalByHandle($args['handle']); if ($initiator == null) { throw new NotFound(); diff --git a/routes/actor_profile.php b/routes/actor_profile.php new file mode 100644 index 0000000..4fea967 --- /dev/null +++ b/routes/actor_profile.php @@ -0,0 +1,19 @@ +mount('/@/:handle', function (array $args) { + if (str_contains($args['handle'], '@')) { + // remote actor + $actor = Actor::findByWebfinger($args['handle']); + } else { + // local actor + $actor = Actor::findLocalByHandle($args['handle']); + } + if ($actor == null || $actor->deleted) { + throw new NotFound("i don't know any actor called " . $args['handle']); + } + render_template('actor_profile_page', ['actor' => $actor]); +}); \ No newline at end of file diff --git a/routes/homepage.php b/routes/homepage.php index 94fe4c9..c147d67 100644 --- a/routes/homepage.php +++ b/routes/homepage.php @@ -6,7 +6,7 @@ use Digitigrade\Router; Router::getInstance()->mount('/', function (array $args) { if (str_contains($_SERVER['HTTP_ACCEPT'] ?? '', 'text/html')) { - throw new TemporaryRedirect(path_to_uri('/feed/global')); + throw new TemporaryRedirect('/feed/global'); } throw new NotFound(); }); \ No newline at end of file diff --git a/routes/note.php b/routes/note.php index 4e0f867..071c86c 100644 --- a/routes/note.php +++ b/routes/note.php @@ -4,13 +4,13 @@ use Digitigrade\HttpResponseStatus\NotFound; use Digitigrade\Model\Note; use Digitigrade\Router; -Router::getInstance()->mount('/post/:id', function (array $args) { +Router::getInstance()->mount('/note/:id', function (array $args) { $note = Note::find($args['id']); if ($note == null || $note->deleted) { throw new NotFound("i don't know that note"); } if (!$note->author->isLocal) { - throw new NotFound("i don't want to tell you about non local posts sorry"); + throw new NotFound("i don't want to tell you about non local notes sorry"); } json_response($note); }); diff --git a/routes/user.php b/routes/user.php deleted file mode 100644 index c0a632a..0000000 --- a/routes/user.php +++ /dev/null @@ -1,19 +0,0 @@ -mount('/@/:handle', function (array $args) { - if (str_contains($args['handle'], '@')) { - // remote actor - $actor = Actor::findByWebfinger($args['handle']); - } else { - // local actor - $actor = Actor::findLocalByHandle($args['handle']); - } - if ($actor == null || $actor->deleted) { - throw new NotFound("i don't know any user called " . $args['handle']); - } - render_template('actor_profile_page', ['actor' => $actor]); -}); \ No newline at end of file diff --git a/routes/webfinger.php b/routes/webfinger.php index 541fb06..1b719cd 100644 --- a/routes/webfinger.php +++ b/routes/webfinger.php @@ -29,7 +29,7 @@ Router::getInstance()->mount('/.well-known/webfinger', function (array $args) { 'links' => [ [ 'rel' => ActorWebfinger::REL_URI, - 'href' => path_to_uri("/user/$actor->handle"), + 'href' => path_to_uri("/actor/$actor->handle"), 'type' => 'application/json' ] ] -- cgit v1.3