sc: redirect subpage aliases to preferred canonical names
[sheet.git] / tools / mksitemap
index a139941fed370dcd201e33365b14f019409dc9c8..7407392fa95b50f0ab63e054eb8570712e2c6e8e 100755 (executable)
@@ -2,18 +2,18 @@
 use 5.014;
 use warnings;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 
 use File::stat;
 use Time::Piece;
 
 my @pages = (
        [qw( index )],
-       [qw( vi digraphs charset browser writing sc termcol )],
+       [qw( vi digraphs charset browser writing sc/lotv termcol dieren )],
        [qw( readline latin unicode countries emoji perl )],
-       [qw( vimperator mutt nethack mplayer font )],
-       [qw( apl less screen brahmi digits )],
-       [qw( source )],
+       [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 = (
@@ -21,7 +21,7 @@ my %freq = (
        (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';
 
@@ -31,12 +31,18 @@ for my $group (@pages) {
        state $prio = 1;
        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($file)->mtime)->date;
+               printf '<lastmod>%s</lastmod>', localtime($stat->mtime)->date;
                say '</url>';
        }
        $prio -= .1;