Source of codec.plp

<(common.inc.plp)><:

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";
my $info = eval { Data("codec-$page") };
if ($@) {
	$info = {};
}

Html({
	title => "$title cheat sheet",
	version => '1.1',
	description => $info->{intro},
	keywords => [@{ $info->{keywords} // [] }, qw' feature comparison support benchmark '],
	data => ["codec-$page.inc.pl"],
	raw => '<style>td,th {width:8%} tbody th {white-space:nowrap}</style>',
});

%{$info}
	or Abort("Requested codec type <q>$page</q> not available", '404 request not found');

say "<h1>\u$title</h1>";
say "<p>$_</p>" for $info->{intro} // ();

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

<div class="section">
<table class="mapped">
<:
my @codecs = sort {
	$info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
} keys $info->{codec}->%*;
my @codeccols = @{$info->{codec}}{@codecs};

{
	print '<col>';
	my @spans;
	$spans[ $_->{generation} ]++ for @codeccols;
	print "<colgroup span=$_>" for @spans;
}
say '<thead><tr><th rowspan=2>';
say "\t", '<th>', $_->{name} for @codeccols;
print '<tr>';
print '<td>', $_->{available} for @codeccols;
say '</thead>';

while (defined (my $feat = shift @feat)) {
	my $featinfo = $info->{feature}->{$feat} or next;
	unshift @feat, @{$_} for $featinfo->{children} // ();
	$featinfo->{score} or next;
	print '<tbody>' if $featinfo->{children};
	printf '<tr><th>%s', $featinfo->{name} // $feat;
	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 '<td class="l%d"', $score;
		printf ' title="%s"', EscapeHTML($_) for $title // ();
		print '>', $data;
	}
	say '</td>';
}

:></table>
</div>