git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Waitz <tali@admingilde.org>
To: git@vger.kernel.org
Subject: [PATCH] gitweb: provide function to format the URL for an action link.
Date: Wed, 16 Aug 2006 00:23:50 +0200	[thread overview]
Message-ID: <20060815222350.GC14459@admingilde.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

                 reply	other threads:[~2006-08-15 22:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060815222350.GC14459@admingilde.org \
    --to=tali@admingilde.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).