@matheusbsbs / matheus-bagliano / commits / a1565c447d
Fork 0

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>

Jakub Narebski committed Sep 15, 2006 at 19:30 UTC a1565c447d441234e227fa6881d26eaf227367e3
1 file changed +10 -7
gitweb/gitweb.perl
+10 -7
@@ -326,11 +326,12 @@ sub href(%) {
326 hash_base => "hb",
327 hash_parent_base => "hpb",
328 page => "pg",
329 + order => "o",
330 searchtext => "s",
331 );
332 my %mapping = @mapping;
333
333 - $params{"project"} ||= $project;
334 + $params{'project'} = $project unless exists $params{'project'};
335
336 my @result = ();
337 for (my $i = 0; $i < @mapping; $i += 2) {
@@ -1304,9 +1305,11 @@ sub git_footer_html {
1305 if (defined $descr) {
1306 print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
1307 }
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";
1310 } 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";
1313 }
1314 print "</div>\n" .
1315 "</body>\n" .
@@ -2153,7 +2156,7 @@ sub git_project_list {
2156 print "<th>Project</th>\n";
2157 } else {
2158 print "<th>" .
2156 - $cgi->a({-href => "$my_uri?" . esc_param("o=project"),
2159 + $cgi->a({-href => href(project=>undef, order=>'project'),
2160 -class => "header"}, "Project") .
2161 "</th>\n";
2162 }
@@ -2162,7 +2165,7 @@ sub git_project_list {
2165 print "<th>Description</th>\n";
2166 } else {
2167 print "<th>" .
2165 - $cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
2168 + $cgi->a({-href => href(project=>undef, order=>'descr'),
2169 -class => "header"}, "Description") .
2170 "</th>\n";
2171 }
@@ -2171,7 +2174,7 @@ sub git_project_list {
2174 print "<th>Owner</th>\n";
2175 } else {
2176 print "<th>" .
2174 - $cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
2177 + $cgi->a({-href => href(project=>undef, order=>'owner'),
2178 -class => "header"}, "Owner") .
2179 "</th>\n";
2180 }
@@ -2180,7 +2183,7 @@ sub git_project_list {
2183 print "<th>Last Change</th>\n";
2184 } else {
2185 print "<th>" .
2183 - $cgi->a({-href => "$my_uri?" . esc_param("o=age"),
2186 + $cgi->a({-href => href(project=>undef, order=>'age'),
2187 -class => "header"}, "Last Change") .
2188 "</th>\n";
2189 }