page: api attribute indicate index requests
[minimedit.git] / sitemap.xml / index.php
index 7d288152ff9bce59f6aaedf6bf10ec140d70df90..99b6fcfb0a93d2e98655bcbc9a8bc0e376d3ae4e 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-ob_clean();
+if ($Page->api) return;
 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'];
@@ -7,16 +7,26 @@ $siteref = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTT
 
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <?php
+$caller = $Page;
 $search = new PageSearch();
 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>";
        }
        print "</url>\n";
 }
+$Page = $caller;
 ?>
 </urlset>
 <?php