Skip to content

Commit a1565c4

Browse files
jnarebJunio C Hamano
authored andcommitted
gitweb: Allow for href() to be used for links without project param
Make it possible to use href() subroutine to generate link with query string which does not include project ('p') parameter. href() used to add project=$project to its parameters, if it was not set (to be more exact if $params{'project'} was false). Now you can pass "project => undef" if you don't want for href() to add project parameter to query string in the generated link. Links to "project_list", "project_index" and "opml" (all related to list of all projects/all git repositories) doesn't need project parameter. Moreover "project_list" is default view (action) if project ('p') parameter is not set, just like "summary" is default view (action) if project is set; project list served as a kind of "home" page for gitweb instalation, and links to "project_list" view were done without specyfying it as an action. Convert remaining links (except $home_link and anchor links) to use href(); this required adding 'order => "o"' to @mapping in href(). This finishes consolidation of URL generation. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d0c2449 commit a1565c4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

gitweb/gitweb.perl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,12 @@ (%)
326326
hash_base => "hb",
327327
hash_parent_base => "hpb",
328328
page => "pg",
329+
order => "o",
329330
searchtext => "s",
330331
);
331332
my %mapping = @mapping;
332333

333-
$params{"project"} ||= $project;
334+
$params{'project'} = $project unless exists $params{'project'};
334335

335336
my @result = ();
336337
for (my $i = 0; $i < @mapping; $i += 2) {
@@ -1304,9 +1305,11 @@ sub git_footer_html {
13041305
if (defined $descr) {
13051306
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
13061307
}
1307-
print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
1308+
print $cgi->a({-href => href(action=>"rss"),
1309+
-class => "rss_logo"}, "RSS") . "\n";
13081310
} else {
1309-
print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
1311+
print $cgi->a({-href => href(project=>undef, action=>"opml"),
1312+
-class => "rss_logo"}, "OPML") . "\n";
13101313
}
13111314
print "</div>\n" .
13121315
"</body>\n" .
@@ -2153,7 +2156,7 @@ sub git_project_list {
21532156
print "<th>Project</th>\n";
21542157
} else {
21552158
print "<th>" .
2156-
$cgi->a({-href => "$my_uri?" . esc_param("o=project"),
2159+
$cgi->a({-href => href(project=>undef, order=>'project'),
21572160
-class => "header"}, "Project") .
21582161
"</th>\n";
21592162
}
@@ -2162,7 +2165,7 @@ sub git_project_list {
21622165
print "<th>Description</th>\n";
21632166
} else {
21642167
print "<th>" .
2165-
$cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
2168+
$cgi->a({-href => href(project=>undef, order=>'descr'),
21662169
-class => "header"}, "Description") .
21672170
"</th>\n";
21682171
}
@@ -2171,7 +2174,7 @@ sub git_project_list {
21712174
print "<th>Owner</th>\n";
21722175
} else {
21732176
print "<th>" .
2174-
$cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
2177+
$cgi->a({-href => href(project=>undef, order=>'owner'),
21752178
-class => "header"}, "Owner") .
21762179
"</th>\n";
21772180
}
@@ -2180,7 +2183,7 @@ sub git_project_list {
21802183
print "<th>Last Change</th>\n";
21812184
} else {
21822185
print "<th>" .
2183-
$cgi->a({-href => "$my_uri?" . esc_param("o=age"),
2186+
$cgi->a({-href => href(project=>undef, order=>'age'),
21842187
-class => "header"}, "Last Change") .
21852188
"</th>\n";
21862189
}

0 commit comments

Comments
 (0)