codec: constant table column widths
[sheet.git] / codec.plp
1 <(common.inc.plp)><:
2
3 my @feat = split m{/+}, $Request || 'default';
4
5 Html({
6         title => 'Codecs',
7         version => '1.0',
8         description => [
9         ],
10         keywords => [qw'
11         '],
12         stylesheet => [qw'light circus dark red'],
13         data => [qw'codec.inc.pl'],
14         raw => '<style>td,th {width:10%} tbody th {white-space:nowrap}</style>',
15 });
16
17 my $info = do 'codec.inc.pl';
18 $info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!);
19
20 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
21 :>
22 <h1>Image codecs</h1>
23
24 <div class="section">
25 <table class="mapped">
26         <col><colgroup span=3><colgroup span=2><colgroup span=3>
27 <thead><tr><th rowspan=2>feature
28 <:
29 my @codecs = sort {
30         $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
31 } keys $info->{codec}->%*;
32
33 print '<th>', $_->{name} for @{$info->{codec}}{@codecs};
34 print "\n<tr>";
35 print '<td>', $_->{available} for @{$info->{codec}}{@codecs};
36 say '</thead>';
37
38 while (defined (my $feat = shift @feat)) {
39         my $featinfo = $info->{feature}->{$feat} or next;
40         unshift @feat, @{$_} for $featinfo->{children} // ();
41         $featinfo->{score} or next;
42         print '<tbody>' if $featinfo->{children};
43         printf '<tr><th>%s', $featinfo->{name} // $feat;
44         for (@codecs) {
45                 my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
46                 if (not defined $data) {
47                         if (my $override = $BOOLSCORE{$score}) {
48                                 ($score, $data) = @{$override};
49                         }
50                         else {
51                                 $data = '•' x ($score - 1);
52                         }
53                 }
54                 printf '<td class="l%d"', $score;
55                 printf ' title="%s"', $_ for $title // ();
56                 print '>', $data;
57         }
58         say '</td>';
59 }
60
61 :></table>
62 </div>
63