X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/c3ef3326d8ca3d9209afd34f6220f78b1eb0dbc2..e1c15e98e78002475bc637d1a5848b45414b9e41:/codec.plp diff --git a/codec.plp b/codec.plp index 35b97ed..2349b1d 100644 --- a/codec.plp +++ b/codec.plp @@ -1,24 +1,33 @@ <(common.inc.plp)><: -my @feat = split m{/+}, $Request || 'default'; +my ($page, @feat) = split m{/+}, $Request || 'image'; +$page !~ /\W/ or Html(), Abort('Invalid codec type request', 400); +@feat or @feat = 'default'; +my $title = "$page codecs"; Html({ - title => 'Codecs', + title => "$title cheat sheet", version => '1.0', description => [ ], keywords => [qw' + codec encoder encoding decode file format type mime + feature comparison support benchmark compression + image audio video '], stylesheet => [qw'light circus dark red'], data => [qw'codec.inc.pl'], + raw => '', }); -my $info = do 'codec.inc.pl'; -$info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!); +my $info = do "codec-$page.inc.pl"; +$info and %{$info} > 1 + or Abort("Requested codec type $page not available", '404 request not found', $@ // $!); -my %BOOLSCORE = (y => 5, n => 1); +say "

\u$title

"; + +my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']); :> -

Image codecs

@@ -37,15 +46,23 @@ say ''; while (defined (my $feat = shift @feat)) { my $featinfo = $info->{feature}->{$feat} or next; unshift @feat, @{$_} for $featinfo->{children} // (); - $featinfo->{score} or $featinfo->{data} or next; + $featinfo->{score} or next; print '' if $featinfo->{children}; printf ''; }
%s', $featinfo->{name} // $feat; - printf('%s', - (map { $_ && $BOOLSCORE{$_} || $_ || 0 } $featinfo->{score}->{$_}), - $featinfo->{data}->{$_} // (map { - $BOOLSCORE{$_} ? ($_ eq 'y' ? '✔' : '✘') : '•' x ($_ - 1) - } $featinfo->{score}->{$_}), - ) for @codecs; + for (@codecs) { + my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_}; + if (not defined $data) { + if (my $override = $BOOLSCORE{$score}) { + ($score, $data) = @{$override}; + } + else { + $data = '•' x ($score - 1); + } + } + printf '', $data; + } say '