index: release v1.18 with only altgr index linked
[sheet.git] / codec.plp
index 2e5079487e792c6147425a8c9dd36354c5f118ae..f13b93ac198d545bbdcc5d12ab2a5eb35bc16867 100644 (file)
--- a/codec.plp
+++ b/codec.plp
@@ -1,37 +1,51 @@
 <(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";
+my $info = eval { Data("codec-$page") };
+if ($@) {
+       $info = {};
+}
 
 Html({
-       title => 'Codecs',
-       version => '1.0',
-       description => [
-       ],
-       keywords => [qw'
-       '],
+       title => "$title cheat sheet",
+       version => '1.1',
+       description => $info->{intro},
+       keywords => [@{ $info->{keywords} // [] }, qw' feature comparison support benchmark '],
        stylesheet => [qw'light circus dark red'],
-       data => [qw'codec.inc.pl'],
+       data => ["codec-$page.inc.pl"],
+       raw => '<style>td,th {width:8%} tbody th {white-space:nowrap}</style>',
 });
 
-my $info = do 'codec.inc.pl';
-$info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!);
+%{$info}
+       or Abort("Requested codec type <q>$page</q> not available", '404 request not found');
+
+say "<h1>\u$title</h1>";
+say "<p>$_</p>" for $info->{intro} // ();
 
 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
 :>
-<h1>Image codecs</h1>
 
 <div class="section">
 <table class="mapped">
-       <col><colgroup span=3><colgroup span=2><colgroup span=3>
-<thead><tr><th rowspan=2>feature
 <:
 my @codecs = sort {
        $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
 } keys $info->{codec}->%*;
+my @codeccols = @{$info->{codec}}{@codecs};
 
-print '<th>', $_->{name} for @{$info->{codec}}{@codecs};
-print "\n<tr>";
-print '<td>', $_->{available} for @{$info->{codec}}{@codecs};
+{
+       print '<col>';
+       my @spans;
+       $spans[ $_->{generation} ]++ for @codeccols;
+       print "<colgroup span=$_>" for @spans;
+}
+say '<thead><tr><th rowspan=2>';
+say "\t", '<th>', $_->{name} for @codeccols;
+print '<tr>';
+print '<td>', $_->{available} for @codeccols;
 say '</thead>';
 
 while (defined (my $feat = shift @feat)) {
@@ -51,7 +65,7 @@ while (defined (my $feat = shift @feat)) {
                        }
                }
                printf '<td class="l%d"', $score;
-               printf ' title="%s"', $_ for $title // ();
+               printf ' title="%s"', EscapeHTML($_) for $title // ();
                print '>', $data;
        }
        say '</td>';