X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/9f1aad6e442dbb3a88210a379d645db842d00def..b86bbb8de10c94737088dbc8b3c8c2fd9d7d0770:/sc.plp
diff --git a/sc.plp b/sc.plp
index 0a41018..3c19fce 100644
--- a/sc.plp
+++ b/sc.plp
@@ -20,18 +20,25 @@ my %scvers = (
game => 'StarCraft II LotV',
major => 2,
},
+ index => 'bw',
+ 1 => 'bw',
+ 2 => 'lotv',
);
-$Request ||= 'bw';
-$Request = 'lotv' if $Request eq '2';
-my %scver = %{ $scvers{$Request} }
- or Abort("Requested version $Request not available", '404 unknown');
+my $requestver = $scvers{$Request ||= 'index'}
+ or Html(), Abort("Requested version $Request not available", '404 request not found');
-my $datafile = "sc-units-$Request.inc.pl";
+if (ref $requestver ne 'HASH') {
+ $header{Location} = "/sc/$requestver";
+ Abort("Canonical URL for $Request is at $requestver", '302 subpage alias');
+}
+
+my %scver = %{$requestver};
+my $datafile = "sc-units-$Request";
Html({
title => "$scver{title} unit cheat sheet",
- version => '1.1',
+ version => '1.3',
description => [
"Reference of $scver{game} unit properties,"
. " comparing various statistics of all the units in $scver{name}"
@@ -45,15 +52,14 @@ Html({
$scver{major} < 2 ? qw' bw broodwar brood war ' :
qw' starcraft2 lotv hots wol ',
],
- stylesheet => [qw'light'],
- raw => '',
- data => [$datafile],
+ stylesheet => [qw( light dark )],
+ raw => '',
+ data => ["$datafile.inc.pl"],
});
say "
$scver{game} units
\n";
-my $units = do $datafile;
-Abort("Cannot open unit data", 501, $_) for $@ || $! || ();
+my $units = Data($datafile);
my $patch = shift @{$units}
or Abort("Cannot open unit data: metadata not found", 501);
@@ -104,8 +110,8 @@ sub coltoggle {