summaryrefslogtreecommitdiffstats
path: root/gitweb/gitweb.perl
diff options
context:
space:
mode:
authorMartin Waitz <tali@admingilde.org>2006-08-16 00:23:50 +0200
committerJunio C Hamano <junkio@cox.net>2006-08-16 06:55:17 +0200
commit06a9d86b49b826562e2b12b5c7e831e20b8f7dce (patch)
tree93eb4d2bca6128dd8e1851eb72c7a2056bb738f0 /gitweb/gitweb.perl
parentgitweb: Show project's git URL on summary page (diff)
downloadgit-06a9d86b49b826562e2b12b5c7e831e20b8f7dce.tar.xz
git-06a9d86b49b826562e2b12b5c7e831e20b8f7dce.zip
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 <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to '')
-rwxr-xr-xgitweb/gitweb.perl27
1 files changed, 27 insertions, 0 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0e1de297e9..1471d4dadb 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -185,6 +185,33 @@ $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 {