diff options
| author | sillylaird <sillyfanboy@gmail.com> | 2026-09-03 00:33:59 +0000 |
|---|---|---|
| committer | sillylaird <sillyfanboy@gmail.com> | 2026-09-03 00:33:59 +0000 |
| commit | 898b52edcb47bcb3e9d6106e74ca73e74ea01e70 (patch) | |
| tree | 85c6ee5ad58b860144551184d4cf86b560c62b91 /journal/feed.xml.php | |
| download | www-898b52edcb47bcb3e9d6106e74ca73e74ea01e70.tar.gz www-898b52edcb47bcb3e9d6106e74ca73e74ea01e70.zip | |
Diffstat (limited to '')
| -rw-r--r-- | journal/feed.xml.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/journal/feed.xml.php b/journal/feed.xml.php new file mode 100644 index 0000000..14fd337 --- /dev/null +++ b/journal/feed.xml.php @@ -0,0 +1,37 @@ +<?php +$entries = require __DIR__ . '/entries.php'; + +header('Content-Type: application/atom+xml; charset=utf-8'); +header('Cache-Control: public, max-age=900'); + +$entries = array_slice($entries, 0, 50); +$site = 'https://www.sillylaird.ca'; +$self = $site . '/journal/feed.xml.php'; +$updated = $entries[0]['date'] ?? date('Y-m-d'); + +function _xml(string $s): string { + return htmlspecialchars($s, ENT_XML1 | ENT_QUOTES, 'UTF-8'); +} + +echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; +?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>SillyLaird — Journal</title> + <link href="<?= _xml($site) ?>/journal/" /> + <link rel="self" href="<?= _xml($self) ?>" /> + <id><?= _xml($site) ?>/journal/</id> + <updated><?= _xml($updated) ?>T00:00:00Z</updated> + <author><name>SillyLaird</name></author> +<?php foreach ($entries as $e): + $date = $e['date'] ?? date('Y-m-d'); + $body = $e['body'] ?? ''; +?> + <entry> + <title><?= _xml($date . ' — ' . mb_strimwidth($body, 0, 80, '…', 'UTF-8')) ?></title> + <id><?= _xml($site) ?>/journal/#<?= _xml($date) ?></id> + <updated><?= _xml($date) ?>T00:00:00Z</updated> + <link href="<?= _xml($site) ?>/journal/" /> + <summary type="text"><?= _xml($body) ?></summary> + </entry> +<?php endforeach; ?> +</feed> |
