aboutsummaryrefslogtreecommitdiffstats
path: root/changelog/feed.xml.php
blob: 3a43e6acf4bbc71929f797e753f8ce29b7f2fb43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require_once __DIR__ . '/api/parser.php';

header('Content-Type: application/atom+xml; charset=utf-8');
header('Cache-Control: public, max-age=900');

$entries = get_changelog_entries(50);
$site    = 'https://www.sillylaird.ca';
$self    = $site . '/changelog/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 — Changelog</title>
  <link href="<?= _xml($site) ?>/changelog/" />
  <link rel="self" href="<?= _xml($self) ?>" />
  <id><?= _xml($site) ?>/changelog/</id>
  <updated><?= _xml($updated) ?>T00:00:00Z</updated>
  <author><name>SillyLaird</name></author>
<?php foreach ($entries as $e):
    $id = $site . '/changelog/#' . ($e['date'] ?: $e['raw_date']);
    $date = $e['date'] ?: date('Y-m-d');
?>
  <entry>
    <title><?= _xml(mb_strimwidth($e['text'], 0, 80, '…', 'UTF-8')) ?></title>
    <id><?= _xml($id) ?></id>
    <updated><?= _xml($date) ?>T00:00:00Z</updated>
    <link href="<?= _xml($site) ?>/changelog/" />
    <summary type="text"><?= _xml($e['text']) ?></summary>
  </entry>
<?php endforeach; ?>
</feed>