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/rss.php | |
| parent | 61b122e88cc6783b4d0cf5142a22002f8e558c60 (diff) | |
[refactor] move some templates to subdirs
Diffstat (limited to 'templates/actor/rss.php')
| -rw-r--r-- | templates/actor/rss.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/templates/actor/rss.php b/templates/actor/rss.php new file mode 100644 index 0000000..03fc4f5 --- /dev/null +++ b/templates/actor/rss.php @@ -0,0 +1,46 @@ +<?php +/** @var \Digitigrade\Model\Actor $actor */ +/** @var string $lang */ + +use Digitigrade\GlobalSettings; +use Digitigrade\Model\Note; +use Digitigrade\Model\NotePrivacyScope; + +// putting this here because otherwise my ide yells about "shorthand <?" +// because it thinks i'm trying to do a php thing instead of xml directive +echo '<?xml version="1.0" encoding="utf-8"?>'; +?> +<rss version="2.0"> + <channel> + <title> + <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?> + </title> + <link><?= path_to_uri("/@/$actor->handle") ?></link> + <description><?= __f('user.rss.description', htmlspecialchars($actor->displayName)) ?></description> + <language><?= $lang ?></language> + <generator><?= __f('version', get_version()) ?></generator> + <?php if (isset($actor->avatar)): ?> + <image> + <url><?= $actor->avatar ?></url> + </image> + <?php endif; ?> + <?php foreach (Note::findAllWithAuthor($actor, limit: 50) as $note): ?> + <?php + /** @var Note $note */ + if ($note->privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) { + continue; + } + ?> + <item> + <link><?= path_to_uri("/@/$actor->handle/note/$note->id") ?></link> + <guid><?= path_to_uri("/note/$note->id") ?></guid> + <title><![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]></title> + <description><![CDATA[<?= $note->getBestContentAsHtml() ?>]]></description> + <pubDate><?= $note->created->format(DateTime::RSS) ?></pubDate> + <?php foreach ($note->attachments as $file): ?> + <enclosure url="<?= $file->href ?>" type="<?= $file->type ?>" size="-1" /><!-- size unknown sorry :( --> + <?php endforeach; ?> + </item> + <?php endforeach; ?> + </channel> +</rss>
\ No newline at end of file |
