unicode: one set of barb arrows from unicode 7.0
[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
8 Html({
9         title => "$title cheat sheet",
10         version => '1.0',
11         description => [
12         ],
13         keywords => [qw'
14                 codec encoder encoding decode file format type mime
15                 feature comparison support benchmark compression
16                 image audio video
17         '],
18         stylesheet => [qw'light circus dark red'],
19         data => [qw'codec.inc.pl'],
20         raw => '<style>td,th {width:8%} tbody th {white-space:nowrap}</style>',
21 });
22
23 my $info = do "codec-$page.inc.pl";
24 $info and %{$info} > 1
25         or Abort("Requested codec type <q>$page</q> not available", '404 request not found', $@ // $!);
26
27 say "<h1>\u$title</h1>";
28 say "<p>$_</p>" for $info->{intro} // ();
29
30 my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
31 :>
32
33 <div class="section">
34 <table class="mapped">
35 <:
36 my @codecs = sort {
37         $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
38 } keys $info->{codec}->%*;
39 my @codeccols = @{$info->{codec}}{@codecs};
40
41 {
42         print '<col>';
43         my @spans;
44         $spans[ $_->{generation} ]++ for @codeccols;
45         print "<colgroup span=$_>" for @spans;
46 }
47 say '<thead><tr><th rowspan=2>';
48 say "\t", '<th>', $_->{name} for @codeccols;
49 print '<tr>';
50 print '<td>', $_->{available} for @codeccols;
51 say '</thead>';
52
53 while (defined (my $feat = shift @feat)) {
54         my $featinfo = $info->{feature}->{$feat} or next;
55         unshift @feat, @{$_} for $featinfo->{children} // ();
56         $featinfo->{score} or next;
57         print '<tbody>' if $featinfo->{children};
58         printf '<tr><th>%s', $featinfo->{name} // $feat;
59         for (@codecs) {
60                 my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
61                 if (not defined $data) {
62                         if (my $override = $BOOLSCORE{$score}) {
63                                 ($score, $data) = @{$override};
64                         }
65                         else {
66                                 $data = '•' x ($score - 1);
67                         }
68                 }
69                 printf '<td class="l%d"', $score;
70                 printf ' title="%s"', EscapeHTML($_) for $title // ();
71                 print '>', $data;
72         }
73         say '</td>';
74 }
75
76 :></table>
77 </div>
78