update index after creating new article
[push-tester.git] / www / index.php
1 <?php
2 require_once __DIR__ . '/../data/config.php';
3 header('Link: <' . $hub . '>; rel="hub"');
4 header('Link: <' . $self . '>; rel="self"', false);
5
6 $files = glob(__DIR__ . '/articles/*.htm');
7 $articles = array();
8 foreach ($files as $file) {
9     $content = file_get_contents($file);
10     $xml = simplexml_load_string($content);
11     $timestamp = strtotime(basename($file, '.htm'));
12     $articles[$timestamp] = (object) array(
13         'file' => 'articles/' . basename($file),
14         'title' => basename($file, '.htm'),
15         'content' => (string) $xml->body->div,
16         'time' => $timestamp,
17     );
18 }
19 krsort($articles);
20 ?>
21 <html xmlns="http://www.w3.org/1999/xhtml">
22  <head>
23   <title>PubSubHubbub tester</title>
24  </head>
25  <body class="h-feed">
26   <p>
27    <a href="add-article.php">create new article</a>
28   </p>
29   <h1>Articles</h1>
30   <?php foreach ($articles as $article) { ?>
31    <article class="h-entry">
32     <h2><?php echo htmlspecialchars($article->title); ?></h2>
33     <div class="e-content">
34      <?php echo $article->content; ?>
35     </div>
36     <p>
37      <a href="<?php echo $article->file; ?>" class="u-url">permalink</a>
38      at <time class="dt-published"><?php echo date('c', $article->time); ?></time>
39      by
40      <span class="h-card vcard author p-author">
41       <img class="u-photo" src="someone.png" width="16" height="16" alt=""/>
42       <a class="p-author h-card" href="someone.htm">Someone</a>
43      </span>
44     </p>
45    </article>
46   <?php } ?>
47  </body>
48 </html>