nieuws/feed: atom export of articles
[minimedit.git] / nieuws / feed / index.php
diff --git a/nieuws/feed/index.php b/nieuws/feed/index.php
new file mode 100644 (file)
index 0000000..eff9203
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+ob_clean();
+print '<?xml version="1.0" encoding="utf-8"?>';
+$siteref = 'http://'.$_SERVER['HTTP_HOST'];
+?>
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+       <title>Lijtweg.nl</title>
+       <subtitle>Nieuwsberichten</subtitle>
+       <id><?= $siteref ?></id>
+       <link href="<?= $siteref ?>" />
+       <link href="<?= $siteref . $_SERVER['REQUEST_URI'] ?>" rel="self" />
+       <author><name>Lijtweg</name></author>
+<?php
+include 'nieuws.inc.php';
+$root = preg_replace('{/feed$}', '', $Page) . "/2???";
+$pages = array_reverse(glob("$root/*.html"));
+
+foreach ($pages as $i => $page) {
+       $article = new ArchiveArticle($page);
+       if (!$i) {
+               // feed metadata from top (most recent) article
+               print "\t<updated>{$article->lastiso}</updated>\n";
+       }
+?>
+
+       <entry>
+               <id><?= $siteref . '/' . $article->link ?></id>
+               <link href="/<?= $article->link ?>" />
+               <title><?= $article->title ?></title>
+               <published><?= $article->dateiso ?></published>
+               <updated><?= $article->lastiso ?></updated>
+               <content type="html"><?= htmlspecialchars($article->body) ?></content>
+<?php
+       if ($article->thumb) {
+               printf("\t\t".'<link rel="enclosure" type="%s" length="%d" href="%s" />'."\n",
+                       'image/jpeg', filesize($article->thumb), "$siteref/{$article->thumb}"
+               );
+       }
+?>
+       </entry>
+<?php
+}
+?>
+</feed>
+<?php
+exit;