Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Atom feed #66

Merged
merged 5 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/handlebars/atom.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Feed - Dialog - Timm Friebe</title>
<link href="{{request.uri.base}}/feed/atom" rel="self"/>
<updated>{{date items.0.date format="c"}}</updated>
<author><name>Timm Friebe</name></author>
<id>urn:uuid:abf3ae67-8d43-497f-bd40-f7fb793eed4f</id>

{{#each items}}
<entry>
<title>{{title}}</title>
<link href="{{request.uri.base}}/{{route this}}"/>
<id>urn:oid:{{_id}}</id>
<updated>{{date ./date format="c"}}</updated>
<summary type="text">{{#each locations}}{{.}}{{#unless @last}}, {{/unless}}{{/each}}</summary>
<content type="html">
{{#with images.0}}&lt;img src="/image/{{slug}}/preview-{{name}}.jpg"&gt;{{/with}}&lt;br&gt;
{{content}}
</content>
</entry>
{{/each}}
</feed>
1 change: 1 addition & 0 deletions src/main/handlebars/layout.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{{> meta}}
<link rel="stylesheet" type="text/css" href="/assets/{{asset 'vendor.css'}}">
<link rel="icon" type="image/svg+xml" href="/static/icon.svg">
<link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/feed/atom"/>
<style type="text/css">
/* CSS reset, see https://piccalil.li/blog/a-modern-css-reset/ */
*, *::before, *::after {
Expand Down
10 changes: 9 additions & 1 deletion src/main/php/de/thekid/dialog/web/Feed.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace de\thekid\dialog\web;

use de\thekid\dialog\{Repository, Pagination};
use web\frontend\{Handler, Get, Param};
use web\frontend\{Handler, Get, Param, View};

#[Handler('/feed')]
class Feed {
Expand All @@ -13,4 +13,12 @@ public function __construct(private Repository $repository) { }
public function listing(#[Param] $page= 1) {
return $this->repository->entries($this->pagination, (int)$page);
}

#[Get('/atom')]
public function atom() {
return View::named('atom')
->header('Content-Type', 'application/atom+xml; charset=utf-8')
->with(['items' => $this->repository->newest(20)])
;
}
}
Loading