diff options
| author | winter | 2025-03-15 18:53:29 +0000 |
|---|---|---|
| committer | winter | 2025-03-15 18:53:29 +0000 |
| commit | e0588a6113ff6b3c1000fa6c82629f81fb5e05b5 (patch) | |
| tree | ef6beb046a7dcc7542b88f0962d4e5e264895b7a /templates/actor/atom.php | |
| parent | 61b122e88cc6783b4d0cf5142a22002f8e558c60 (diff) | |
[refactor] move some templates to subdirs
Diffstat (limited to 'templates/actor/atom.php')
| -rw-r--r-- | templates/actor/atom.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/templates/actor/atom.php b/templates/actor/atom.php new file mode 100644 index 0000000..8bd40fb --- /dev/null +++ b/templates/actor/atom.php @@ -0,0 +1,51 @@ +<?php +/** @var \Digitigrade\Model\Actor $actor */ +/** @var string $lang */ + +use Digitigrade\GlobalSettings; +use Digitigrade\Model\Note; +use Digitigrade\Model\NotePrivacyScope; + +$selfUri = path_to_uri("/actor/$actor->id/feed/$lang/feed.atom"); +$actorPage = path_to_uri("/@/$actor->handle"); + +echo '<?xml version="1.0" encoding="utf-8"?>'; +?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <id><?= $selfUri ?></id> + <title> + <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?> + </title> + <updated><?= Note::findAllWithAuthor($actor, 1)[0]->created->format(DateTime::ATOM) ?></updated> + <author> + <name><?= htmlspecialchars($actor->displayName) ?></name> + <uri><?= $actorPage ?></uri> + </author> + <link rel="self" href="<?= $selfUri ?>" /> + <link rel="alternate" type="text/html" href="<?= $actorPage ?>" /> + <generator version="<?= get_version() ?>">Digitigrade</generator> + <?php if (isset($actor->avatar)): ?> + <icon><?= $actor->avatar ?></icon> + <?php endif; ?> + <subtitle><?= __f('user.rss.description', $actor->displayName) ?></subtitle> + + <?php foreach (Note::findAllWithAuthor($actor, limit: 50) as $note): ?> + <?php + /** @var Note $note */ + if ($note->privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) { + continue; + } + ?> + <entry> + <id><?= path_to_uri("/note/$note->id") ?></id> + <title><![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]></title> + <updated><?= ($note->modified ?? $note->created)->format(DateTime::ATOM) ?></updated> + <link rel="alternate" type="text/html" href="<?= path_to_uri("/@/$actor->handle/note/$note->id") ?>" /> + <content type="html"><![CDATA[<?= $note->getBestContentAsHtml() ?>]]></content> + <?php foreach ($note->attachments as $file): ?> + <link rel="enclosure" title="<?= htmlspecialchars($file->description) ?>" type="<?= $file->type ?>" + href="<?= $file->href ?>" /> + <?php endforeach; ?> + </entry> + <?php endforeach; ?> +</feed>
\ No newline at end of file |
