Section headers will be optionally displayed when projects dirnames or owner names changes (depending on sort order), making it easier to find projects in large setups. Signed-off-by: Gustavo Sverzut Barbieri <barbieri@xxxxxxxxxxxxxx> --- gitweb/gitweb.css | 7 +++++ gitweb/gitweb.perl | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletions(-) diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index aa0eeca..44abc4c 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -235,6 +235,13 @@ tr.dark:hover { background-color: #edece6; } +tr.section td { + background-color: #d9d8d1; + border-top: 1px solid #000000; + border-left: 1px solid #000000; + font-weight: bold; +} + td { padding: 2px 5px; font-size: 100%; diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c5675cf..c99cea3 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Encode; use Fcntl ':mode'; use File::Find qw(); -use File::Basename qw(basename); +use File::Basename qw(basename dirname); binmode STDOUT, ':utf8'; BEGIN { @@ -82,6 +82,9 @@ our $projects_list_description_width = 25; # valid values are none, project, descr, owner, and age our $default_projects_order = "project"; +# use sections to separate projects by dirname, helps usability +our $use_sections = 1; + # show repository only if this file exists # (only effective if this variable evaluates to true) our $export_ok = "++GITWEB_EXPORT_OK++"; @@ -3631,6 +3634,66 @@ sub print_sort_th_num { print_sort_th(0, @_); } +sub print_section_tr { + my ($n_cols, $section) = @_; + print "<tr class=\"section\"><td colspan=\"$n_cols\">$section</td></tr>\n"; +} + +sub print_section_internal { + my ($order, $n_cols, $current, $getter) = @_; + my $current_value = $getter->($current); + + if (!$current_value) { + return 0; + } + + my $last_value = ''; + if ($current > 0) { + $last_value = $getter->($current - 1); + } + + if ($current_value ne $last_value) { + print_section_tr($n_cols, $current_value); + return 1; + } + + return 0; +} + +sub print_section_project { + my ($order, $n_cols, $current, $projects) = @_; + + sub get_section_project { + my ($index) = @_; + return dirname(@$projects[$index]->{'path'}); + } + + return print_section_internal($order, $n_cols, $current, \&get_section_project); +} + +sub print_section_owner { + my ($order, $n_cols, $current, $projects) = @_; + + sub get_section_owner { + my ($index) = @_; + return @$projects[$index]->{'owner'}; + } + + return print_section_internal($order, $n_cols, $current, \&get_section_owner); +} + +sub print_section { + my ($order, $n_cols, $current, $projects) = @_; + + if ($order eq 'project') { + return print_section_project($order, $n_cols, $current, $projects); + } elsif ($order eq 'owner') { + return print_section_owner($order, $n_cols, $current, $projects); + } + + return 0; +} + sub git_project_list_body { my ($projlist, $order, $from, $to, $extra, $no_header) = @_; @@ -3658,9 +3721,17 @@ sub git_project_list_body { print "<th></th>\n" . # for links "</tr>\n"; } + my $n_cols = $check_forks ? 6 : 5; my $alternate = 1; for (my $i = $from; $i <= $to; $i++) { my $pr = $projects[$i]; + + if ($use_sections) { + if (print_section($order, $n_cols, $i, \@projects)) { + $alternate = 1; + } + } + if ($alternate) { print "<tr class=\"dark\">\n"; } else { -- 1.5.5.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html