--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Latest comments</title>
+ <link href="{{baseUrl}}/latest-atom.php"/>
+ <updated>{{lastComment.comment_published|date("c")}}</updated>
+ <id>{{baseUrl}}/latest-atom.php</id>
+
+ {% for comment in comments %}
+ <entry>
+ <title>{{comment.comment_type}} #{{comment.comment_id}} to {{comment.domain}}</title>
+ <link href="{{baseUrl}}{{comment.url}}"/>
+ <id>{{baseUrl}}{{comment.url}}</id>
+ <updated>{{comment.comment_published|date("c")}}</updated>
+ <author>
+ <name>{{comment.user.user_name}}</name>
+ </author>
+ <summary>
+ {{comment.comment_type}} to
+ {{comment.comment_of_url}}
+ </summary>
+ </entry>
+ {% endfor %}
+</feed>
<meta charset="utf-8"/>
<title>Latest comments</title>
<link rel="stylesheet" type="text/css" href="css/latest.css"/>
+ <link rel="alternate" type="application/atom+xml" href="latest-atom.php"/>
<meta name="generator" content="anoweco"/>
</head>
<body class="h-entry">
--- /dev/null
+<?php
+namespace anoweco;
+require 'www-header.php';
+
+$storage = new Storage();
+$comments = $storage->listLatest();
+
+foreach ($comments as $comment) {
+ $comment->url = Urls::comment($comment->comment_id);
+ $comment->domain = parse_url($comment->comment_of_url, PHP_URL_HOST);
+}
+
+$vars = [
+ 'baseUrl' => getBaseUrl(),
+ 'comments' => $comments,
+ 'lastComment' => $comments[0],
+];
+header('Content-Type: application/atom+xml');
+render('latest-atom', $vars);
+?>
echo $template->render($vars);
}
}
+
+/**
+ * No trailing slash
+ */
+function getBaseUrl()
+{
+ return $_SERVER['REQUEST_SCHEME']
+ . '://' . $_SERVER['HTTP_HOST'];
+}
?>