Skip to contentSkip to conversation

gitweb: make search form generate pathinfo-style URLs

PATCH In review Matt McCutchen 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: make search form generate pathinfo-style URLs

The search form generated traditional-style URLs with a "p=" parameter even when the pathinfo feature was on. This patch makes it generate pathinfo-style URLs when appropriate.

---
 gitweb/gitweb.perl |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +9 -3
index f36428e..7b0e110 100755
@@ -2215,12 +2215,18 @@ EOF
 		} else {
 			$search_hash = "HEAD";
 		}
+		my $action = $my_uri;
+		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		if ($use_pathinfo) {
+			$action .= "/$project";
+		} else {
+			$cgi->param("p", $project);
+		}
 		$cgi->param("a", "search");
 		$cgi->param("h", $search_hash);
-		$cgi->param("p", $project);
-		print $cgi->startform(-method => "get", -action => $my_uri) .
+		print $cgi->startform(-method => "get", -action => $action) .
 		      "<div class=\"search\">\n" .
-		      $cgi->hidden(-name => "p") . "\n" .
+		      (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .
 		      $cgi->hidden(-name => "a") . "\n" .
 		      $cgi->hidden(-name => "h") . "\n" .
 		      $cgi->popup_menu(-name => 'st', -default => 'commit',
Signature · 1 line
1.5.2.2.552.gc32f
#1 lore raw
Quoted 3 lines · Matt McCutchen

The search form generated traditional-style URLs with a "p=" parameter even when the pathinfo feature was on. This patch makes it generate pathinfo-style URLs when appropriate.

I sent this patch four days ago but no one has commented or done anything about it. Please clue me in: is this typical, or did I do something wrong or do I need to do something else?

Thanks,
Matt

#2 lore raw
Quoted 3 lines · Matt McCutchen

I sent this patch four days ago but no one has commented or done anything about it. Please clue me in: is this typical, or did I do something wrong or do I need to do something else?

Yes, it sometimes happens to patches to some areas. No, you did not do anything wrong as far as I can see. Yes, sending this kind of reminder out is exactly what is needed.

I have three recent patches from you on gitweb in my patch queue.

Subject: [PATCH] gitweb: snapshot cleanups & support for offering multiple
formats
Date: Thu, 28 Jun 2007 14:02:13 -0400
Message-ID: <1183053733.6108.0.camel@mattlaptop2>

Subject: [PATCH] gitweb: make search form generate pathinfo-style URLs
Date: Thu, 28 Jun 2007 14:57:07 -0400
Message-ID: <1183057027.6108.4.camel@mattlaptop2>

Subject: [PATCH] gitweb: make "No commits" in project list gray, not bold
green
Date: Thu, 28 Jun 2007 18:15:22 -0400
Message-ID: <1183068922.6108.8.camel@mattlaptop2>

There are people whom I consider "gitweb folks", who are more familiar with, and more importantly who are more interested in, gitweb than I am. Having good "subsystem people" makes gitweb a lower-priority area to myself, and for these patches it made even so that nobody commented on them.

I should have asked Ack/Nack/Comments from gitweb folks much earlier, but was a bit too loaded with the day job. Sorry about that.

So, gitweb folks, what do you think about these patches?

#3 lore raw
In reply to Matt McCutchen
Quoted 22 lines · Matt McCutchen

The search form generated traditional-style URLs with a "p=" parameter even when the pathinfo feature was on. This patch makes it generate pathinfo-style URLs when appropriate.

---
 gitweb/gitweb.perl |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +5 -0
index f36428e..7b0e110 100755
@@ -2215,12 +2215,18 @@ EOF
 		} else {
 			$search_hash = "HEAD";
 		}
+		my $action = $my_uri;
+		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		if ($use_pathinfo) {
+			$action .= "/$project";
+		} else {

gitweb/gitweb.perl EOF · line 2229

Quoted 10 lines
gitweb/gitweb.perl +4 -3
+			$cgi->param("p", $project);
+		}
 		$cgi->param("a", "search");
 		$cgi->param("h", $search_hash);
-		$cgi->param("p", $project);
-		print $cgi->startform(-method => "get", -action => $my_uri) .
+		print $cgi->startform(-method => "get", -action => $action) .
 		      "<div class=\"search\">\n" .
-		      $cgi->hidden(-name => "p") . "\n" .
+		      (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .

Ahhhhh. (!$use_pathinfo && blah) when $use_pathinfo is true evaluates to an empty string, which saves you from protecting yourself from undef. Perhaps clever, but is not terribly nice.

Other than that, the patch looks sane to me.

#4 lore raw
Quoted 39 lines · --- Junio C Hamano
Quoted 22 lines · Matt McCutchen

The search form generated traditional-style URLs with a "p=" parameter even when the pathinfo feature was on. This patch makes it generate pathinfo-style URLs when appropriate.

---
 gitweb/gitweb.perl |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +5 -0
index f36428e..7b0e110 100755
@@ -2215,12 +2215,18 @@ EOF
 		} else {
 			$search_hash = "HEAD";
 		}
+		my $action = $my_uri;
+		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		if ($use_pathinfo) {
+			$action .= "/$project";
+		} else {

gitweb/gitweb.perl EOF · line 2229

Quoted 10 lines
gitweb/gitweb.perl +4 -3
+			$cgi->param("p", $project);
+		}
 		$cgi->param("a", "search");
 		$cgi->param("h", $search_hash);
-		$cgi->param("p", $project);
-		print $cgi->startform(-method => "get", -action => $my_uri) .
+		print $cgi->startform(-method => "get", -action => $action) .
 		      "<div class=\"search\">\n" .
-		      $cgi->hidden(-name => "p") . "\n" .
+		      (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .

Ahhhhh. (!$use_pathinfo && blah) when $use_pathinfo is true evaluates to an empty string, which saves you from protecting yourself from undef. Perhaps clever, but is not terribly nice.

Quoted 1 line

Other than that, the patch looks sane to me.

Good catch.

Luben