codec: categorise related features in groups
[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 });
15
16 my $info = do 'codec.inc.pl';
17 $info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!);
18
19 my %BOOLSCORE = (y => 5, n => 1);
20 :>
21 <h1>Image codecs</h1>
22
23 <div class="section">
24 <table class="mapped">
25         <col><colgroup span=2><colgroup span=2><colgroup span=3>
26 <thead><tr><th rowspan=2>feature
27 <:
28 my @codecs = sort {
29         $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
30 } keys $info->{codec}->%*;
31
32 print '<th>', $_->{name} for @{$info->{codec}}{@codecs};
33 print "\n<tr>";
34 print '<td>', $_->{available} for @{$info->{codec}}{@codecs};
35 say '</thead>';
36
37 while (defined (my $feat = shift @feat)) {
38         my $featinfo = $info->{feature}->{$feat} or next;
39         unshift @feat, @{$_} for $featinfo->{children} // ();
40         $featinfo->{score} or $featinfo->{data} or next;
41         print '<tbody>' if $featinfo->{children};
42         printf '<tr><th>%s', $featinfo->{name} // $feat;
43         printf('<td class="l%d">%s',
44                 (map { $_ && $BOOLSCORE{$_} || $_ || 0 } $featinfo->{score}->{$_}),
45                 $featinfo->{data}->{$_} // (map {
46                         $BOOLSCORE{$_} ? ($_ eq 'y' ? '✔' : '✘') : '•' x ($_ - 1)
47                 } $featinfo->{score}->{$_}),
48         ) for @codecs;
49         say '</td>';
50 }
51
52 :></table>
53 </div>
54