page: replace global variables by $Page object
[minimedit.git] / nieuws / feed / index.php
index 0a88cd4f3e06f2ea458d3aaa0d0ed826867f5a08..9fb71a9ae86de7cf7bc2c43e3956a832e717d361 100644 (file)
@@ -1,20 +1,20 @@
 <?php
-ob_clean();
 header('Content-Type: application/atom+xml; charset=utf-8');
+header('Access-Control-Allow-Origin: *');
 print '<?xml version="1.0" encoding="utf-8"?>';
-$siteref = 'http://'.$_SERVER['HTTP_HOST'];
+$siteref = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'];
 ?>
 
 <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Lijtweg.nl</title>
        <subtitle>Nieuwsberichten</subtitle>
-       <id><?= $siteref ?></id>
-       <link href="<?= $siteref ?>" />
+       <id><?= $siteref ?>/</id>
+       <link href="<?= $siteref ?>/" />
        <link href="<?= $siteref . $_SERVER['REQUEST_URI'] ?>" rel="self" />
+       <icon>/favicon.png</icon>
        <author><name>Lijtweg</name></author>
 <?php
-include 'nieuws.inc.php';
-$root = preg_replace('{/feed$}', '', $Page) . "/2???";
+$root = preg_replace('{/feed$}', '', $Page->handler) . "/2???";
 $pages = array_reverse(glob("$root/*.html"));
 
 foreach ($pages as $i => $page) {
@@ -27,18 +27,24 @@ foreach ($pages as $i => $page) {
 
        <entry>
                <id><?= $siteref . '/' . $article->link ?></id>
-               <link href="/<?= $article->link ?>" />
+               <link href="<?= $siteref . '/' . $article->link ?>" />
                <title><?= $article->title ?></title>
-               <published><?= $article->dateiso ?></published>
-               <updated><?= $article->dateiso ?></updated>
-               <content type="html"><?= htmlspecialchars($article->body) ?></content>
+               <published><?= $article->meta['article:published_time'] ?? $article->dateiso ?></published>
+               <updated><?= $article->meta['article:modified_time'] ?? $article->dateiso ?></updated>
 <?php
+       if ($article->teaser) {
+               printf("\t\t<summary>%s</summary>\n", htmlspecialchars($article->teaser));
+       }
        if ($article->thumb) {
-               printf("\t\t".'<link rel="enclosure" type="%s" length="%d" href="%s" />'."\n",
-                       'image/jpeg', filesize($article->thumb), "$siteref/{$article->thumb}"
+               printf("\t\t".'<link rel="enclosure" type="%s" href="%s"%s />'."\n",
+                       'image/jpeg',
+                       "$siteref/{$article->thumb}",
+                       file_exists($article->thumb) ? sprintf(' length="%d"', filesize($article->thumb)) : ''
                );
        }
 ?>
+               <content type="html"><?= htmlspecialchars($article->story) ?>
+               </content>
        </entry>
 <?php
 }