The following two patches will add sections to gitweb so usability is
improved for large project listing. It looks like:
http://staff.get-e.org/
but it's a new code that also supports owner sort.
Patches orverview:
* [PATCH 1/2] gitweb: sort projects by path.
This one is required to fix project sort. Since we use paths, we
should compare individual components to make it look like a
tree. Since we now can enable sections this error will be more
evident, so there is the fix.
* [PATCH 2/2] gitweb: add section support to gitweb project listing.
The real section work. This will add use_sections variable and if
it evaluates to true sections will be enabled. Just project and
owner sections are implemented.
I hope it looks good for inclusion. Last time I did perl was about 8
years ago, please point any problems and I'll fix them.
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Projects are paths, so they should be sorted in pieces, not as a
whole, so a/x will be come before a-b/x.
Signed-off-by: Gustavo Sverzut Barbieri <redacted>
---
gitweb/gitweb.perl | 37 ++++++++++++++++++++++++++++++++-----
1 files changed, 32 insertions(+), 5 deletions(-)
@@ -3574,17 +3574,40 @@ sub fill_project_list_info {return@projects;}+subcmp_paths{+my($a,$b)=@_;+my@la=split('/',$a);+my@lb=split('/',$b);+my$last;++if($#la<$#lb){+$last=$#la;+}else{+$last=$#lb;+}++for(my$i=0;$i<$last;$i++){+if($la[$i]gt$lb[$i]){+return1;+}+}++return$#la<=>$#lb;+}+# print 'sort by' <th> element, either sorting by $key if $name eq $order# (changing $list), or generating 'sort by $name' replay link otherwisesubprint_sort_th{-my($str_sort,$name,$order,$key,$header,$list)=@_;+my($sort_mode,$name,$order,$key,$header,$list)=@_;$key||=$name;$header||=ucfirst($name);if($ordereq$name){-if($str_sort){+if($sort_mode==2){+@$list=sort{cmp_paths($a->{$key},$b->{$key})}@$list;+}elsif($sort_mode==1){@$list=sort{$a->{$key}cmp$b->{$key}}@$list;-}else{+}elsif($sort_mode==0){@$list=sort{$a->{$key}<=>$b->{$key}}@$list;}print"<th>$header</th>\n";
@@ -3596,6 +3619,10 @@ sub print_sort_th {}}+subprint_sort_th_path{+print_sort_th(2,@_);+}+subprint_sort_th_str{print_sort_th(1,@_);}
@@ -3620,8 +3647,8 @@ sub git_project_list_body {if($check_forks){print"<th></th>\n";}-print_sort_th_str('project',$order,'path',-'Project',\@projects);+print_sort_th_path('project',$order,'path',+'Project',\@projects);print_sort_th_str('descr',$order,'descr_long','Description',\@projects);print_sort_th_str('owner',$order,'owner',
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 <redacted>
---
gitweb/gitweb.css | 7 +++++
gitweb/gitweb.perl | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 79 insertions(+), 1 deletions(-)
@@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser);useEncode;useFcntl':mode';useFile::Findqw();-useFile::Basenameqw(basename);+useFile::Basenameqw(basename dirname);binmodeSTDOUT,':utf8';BEGIN{
@@ -82,6 +82,9 @@ our $projects_list_description_width = 25;# valid values are none, project, descr, owner, and ageour$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,@_);}+subprint_section_tr{+my($n_cols,$section)=@_;+print"<tr class=\"section\"><td colspan=\"$n_cols\">$section</td></tr>\n";+}++subprint_section_internal{+my($order,$n_cols,$current,$getter)=@_;+my$current_value=$getter->($current);++if(!$current_value){+return0;+}++my$last_value='';+if($current>0){+$last_value=$getter->($current-1);+}++if($current_valuene$last_value){+print_section_tr($n_cols,$current_value);+return1;+}++return0;+}++subprint_section_project{+my($order,$n_cols,$current,$projects)=@_;++subget_section_project{+my($index)=@_;+returndirname(@$projects[$index]->{'path'});+}++returnprint_section_internal($order,$n_cols,$current,\&get_section_project);+}++subprint_section_owner{+my($order,$n_cols,$current,$projects)=@_;++subget_section_owner{+my($index)=@_;+return@$projects[$index]->{'owner'};+}++returnprint_section_internal($order,$n_cols,$current,\&get_section_owner);+}++subprint_section{+my($order,$n_cols,$current,$projects)=@_;++if($ordereq'project'){+returnprint_section_project($order,$n_cols,$current,$projects);+}elsif($ordereq'owner'){+returnprint_section_owner($order,$n_cols,$current,$projects);+}++return0;+}+subgit_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{
Projects are paths, so they should be sorted in pieces, not as a
whole, so a/x will be come before a-b/x.
Signed-off-by: Gustavo Sverzut Barbieri <redacted>
---
New version that fix cmp_paths. Unlike I though initially, $#list
reports the last element index, not the list length. Nonetheless the
last component must be compared only if the list lengths are the same,
otherwise we'll get $root/a/a.git before $root/b.git and sections will
look ugly (group elements of the same level together).
gitweb/gitweb.perl | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
@@ -3574,17 +3574,45 @@ sub fill_project_list_info {return@projects;}+subcmp_paths{+my($a,$b)=@_;+my@la=split('/',$a);+my@lb=split('/',$b);+my$last;++if($#la<$#lb){+$last=$#la;+}else{+$last=$#lb;+}++for(my$i=0;$i<$last;$i++){+my$r=$la[$i]cmp$lb[$i];+if($r!=0){+return$r;+}+}++if($#la==$#lb){+return$la[$last]cmp$lb[$last];+}else{+return$#la<=>$#lb;+}+}+# print 'sort by' <th> element, either sorting by $key if $name eq $order# (changing $list), or generating 'sort by $name' replay link otherwisesubprint_sort_th{-my($str_sort,$name,$order,$key,$header,$list)=@_;+my($sort_mode,$name,$order,$key,$header,$list)=@_;$key||=$name;$header||=ucfirst($name);if($ordereq$name){-if($str_sort){+if($sort_mode==2){+@$list=sort{cmp_paths($a->{$key},$b->{$key})}@$list;+}elsif($sort_mode==1){@$list=sort{$a->{$key}cmp$b->{$key}}@$list;-}else{+}elsif($sort_mode==0){@$list=sort{$a->{$key}<=>$b->{$key}}@$list;}print"<th>$header</th>\n";
@@ -3596,6 +3624,10 @@ sub print_sort_th {}}+subprint_sort_th_path{+print_sort_th(2,@_);+}+subprint_sort_th_str{print_sort_th(1,@_);}
@@ -3620,8 +3652,8 @@ sub git_project_list_body {if($check_forks){print"<th></th>\n";}-print_sort_th_str('project',$order,'path',-'Project',\@projects);+print_sort_th_path('project',$order,'path',+'Project',\@projects);print_sort_th_str('descr',$order,'descr_long','Description',\@projects);print_sort_th_str('owner',$order,'owner',
Since nobody replied and I missed some gitweb guys in CC, I'm adding
Petr and Jakub, as some guys said on IRC.
Have anyone tried this patch, any problems?
On Mon, Jul 28, 2008 at 11:34 PM, Gustavo Sverzut Barbieri
[off-list ref] wrote:
The following two patches will add sections to gitweb so usability is
improved for large project listing. It looks like:
http://staff.get-e.org/
but it's a new code that also supports owner sort.
Patches orverview:
* [PATCH 1/2] gitweb: sort projects by path.
This one is required to fix project sort. Since we use paths, we
should compare individual components to make it look like a
tree. Since we now can enable sections this error will be more
evident, so there is the fix.
* [PATCH 2/2] gitweb: add section support to gitweb project listing.
The real section work. This will add use_sections variable and if
it evaluates to true sections will be enabled. Just project and
owner sections are implemented.
I hope it looks good for inclusion. Last time I did perl was about 8
years ago, please point any problems and I'll fix them.
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
From: Petr Baudis <hidden> Date: 2016-06-15 22:45:05
Hi,
On Thu, Jul 31, 2008 at 04:43:35PM -0300, Gustavo Sverzut Barbieri wrote:
Since nobody replied and I missed some gitweb guys in CC, I'm adding
Petr and Jakub, as some guys said on IRC.
Have anyone tried this patch, any problems?
sorry, I have it in my review queue. At first pass it was looking
good, but I wanted to look at it better before commenting.
One thing I'm wondering about is how to make this stuff configurable,
since I'm not very comfortable with adding more "unbound" configuration
variables and would rather prefer stuff to be added to the $features
array... I'm not at all sure about my own sentiment here, however.
--
Petr "Pasky" Baudis
As in certain cults it is possible to kill a process if you know
its true name. -- Ken Thompson and Dennis M. Ritchie
On Thu, Jul 31, 2008 at 5:32 PM, Petr Baudis [off-list ref] wrote:
Hi,
On Thu, Jul 31, 2008 at 04:43:35PM -0300, Gustavo Sverzut Barbieri wrote:
quoted
Since nobody replied and I missed some gitweb guys in CC, I'm adding
Petr and Jakub, as some guys said on IRC.
Have anyone tried this patch, any problems?
sorry, I have it in my review queue. At first pass it was looking
good, but I wanted to look at it better before commenting.
no problem, just to see it was noticed or not :-)
One thing I'm wondering about is how to make this stuff configurable,
since I'm not very comfortable with adding more "unbound" configuration
variables and would rather prefer stuff to be added to the $features
array... I'm not at all sure about my own sentiment here, however.
Path comparison (first patch), Sections (second), both?
I know path comparison can be a performance hit on large listings on
sites with heavy traffic. However, I don't see many people accessing
the projects page at the same time for long periods, it's not like
slashdot... people mostly use it to know about repositories and then
use git to track it.
The slowness is due O(n^2) worst case of sort and each step is not
a bit heavier since it need to split path into components and walk
these. Maybe cache the split?
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Yet another "ping" on this topic, news?
On Thu, Jul 31, 2008 at 5:58 PM, Gustavo Sverzut Barbieri
[off-list ref] wrote:
On Thu, Jul 31, 2008 at 5:32 PM, Petr Baudis [off-list ref] wrote:
quoted
Hi,
On Thu, Jul 31, 2008 at 04:43:35PM -0300, Gustavo Sverzut Barbieri wrote:
quoted
Since nobody replied and I missed some gitweb guys in CC, I'm adding
Petr and Jakub, as some guys said on IRC.
Have anyone tried this patch, any problems?
sorry, I have it in my review queue. At first pass it was looking
good, but I wanted to look at it better before commenting.
no problem, just to see it was noticed or not :-)
quoted
One thing I'm wondering about is how to make this stuff configurable,
since I'm not very comfortable with adding more "unbound" configuration
variables and would rather prefer stuff to be added to the $features
array... I'm not at all sure about my own sentiment here, however.
Path comparison (first patch), Sections (second), both?
I know path comparison can be a performance hit on large listings on
sites with heavy traffic. However, I don't see many people accessing
the projects page at the same time for long periods, it's not like
slashdot... people mostly use it to know about repositories and then
use git to track it.
The slowness is due O(n^2) worst case of sort and each step is not
a bit heavier since it need to split path into components and walk
these. Maybe cache the split?
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202