mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
gitweb: Split git_project_list_body in two functions
Extract the printing of project rows (body/contents of projects list table) on the 'project_list' page into a separate git_project_list_rows function. This makes it easier to reuse the code to print different subsets of the whole project list. [jn: Updated to post restructuring projects list generation] Signed-off-by: Sebastien Cevey <seb@cine7.net> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4b9447f98e
commit
0fa920c35c
@ -4946,6 +4946,55 @@ sub format_sort_th {
|
||||
return $sort_th;
|
||||
}
|
||||
|
||||
sub git_project_list_rows {
|
||||
my ($projlist, $from, $to, $check_forks) = @_;
|
||||
|
||||
$from = 0 unless defined $from;
|
||||
$to = $#$projlist if (!defined $to || $#$projlist < $to);
|
||||
|
||||
my $alternate = 1;
|
||||
for (my $i = $from; $i <= $to; $i++) {
|
||||
my $pr = $projlist->[$i];
|
||||
|
||||
if ($alternate) {
|
||||
print "<tr class=\"dark\">\n";
|
||||
} else {
|
||||
print "<tr class=\"light\">\n";
|
||||
}
|
||||
$alternate ^= 1;
|
||||
|
||||
if ($check_forks) {
|
||||
print "<td>";
|
||||
if ($pr->{'forks'}) {
|
||||
my $nforks = scalar @{$pr->{'forks'}};
|
||||
if ($nforks > 0) {
|
||||
print $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks"),
|
||||
-title => "$nforks forks"}, "+");
|
||||
} else {
|
||||
print $cgi->span({-title => "$nforks forks"}, "+");
|
||||
}
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
|
||||
-class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
|
||||
"<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
|
||||
-class => "list", -title => $pr->{'descr_long'}},
|
||||
esc_html($pr->{'descr'})) . "</td>\n" .
|
||||
"<td><i>" . chop_and_escape_str($pr->{'owner'}, 15) . "</i></td>\n";
|
||||
print "<td class=\"". age_class($pr->{'age'}) . "\">" .
|
||||
(defined $pr->{'age_string'} ? $pr->{'age_string'} : "No commits") . "</td>\n" .
|
||||
"<td class=\"link\">" .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") .
|
||||
($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') .
|
||||
"</td>\n" .
|
||||
"</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub git_project_list_body {
|
||||
# actually uses global variable $project
|
||||
my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
|
||||
@ -5001,47 +5050,9 @@ sub git_project_list_body {
|
||||
print "<th></th>\n" . # for links
|
||||
"</tr>\n";
|
||||
}
|
||||
my $alternate = 1;
|
||||
for (my $i = $from; $i <= $to; $i++) {
|
||||
my $pr = $projects[$i];
|
||||
|
||||
if ($alternate) {
|
||||
print "<tr class=\"dark\">\n";
|
||||
} else {
|
||||
print "<tr class=\"light\">\n";
|
||||
}
|
||||
$alternate ^= 1;
|
||||
git_project_list_rows(\@projects, $from, $to, $check_forks);
|
||||
|
||||
if ($check_forks) {
|
||||
print "<td>";
|
||||
if ($pr->{'forks'}) {
|
||||
my $nforks = scalar @{$pr->{'forks'}};
|
||||
if ($nforks > 0) {
|
||||
print $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks"),
|
||||
-title => "$nforks forks"}, "+");
|
||||
} else {
|
||||
print $cgi->span({-title => "$nforks forks"}, "+");
|
||||
}
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
|
||||
-class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
|
||||
"<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
|
||||
-class => "list", -title => $pr->{'descr_long'}},
|
||||
esc_html($pr->{'descr'})) . "</td>\n" .
|
||||
"<td><i>" . chop_and_escape_str($pr->{'owner'}, 15) . "</i></td>\n";
|
||||
print "<td class=\"". age_class($pr->{'age'}) . "\">" .
|
||||
(defined $pr->{'age_string'} ? $pr->{'age_string'} : "No commits") . "</td>\n" .
|
||||
"<td class=\"link\">" .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " .
|
||||
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") .
|
||||
($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') .
|
||||
"</td>\n" .
|
||||
"</tr>\n";
|
||||
}
|
||||
if (defined $extra) {
|
||||
print "<tr>\n";
|
||||
if ($check_forks) {
|
||||
|
Loading…
Reference in New Issue
Block a user