From 8c4721622dd9e717228f408c3aacebdccdfa69f0 Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Mon, 28 Dec 2020 20:07:25 +0100 Subject: recent_list: hack support for caller-specified rel_path It had been identified by djpig as something that might be needed at some point, since the current heuristics to compute a rel_path doesn't work when one is below a directory X and trying to locate items below a directory Y that's neither X or under X (e.g. intro/ vs. security/). This implementation shouldn't change anything for existing callers, as they'll end up with an undefined last parameter, while callers passing that extra parameter will skip the insufficient heuristics. --- english/template/debian/recent_list.wml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/english/template/debian/recent_list.wml b/english/template/debian/recent_list.wml index 833d33da066..5497add9d3b 100644 --- a/english/template/debian/recent_list.wml +++ b/english/template/debian/recent_list.wml @@ -109,12 +109,18 @@ sub get_recent_list { $is_events = 0; $is_by_date = 0; - my ($time, $minnum, $eng_dir, $format, $match) = @_; + my ($time, $minnum, $eng_dir, $format, $match, $rel_path) = @_; # djpig: this is a hack for backward compatibility # djpig: I would prefer a new argument $rel_path # djpig: additionally to $eng_dir - my $rel_path = ($time =~ s|^(?:\./)?([[:alpha:]]+)/?||) ? $1 : ''; - $rel_path .= '/' unless $rel_path eq ''; + # + # kibi/2020-12-28: let's retain the previous heuristics when + # rel_path is not defined, while adding support for a + # caller-specified rel_path + if (not defined $rel_path) { + my $rel_path = ($time =~ s|^(?:\./)?([[:alpha:]]+)/?||) ? $1 : ''; + $rel_path .= '/' unless $rel_path eq ''; + } #warn "$rel_path\n"; my $open_by_path = 0; my ($year, $since_year, $since_date); -- cgit v1.2.3