From 2a0b17e8c37b13b5af67cd03d99d70e26d4e5744 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 19 Mar 2023 15:27:25 +0100 Subject: [PATCH] codec: page specific keywords from include data --- codec-audio.inc.pl | 1 + codec-image.inc.pl | 1 + codec.plp | 18 ++++++++---------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/codec-audio.inc.pl b/codec-audio.inc.pl index 5844ea0..330f3b5 100644 --- a/codec-audio.inc.pl +++ b/codec-audio.inc.pl @@ -1,6 +1,7 @@ use utf8; +{ intro => 'Comparison of audio compression formats.', +keywords => [qw( audio sound codec encoder encoding decode compression file format type mime )], codec => { mp3 => { name => 'MP3', diff --git a/codec-image.inc.pl b/codec-image.inc.pl index f689142..6c138ab 100644 --- a/codec-image.inc.pl +++ b/codec-image.inc.pl @@ -1,6 +1,7 @@ use utf8; +{ intro => 'Comparison of image encoding formats, based on Cloudinary research.', +keywords => [qw( image picture codec encoder encoding decode compression file format type mime )], codec => { jpeg => { name => 'JPEG', diff --git a/codec.plp b/codec.plp index 5c3e572..05fe30e 100644 --- a/codec.plp +++ b/codec.plp @@ -4,25 +4,23 @@ 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.0', - description => [ - ], - keywords => [qw' - codec encoder encoding decode file format type mime - feature comparison support benchmark compression - image audio video - '], + description => $info->{intro}, + keywords => [@{ $info->{keywords} // [] }, qw' feature comparison support benchmark '], stylesheet => [qw'light circus dark red'], data => ["codec-$page.inc.pl"], raw => '', }); -my $info = Data("codec-$page"); -$info and %{$info} > 1 - or Abort("Requested codec type $page not available", '404 request not found', $@ // $!); +%{$info} + or Abort("Requested codec type $page not available", '404 request not found'); say "

\u$title

"; say "

$_

" for $info->{intro} // (); -- 2.30.0