feat: ✨ add RSS and Atom feeds with caching and nice links
This commit is contained in:
parent
c6297fd81b
commit
596cc0e1a3
7 changed files with 120 additions and 1 deletions
|
@ -111,6 +111,14 @@ function generate_website($SURI) {
|
|||
|
||||
echo $twig->render('upload.html');
|
||||
}
|
||||
} elseif(preg_match('/^\/feed(?:\/(rss|atom)(.*))?$/', $SURI, $match)) {
|
||||
$feed = $adapter->get_laminas_feed($match[2] ?? '/', $match[1] ?? 'rss');
|
||||
|
||||
header('Content-Type: application/xml');
|
||||
header('Cache-Control: max-age=1800');
|
||||
header('Etag: W/"' . $SURI . '/' . strtotime($feed['feed_ts']) . '"');
|
||||
|
||||
echo $feed['feed'];
|
||||
} elseif(preg_match('/^\s*image/', $_SERVER['HTTP_ACCEPT'])) {
|
||||
header('Location: /raw' . $SURI);
|
||||
exit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue