page: replace output caching by article object
[minimedit.git] / nieuws / feed / index.php
1 <?php
2 header('Content-Type: application/atom+xml; charset=utf-8');
3 print '<?xml version="1.0" encoding="utf-8"?>';
4 $siteref = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'];
5 ?>
6
7 <feed xmlns="http://www.w3.org/2005/Atom">
8         <title>Lijtweg.nl</title>
9         <subtitle>Nieuwsberichten</subtitle>
10         <id><?= $siteref ?>/</id>
11         <link href="<?= $siteref ?>/" />
12         <link href="<?= $siteref . $_SERVER['REQUEST_URI'] ?>" rel="self" />
13         <author><name>Lijtweg</name></author>
14 <?php
15 $root = preg_replace('{/feed$}', '', $Page) . "/2???";
16 $pages = array_reverse(glob("$root/*.html"));
17
18 foreach ($pages as $i => $page) {
19         $article = new ArchiveArticle($page);
20         if (!$i) {
21                 // feed metadata from top (most recent) article
22                 print "\t<updated>{$article->lastiso}</updated>\n";
23         }
24 ?>
25
26         <entry>
27                 <id><?= $siteref . '/' . $article->link ?></id>
28                 <link href="<?= $siteref . '/' . $article->link ?>" />
29                 <title><?= $article->title ?></title>
30                 <published><?= $article->dateiso ?></published>
31                 <updated><?= $article->dateiso ?></updated>
32 <?php
33         if ($article->teaser) {
34                 printf("\t\t<summary>%s</summary>\n", htmlspecialchars($article->teaser));
35         }
36         if ($article->thumb) {
37                 printf("\t\t".'<link rel="enclosure" type="%s" href="%s"%s />'."\n",
38                         'image/jpeg',
39                         "$siteref/{$article->thumb}",
40                         file_exists($article->thumb) ? sprintf(' length="%d"', filesize($article->thumb)) : ''
41                 );
42         }
43 ?>
44                 <content type="html"><?= htmlspecialchars($article->story) ?>
45                 </content>
46         </entry>
47 <?php
48 }
49 ?>
50 </feed>
51 <?php
52 exit;