diff options
| author | winter | 2024-12-14 00:08:41 +0000 |
|---|---|---|
| committer | winter | 2024-12-14 00:08:41 +0000 |
| commit | 86cf52e8d2701e13bd9fd4c847b35eba7506c473 (patch) | |
| tree | 7b21f99004650efc42057e96905967e5d4e01038 /routes | |
| parent | 2713c1f73a39d4106936d4c52bf8f18d810d7f3c (diff) | |
add a godawful basic html actor page
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/actor.php | 4 | ||||
| -rw-r--r-- | routes/user.php | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/routes/actor.php b/routes/actor.php index 021b9f8..51c0e1a 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -1,6 +1,7 @@ <?php use Digitigrade\HttpResponseStatus\NotFound; +use Digitigrade\HttpResponseStatus\TemporaryRedirect; use Digitigrade\Model\Actor; use Digitigrade\Model\Note; use Digitigrade\Router; @@ -10,6 +11,9 @@ Router::getInstance()->mount('/user/:handle', function (array $args) { if ($actor == null) { throw new NotFound("i don't know any local user called " . $args['handle']); } + if (str_contains($_SERVER['HTTP_ACCEPT'], 'text/html')) { + throw new TemporaryRedirect(path_to_uri("/@/$actor->handle")); + } json_response($actor); }); diff --git a/routes/user.php b/routes/user.php new file mode 100644 index 0000000..5532448 --- /dev/null +++ b/routes/user.php @@ -0,0 +1,30 @@ +<?php + +use Digitigrade\HttpResponseStatus\NotFound; +use Digitigrade\Model\Actor; +use Digitigrade\Router; + +Router::getInstance()->mount('/@/:handle', function (array $args) { + $actor = Actor::findLocalByHandle($args['handle']); + if ($actor == null) { + throw new NotFound("i don't know any local user called " . $args['handle']); + } + + ?> + <!DOCTYPE html> + <html> + + <head> + <title><?= $actor->displayName ?> (@<?= $actor->handle ?>)</title> + </head> + + <body> + <h1><?= $actor->displayName ?></h1> + <p>@<?= $actor->handle ?></p> + <hr> + <p><?= $actor->bio ?></p> + </body> + + </html> + <?php +});
\ No newline at end of file |
