summaryrefslogtreecommitdiff
path: root/handler/RSS.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
commitf7bfdf58def6aadc922e1632f407d1418269a0d7 (patch)
treed7a0b2819e6a26c11d40ee0b27267ea827fbb345 /handler/RSS.php
initial
Diffstat (limited to 'handler/RSS.php')
-rw-r--r--handler/RSS.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/handler/RSS.php b/handler/RSS.php
new file mode 100644
index 0000000..08a2136
--- /dev/null
+++ b/handler/RSS.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace handler;
+use posts;
+use Response;
+use SkinContext;
+
+class RSS extends \RequestHandler {
+
+ public function get(): Response {
+ global $config;
+
+ $items = array_map(fn(\Post $post) => [
+ 'title' => $post->title,
+ 'link' => $post->getUrl(),
+ 'pub_date' => date(DATE_RSS, $post->ts),
+ 'description' => $post->getDescriptionPreview(500),
+ ], posts::getPosts(0, 20));
+
+ $ctx = new SkinContext('\\skin\\rss');
+ $body = $ctx->atom(
+ title: ($this->lang)('site_title'),
+ link: 'https://'.$config['domain'],
+ rss_link: 'https://'.$config['domain'].'/feed.rss',
+ items: $items);
+
+ $response = new Response(200, $body);
+ $response->addHeader('Content-Type: application/rss+xml; charset=utf-8');
+ return $response;
+ }
+
+} \ No newline at end of file