aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor_rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'templates/actor_rss.php')
-rw-r--r--templates/actor_rss.php46
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