diff options
| author | winter | 2024-12-20 19:12:12 +0000 |
|---|---|---|
| committer | winter | 2024-12-20 19:12:12 +0000 |
| commit | 3272de09352d1583ea817187d13a7a548e360296 (patch) | |
| tree | 747d621c8e9543dbdf9b81bd751a8a6e153477f8 /routes | |
| parent | d9ae605537792e93a535851c32d14393a645fc75 (diff) | |
super ultra mega basic global timeline
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/actor.php | 2 | ||||
| -rw-r--r-- | routes/global_timeline.php | 30 | ||||
| -rw-r--r-- | routes/homepage.php | 14 | ||||
| -rw-r--r-- | routes/interaction.php | 2 | ||||
| -rw-r--r-- | routes/note.php | 2 | ||||
| -rw-r--r-- | routes/user.php | 2 |
6 files changed, 41 insertions, 11 deletions
diff --git a/routes/actor.php b/routes/actor.php index 65a3837..8ebf1e2 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -9,7 +9,7 @@ use Digitigrade\Router; Router::getInstance()->mount('/user/:handle', function (array $args) { $actor = Actor::findLocalByHandle($args['handle']); - if ($actor == null) { + if ($actor == null || $actor->deleted) { throw new NotFound("i don't know any local user called " . $args['handle']); } if (isset($_SERVER['HTTP_ACCEPT']) && str_contains($_SERVER['HTTP_ACCEPT'], 'text/html')) { diff --git a/routes/global_timeline.php b/routes/global_timeline.php new file mode 100644 index 0000000..55f64e1 --- /dev/null +++ b/routes/global_timeline.php @@ -0,0 +1,30 @@ +<?php + +use Digitigrade\Model\Note; +use Digitigrade\Router; + +Router::getInstance()->mount('/feed/global', function (array $args) { + // this is really rubbish as it doesn't put them in order, doesn't check visibility/indexable, etc + $posts = Note::findAllWhere('deleted = false', []); + ?> + <!DOCTYPE html> + <html lang="en"> + + <head> + <title>digitigrade global timeline</title> + </head> + + <body> + <h1>Global timeline</h1> + <?php foreach ($posts as $p): ?> + <div style="margin: 8px; padding: 8px; border: 1px solid"> + <b><?= $p->author->displayName ?></b> <small><?= $p->author->uri ?></small><br> + <p><?= $p->plainContent ?></p> + <small><?= $p->created->format('c') ?></small> + </div> + <?php endforeach; ?> + </body> + + </html> + <?php +});
\ No newline at end of file diff --git a/routes/homepage.php b/routes/homepage.php index 5fbc102..94fe4c9 100644 --- a/routes/homepage.php +++ b/routes/homepage.php @@ -1,12 +1,12 @@ <?php +use Digitigrade\HttpResponseStatus\NotFound; +use Digitigrade\HttpResponseStatus\TemporaryRedirect; use Digitigrade\Router; Router::getInstance()->mount('/', function (array $args) { - echo '<h1>home</h1>'; -}); - -Router::getInstance()->mount('/:username', function (array $args) { ?> - <h1><?= $args['username'] ?></h1> - <p>todo!</p> -<?php });
\ No newline at end of file + if (str_contains($_SERVER['HTTP_ACCEPT'] ?? '', 'text/html')) { + throw new TemporaryRedirect(path_to_uri('/feed/global')); + } + throw new NotFound(); +});
\ No newline at end of file diff --git a/routes/interaction.php b/routes/interaction.php index c50dec2..53bc193 100644 --- a/routes/interaction.php +++ b/routes/interaction.php @@ -6,7 +6,7 @@ use Digitigrade\Router; Router::getInstance()->mount('/interaction/:id', function (array $args) { $interaction = Interaction::find($args['id']); - if ($interaction == null) { + if ($interaction == null || $interaction->deleted) { throw new NotFound("i don't know that interaction"); } if (!$interaction->author->isLocal) { diff --git a/routes/note.php b/routes/note.php index be7eb25..4e0f867 100644 --- a/routes/note.php +++ b/routes/note.php @@ -6,7 +6,7 @@ use Digitigrade\Router; Router::getInstance()->mount('/post/:id', function (array $args) { $note = Note::find($args['id']); - if ($note == null) { + if ($note == null || $note->deleted) { throw new NotFound("i don't know that note"); } if (!$note->author->isLocal) { diff --git a/routes/user.php b/routes/user.php index 5532448..8626c38 100644 --- a/routes/user.php +++ b/routes/user.php @@ -6,7 +6,7 @@ use Digitigrade\Router; Router::getInstance()->mount('/@/:handle', function (array $args) { $actor = Actor::findLocalByHandle($args['handle']); - if ($actor == null) { + if ($actor == null || $actor->deleted) { throw new NotFound("i don't know any local user called " . $args['handle']); } |
