3 my ($page, @feat) = split m{/+}, $Request || 'image';
4 $page !~ /\W/ or Html(), Abort('Invalid codec type request', 400);
5 @feat or @feat = 'default';
6 my $title = "$page codecs";
7 my $info = eval { Data("codec-$page") };
13 title => "$title cheat sheet",
15 description => $info->{intro},
16 keywords => [@{ $info->{keywords} // [] }, qw' feature comparison support benchmark '],
17 stylesheet => [qw'light circus dark red'],
18 data => ["codec-$page.inc.pl"],
19 raw => '<style>td,th {width:8%} tbody th {white-space:nowrap}</style>',
23 or Abort("Requested codec type <q>$page</q> not available", '404 request not found');
25 say "<h1>\u$title</h1>";
26 say "<p>$_</p>" for $info->{intro} // ();
28 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
32 <table class="mapped">
35 $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
36 } keys $info->{codec}->%*;
37 my @codeccols = @{$info->{codec}}{@codecs};
42 $spans[ $_->{generation} ]++ for @codeccols;
43 print "<colgroup span=$_>" for @spans;
45 say '<thead><tr><th rowspan=2>';
46 say "\t", '<th>', $_->{name} for @codeccols;
48 print '<td>', $_->{available} for @codeccols;
51 while (defined (my $feat = shift @feat)) {
52 my $featinfo = $info->{feature}->{$feat} or next;
53 unshift @feat, @{$_} for $featinfo->{children} // ();
54 $featinfo->{score} or next;
55 print '<tbody>' if $featinfo->{children};
56 printf '<tr><th>%s', $featinfo->{name} // $feat;
58 my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
59 if (not defined $data) {
60 if (my $override = $BOOLSCORE{$score}) {
61 ($score, $data) = @{$override};
64 $data = '•' x ($score - 1);
67 printf '<td class="l%d"', $score;
68 printf ' title="%s"', EscapeHTML($_) for $title // ();