page: replace output caching by article object
[minimedit.git] / sitemap.xml / index.php
index 7d288152ff9bce59f6aaedf6bf10ec140d70df90..0e68218fc972a001a6f4abf9d8603c0425bbd9dd 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-ob_clean();
 header('Content-Type: application/atom+xml; charset=utf-8');
 print '<?xml version="1.0" encoding="utf-8"?>';
 $siteref = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'];
@@ -12,6 +11,14 @@ foreach ($search->files() as $link) {
        $article = new ArchiveArticle($link);
        print '<url>';
        print "<loc>$siteref/{$article->link}</loc>";
+       $score = 10;
+       if ($article->link) {
+               $score -= substr_count($article->link, '/') + 1;  # -10% per subdir
+               $age = time() - strtotime($article->dateiso);
+               $age /= 3600 * 24 * 365;  # years
+               if ($age > .1) $score -= $age / 10 + .1;  # -1% per year
+       }
+       printf('<priority>%.2f</priority>', $score / 10);
        if ($article->last) {
                print "<lastmod>{$article->lastiso}</lastmod>";
        }