From 06a9d86b49b826562e2b12b5c7e831e20b8f7dce Mon Sep 17 00:00:00 2001 From: Martin Waitz Date: Wed, 16 Aug 2006 00:23:50 +0200 Subject: gitweb: provide function to format the URL for an action link. Provide a new function which can be used to generate an URL for the CGI. This makes it possible to consolidate the URL generation in order to make it easier to change the encoding of actions into URLs. Signed-off-by: Martin Waitz Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gitweb') diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 0e1de297e..1471d4dad 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -184,6 +184,33 @@ if (!defined($actions{$action})) { $actions{$action}->(); exit; +## ====================================================================== +## action links + +sub href(%) { + my %mapping = ( + action => "a", + project => "p", + file_name => "f", + hash => "h", + hash_parent => "hp", + hash_base => "hb", + page => "pg", + searchtext => "s", + ); + + my %params = @_; + $params{"project"} ||= $project; + + my $href = "$my_uri?"; + $href .= esc_param( join(";", + map { "$mapping{$_}=$params{$_}" } keys %params + ) ); + + return $href; +} + + ## ====================================================================== ## validation, quoting/unquoting and escaping -- cgit v1.2.1