Skip to content

Commit 1cad283

Browse files
jnarebgitster
authored andcommitted
gitweb: Easier adding/changing parameters to current URL
Add boolean option '-replay' to href() subroutine, which is used to generate links in gitweb. This option "replays" current URL, overriding it with provided parameters. It means that current value of each CGI parameter is used unless otherwise provided. This change is meant to make it easier to generate links which differ from current page URL only by one parameter, for example the same view but sorted by different column: href(-replay=>1, order=>"age") or view which differs by some option, e.g. in log views href(-replay=>1, extra_options=>"--no-merges") or alternate view of the same object, e.g. in the 'blob' view href(-replay=>1, action=>"blob_plain") Actual use of this functionality is left for later. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fa9aff4 commit 1cad283

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gitweb/gitweb.perl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,15 @@ (%)
611611
);
612612
my %mapping = @mapping;
613613

614+
if ($params{-replay}) {
615+
while (my ($name, $symbol) = each %mapping) {
616+
if (!exists $params{$name}) {
617+
# to allow for multivalued params we use arrayref form
618+
$params{$name} = [ $cgi->param($symbol) ];
619+
}
620+
}
621+
}
622+
614623
$params{'project'} = $project unless exists $params{'project'};
615624

616625
my ($use_pathinfo) = gitweb_check_feature('pathinfo');

0 commit comments

Comments
 (0)