[PATCH] gitweb: provide function to format the URL for an action link.

From: Martin Waitz <tali@admingilde.org>
Date: 2006-08-16 08:23:50
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 <tali@admingilde.org>
---
 gitweb/gitweb.perl |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b5b89de..726dd66 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -181,6 +181,33 @@ if (!defined($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
 
 sub validate_input {
-- 
1.4.2.rc2.gf055

-- 
Martin Waitz

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Received on Wed Aug 16 08:24:30 2006

This archive was generated by hypermail 2.1.8 : 2006-08-16 08:25:15 EST