sc: redirect subpage aliases to preferred canonical names
[sheet.git] / tools / mksitemap
index 4948525137c260aae74898cbf9c3ede7dc837eb4..7407392fa95b50f0ab63e054eb8570712e2c6e8e 100755 (executable)
@@ -2,21 +2,26 @@
 use 5.014;
 use warnings;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
+
+use File::stat;
+use Time::Piece;
 
 my @pages = (
        [qw( index )],
-       [qw( readline vi digraphs charset unicode )],
-       [qw( vimperator mutt nethack mplayer )],
-       [qw( writing )],
-       [qw( source )],
+       [qw( vi digraphs charset browser writing sc/lotv termcol dieren )],
+       [qw( readline latin unicode countries emoji perl )],
+       [qw( vimperator mutt nethack mplayer font codec )],
+       [qw( apl less screen digits sc/bw sc/hots termcol/legacy keyboard )],
+       [qw( chars/table/html sample source plan )],
 );
 
 my %freq = (
-       (map { $_ => 'yearly' } qw[ readline nethack mplayer ]),
+       (map { $_ => 'yearly' } qw[ readline nethack mplayer apl ]),
+       (map { $_ => 'weekly' } qw[ browser ]),
 );
 
-my %known = map { $_ => 1 } map { @{$_} } @pages;
+my %known = map { s{/.*}{}r => 1 } map { @{$_} } @pages;
 $known{$_} or warn "page $_ undeclared\n"
        for grep { !/\./ } map { s/\.plp\z//r } glob '*.plp';
 
@@ -24,12 +29,20 @@ say '<?xml version="1.0" encoding="UTF-8"?>';
 say '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
 for my $group (@pages) {
        state $prio = 1;
-       for my $page (@{$group}) {
-               $page =~ s/\Aindex\z//;
+       for my $file (@{$group}) {
+               (my $page = $file) =~ s/\Aindex\z//;
+               $file =~ s{/.*}{};
+               $file .= '.plp';
+               my $stat = stat $file or do {
+                       warn "missing file $file\n";
+                       next;
+               };
+
                print '<url>';
                print "<loc>http://sheet.shiar.nl/$page</loc>";
                printf '<changefreq>%s</changefreq>', $freq{$page} // 'monthly';
                printf '<priority>%.2f</priority>', $prio;
+               printf '<lastmod>%s</lastmod>', localtime($stat->mtime)->date;
                say '</url>';
        }
        $prio -= .1;