codec: page request overrides image type
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 31 Oct 2021 01:00:48 +0000 (02:00 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
codec-image.inc.pl [moved from codec.inc.pl with 100% similarity]
codec.plp

similarity index 100%
rename from codec.inc.pl
rename to codec-image.inc.pl
index 8a5b6a89de36b3e86f2387cdca87e510ca8a9953..2349b1dc9747085742c468318d9eb41501575bfd 100644 (file)
--- a/codec.plp
+++ b/codec.plp
@@ -1,25 +1,33 @@
 <(common.inc.plp)><:
 
-my @feat = split m{/+}, $Request || 'default';
+my ($page, @feat) = split m{/+}, $Request || 'image';
+$page !~ /\W/ or Html(), Abort('Invalid codec type request', 400);
+@feat or @feat = 'default';
+my $title = "$page codecs";
 
 Html({
-       title => 'Codecs',
+       title => "$title cheat sheet",
        version => '1.0',
        description => [
        ],
        keywords => [qw'
+               codec encoder encoding decode file format type mime
+               feature comparison support benchmark compression
+               image audio video
        '],
        stylesheet => [qw'light circus dark red'],
        data => [qw'codec.inc.pl'],
        raw => '<style>td,th {width:10%} tbody th {white-space:nowrap}</style>',
 });
 
-my $info = do 'codec.inc.pl';
-$info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!);
+my $info = do "codec-$page.inc.pl";
+$info and %{$info} > 1
+       or Abort("Requested codec type <q>$page</q> not available", '404 request not found', $@ // $!);
+
+say "<h1>\u$title</h1>";
 
 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
 :>
-<h1>Image codecs</h1>
 
 <div class="section">
 <table class="mapped">