git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 6/7] gitweb: Sort query string parameters in href() function
Date: Thu, 17 Aug 2006 11:21:27 +0200	[thread overview]
Message-ID: <1155806489764-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <11558064883957-git-send-email-jnareb@gmail.com>

Introduction of a href() function to generate an URL for the CGI,
while making it easier to change the encoding of actions into URLs,
changed also the ordering of parameters in query string, and in URL.

This patch tries to bring back old ordering of query string
parameters. Probably it is not worth the cost; this is an RFC.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b3f38bf..d132aab 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -197,8 +197,29 @@ sub href(%) {
 		hash_base => "hb",
 		page => "pg",
 		searchtext => "s",
+		order => "o",
 	);
 
+	my %ordering = (
+		project => 0,
+		action => 1,
+		order => 2,
+		hash => 10,
+		hash_parent => 11,
+		hash_base => 12,
+		page => 20,
+		file_name => 21,
+		searchtext => 22,
+	);
+
+	sub byordering ($$) {
+		if (exists $ordering{$_[0]} && exists $ordering{$_[1]}) {
+			return $ordering{$_[0]} <=> $ordering{$_[1]};
+		} else {
+			return $_[0] cmp $_[1];
+		}
+	}
+
 	my %params = @_;
 	$params{"project"} ||= $project;
 
@@ -210,7 +231,7 @@ sub href(%) {
 			} else {
 				"$_=$params{$_}";
 			}
-		} keys %params ) );
+		} sort byordering keys %params ) );
 
 	return $href;
 }
-- 
1.4.1.1

  parent reply	other threads:[~2006-08-17  9:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17  9:21 [PATCH 0/7] A few gitweb cleanups and improvements Jakub Narebski
2006-08-17  9:21 ` [PATCH 1/7] gitweb: Add support for per project git URLs Jakub Narebski
2006-08-17 18:58   ` David Rientjes
2006-08-17  9:21 ` [PATCH 2/7] gitweb: Refactor printing commit message Jakub Narebski
2006-08-17  9:21 ` [PATCH 3/7] gitweb: Fix typo in separation of git_difftree_body Jakub Narebski
2006-08-17  9:21 ` [PATCH 4/7] gitweb: Expand href() function to use key as param name for no mapping Jakub Narebski
2006-08-17  9:58   ` Junio C Hamano
2006-08-17 10:08     ` Jakub Narebski
2006-08-17  9:21 ` [PATCH 5/7] gitweb: Added parse_difftree_raw_line function for later use Jakub Narebski
2006-08-17  9:55   ` Junio C Hamano
2006-08-17  9:21 ` Jakub Narebski [this message]
2006-08-17  9:21 ` [PATCH 7/7] gitweb: Uniquify version info output, add meta generator in page header Jakub Narebski

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=1155806489764-git-send-email-jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --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).