www: Fix versions page for multichar sections + add section selector

This commit is contained in:
Yorhel 2024-05-02 20:01:52 +02:00
parent 3bf860f54e
commit ca07b78610

View file

@ -1133,7 +1133,7 @@ TUWF::get qr{/loc/([a-fA-F0-9]{40})}, sub {
# /ver[.$shorthash][.$lang]/$name.$section
TUWF::get qr{/ver(?:\.([a-fA-F0-9]{8}))?(?:\.([^/]+))?/([^/]+)\.([0-9a-zA-Z])}, sub {
TUWF::get qr{/ver(?:\.([a-fA-F0-9]{8}))?(?:\.([^/]+))?/([^/]+)\.([0-9a-zA-Z]+)}, sub {
my($shorthash, $lang, $name, $sect) = tuwf->captures(1,2,3,4);
$shorthash = $shorthash ? shorthash_to_int $shorthash : -1;
$lang ||= '';
@ -1148,6 +1148,10 @@ TUWF::get qr{/ver(?:\.([a-fA-F0-9]{8}))?(?:\.([^/]+))?/([^/]+)\.([0-9a-zA-Z])},
ORDER BY p.system DESC, p.name, v.released DESC, f.shorthash
');
my @sect = map $_->{section}, tuwf->dbAlli(
'SELECT DISTINCT section FROM mans WHERE name =', \$name, 'ORDER BY section'
)->@*;
my $langs = man_languages $name, $sect;
my %sys;
@ -1157,6 +1161,19 @@ TUWF::get qr{/ver(?:\.([a-fA-F0-9]{8}))?(?:\.([^/]+))?/([^/]+)\.([0-9a-zA-Z])},
framework_ title => $title, mainclass => 'verpage', sub {
h1_ $title;
p_ sub {
txt_ 'Alternative sections: ';
for (0..$#sect) {
txt_ ', ' if $_ > 0;
if(($sect[$_]||'') eq $sect) {
b_ $sect[$_];
} else {
a_ href => '/ver'.($lang?".$lang":'')."/$name.$sect[$_]", $sect[$_];
}
}
txt_ '.';
} if @sect > 1;
p_ sub {
txt_ 'Available languages: ';
for (0..$#{$langs}) {