sitemap: warn about undeclared pages
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 2 May 2017 21:59:57 +0000 (23:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 29 May 2017 17:23:12 +0000 (19:23 +0200)
tools/mksitemap

index cbfa8c93c7c14b450100401d97f5fe2eeefe5377..4948525137c260aae74898cbf9c3ede7dc837eb4 100755 (executable)
@@ -5,7 +5,7 @@ use warnings;
 our $VERSION = '1.00';
 
 my @pages = (
 our $VERSION = '1.00';
 
 my @pages = (
-       [''],
+       [qw( index )],
        [qw( readline vi digraphs charset unicode )],
        [qw( vimperator mutt nethack mplayer )],
        [qw( writing )],
        [qw( readline vi digraphs charset unicode )],
        [qw( vimperator mutt nethack mplayer )],
        [qw( writing )],
@@ -16,11 +16,16 @@ my %freq = (
        (map { $_ => 'yearly' } qw[ readline nethack mplayer ]),
 );
 
        (map { $_ => 'yearly' } qw[ readline nethack mplayer ]),
 );
 
+my %known = map { $_ => 1 } map { @{$_} } @pages;
+$known{$_} or warn "page $_ undeclared\n"
+       for grep { !/\./ } map { s/\.plp\z//r } glob '*.plp';
+
 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}) {
 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//;
                print '<url>';
                print "<loc>http://sheet.shiar.nl/$page</loc>";
                printf '<changefreq>%s</changefreq>', $freq{$page} // 'monthly';
                print '<url>';
                print "<loc>http://sheet.shiar.nl/$page</loc>";
                printf '<changefreq>%s</changefreq>', $freq{$page} // 'monthly';