index: release v1.18 with only altgr index linked
[sheet.git] / codec.plp
1 <(common.inc.plp)><:
2
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") };
8 if ($@) {
9         $info = {};
10 }
11
12 Html({
13         title => "$title cheat sheet",
14         version => '1.1',
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>',
20 });
21
22 %{$info}
23         or Abort("Requested codec type <q>$page</q> not available", '404 request not found');
24
25 say "<h1>\u$title</h1>";
26 say "<p>$_</p>" for $info->{intro} // ();
27
28 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
29 :>
30
31 <div class="section">
32 <table class="mapped">
33 <:
34 my @codecs = sort {
35         $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
36 } keys $info->{codec}->%*;
37 my @codeccols = @{$info->{codec}}{@codecs};
38
39 {
40         print '<col>';
41         my @spans;
42         $spans[ $_->{generation} ]++ for @codeccols;
43         print "<colgroup span=$_>" for @spans;
44 }
45 say '<thead><tr><th rowspan=2>';
46 say "\t", '<th>', $_->{name} for @codeccols;
47 print '<tr>';
48 print '<td>', $_->{available} for @codeccols;
49 say '</thead>';
50
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;
57         for (@codecs) {
58                 my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
59                 if (not defined $data) {
60                         if (my $override = $BOOLSCORE{$score}) {
61                                 ($score, $data) = @{$override};
62                         }
63                         else {
64                                 $data = '•' x ($score - 1);
65                         }
66                 }
67                 printf '<td class="l%d"', $score;
68                 printf ' title="%s"', EscapeHTML($_) for $title // ();
69                 print '>', $data;
70         }
71         say '</td>';
72 }
73
74 :></table>
75 </div>
76