{"thread":{"id":"14634","subject":"Gitweb; ordering of fork list on summary page (was Vanilla gitweb vs repo.or.cz)","startedAt":"2008-07-23T17:10:52Z","lastAt":"2008-09-25T16:48:48Z","messageCount":3,"participants":["Mike Ralphson","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84552","messageId":"e2b179460807231010m44ff446auc054ead9178c711b@mail.gmail.com","threadId":"14634","inReplyTo":null,"subject":"Gitweb; ordering of fork list on summary page (was Vanilla gitweb vs repo.or.cz)","fromName":"Mike Ralphson","fromEmail":"mike.ralphson@gmail.com","sentAt":"2008-07-23T17:10:52Z","receivedAt":"2008-07-23T17:10:52Z","isPatch":false,"sender":{"key":"mike.ralphson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/21603?v=4"},"body":"2008/7/13 Petr Baudis <pasky@suse.cz>:\n>  Then, there is the http://repo.or.cz/w/git/gitweb.git repository,\n> which was my old attempt at maintaining gitweb actively. Unfortunately,\n> this didn't quite work out because of my general lack of time and\n> dedication.\n\nNotwithstanding the above, I've pushed a little 'fix' to the mob branch:\n\nhttp://repo.or.cz/w/git/gitweb.git?a=commitdiff;h=3e8f6e9125071a7e17c88efb69c1780d775025bc\n\nThe list of forks on the summary page was unsorted, this just makes\nthem sorted by age, which seems a fair way to decide which forks are\nshown before the list size cut-off (15) kicks in.\n\ns/noheader/no_header was just to make it obvious what the parameter\naffects, so all the code can be found with one grep, and s/undef/'age'\njust shows the intent, although that parameter isn't what actually\ncontrols the sort order. Or, I guess, the sorting could be refactored\nout of the header generation code.\n\nMike\n"},{"id":"298980","messageId":"1222361317-17275-1-git-send-email-pasky@suse.cz","threadId":"14634","inReplyTo":"e2b179460807231010m44ff446auc054ead9178c711b@mail.gmail.com","subject":"[PATCH] gitweb: Clean-up sorting of project list","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-09-25T16:48:37Z","receivedAt":"2008-09-25T16:48:37Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This decouples the sorting of project list and printing the column\nheaders, so that the project list can be easily sorted even when\nthe headers are not shown.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n gitweb/gitweb.perl |   45 ++++++++++++++++++++-------------------------\n 1 files changed, 20 insertions(+), 25 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex da474d0..bd81e14 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3605,19 +3605,13 @@ sub fill_project_list_info {\n \treturn @projects;\n }\n \n-# print 'sort by' <th> element, either sorting by $key if $name eq $order\n-# (changing $list), or generating 'sort by $name' replay link otherwise\n+# print 'sort by' <th> element, generating 'sort by $name' replay link\n+# if that order is not selected\n sub print_sort_th {\n-\tmy ($str_sort, $name, $order, $key, $header, $list) = @_;\n-\t$key    ||= $name;\n+\tmy ($name, $order, $header) = @_;\n \t$header ||= ucfirst($name);\n \n \tif ($order eq $name) {\n-\t\tif ($str_sort) {\n-\t\t\t@$list = sort {$a->{$key} cmp $b->{$key}} @$list;\n-\t\t} else {\n-\t\t\t@$list = sort {$a->{$key} <=> $b->{$key}} @$list;\n-\t\t}\n \t\tprint \"<th>$header</th>\\n\";\n \t} else {\n \t\tprint \"<th>\" .\n@@ -3627,14 +3621,6 @@ sub print_sort_th {\n \t}\n }\n \n-sub print_sort_th_str {\n-\tprint_sort_th(1, @_);\n-}\n-\n-sub print_sort_th_num {\n-\tprint_sort_th(0, @_);\n-}\n-\n sub git_project_list_body {\n \tmy ($projlist, $order, $from, $to, $extra, $no_header) = @_;\n \n@@ -3645,20 +3631,29 @@ sub git_project_list_body {\n \t$from = 0 unless defined $from;\n \t$to = $#projects if (!defined $to || $#projects < $to);\n \n+\tmy %order_info = (\n+\t\tproject => { key => 'path', type => 'str' },\n+\t\tdescr => { key => 'descr_long', type => 'str' },\n+\t\towner => { key => 'owner', type => 'str' },\n+\t\tage => { key => 'age', type => 'num' }\n+\t);\n+\tmy $oi = $order_info{$order};\n+\tif ($oi->{'type'} eq 'str') {\n+\t\t@projects = sort {$a->{$oi->{'key'}} cmp $b->{$oi->{'key'}}} @projects;\n+\t} else {\n+\t\t@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;\n+\t}\n+\n \tprint \"<table class=\\\"project_list\\\">\\n\";\n \tunless ($no_header) {\n \t\tprint \"<tr>\\n\";\n \t\tif ($check_forks) {\n \t\t\tprint \"<th></th>\\n\";\n \t\t}\n-\t\tprint_sort_th_str('project', $order, 'path',\n-\t\t                  'Project', \\@projects);\n-\t\tprint_sort_th_str('descr', $order, 'descr_long',\n-\t\t                  'Description', \\@projects);\n-\t\tprint_sort_th_str('owner', $order, 'owner',\n-\t\t                  'Owner', \\@projects);\n-\t\tprint_sort_th_num('age', $order, 'age',\n-\t\t                  'Last Change', \\@projects);\n+\t\tprint_sort_th('project', $order, 'Project');\n+\t\tprint_sort_th('descr', $order, 'Description');\n+\t\tprint_sort_th('owner', $order, 'Owner');\n+\t\tprint_sort_th('age', $order, 'Last Change');\n \t\tprint \"<th></th>\\n\" . # for links\n \t\t      \"</tr>\\n\";\n \t}\n-- \ntg: (c427559..) t/forks/sort-refactor (depends on: vanilla/master)\n"},{"id":"298981","messageId":"1222361328-17368-1-git-send-email-pasky@suse.cz","threadId":"14634","inReplyTo":"1222361317-17275-1-git-send-email-pasky@suse.cz","subject":"[PATCH] gitweb: Sort the list of forks on the summary page by age","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-09-25T16:48:48Z","receivedAt":"2008-09-25T16:48:48Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"From: Petr Baudis <pasky@suse.cz>\n\nFrom: Mike Ralphson <mike@abacus.co.uk>\n\nThe list of forks on the summary page was unsorted, this just makes\nthem sorted by age, which seems a fair way to decide which forks are\nshown before the list size cut-off (15) kicks in.\n\ns/noheader/no_header was just to make it obvious what the parameter\naffects, so all the code can be found with one grep.\n\npb: As suggested by Mike, I have augmented this by an additional patch\nthat refactors the sorting logic so that it is not tied to printing\nthe headers.\n\nSigned-off-by: Mike Ralphson <mike@abacus.co.uk>\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n gitweb/gitweb.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex bd81e14..0f8a564 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4119,10 +4119,10 @@ sub git_summary {\n \n \tif (@forklist) {\n \t\tgit_print_header_div('forks');\n-\t\tgit_project_list_body(\\@forklist, undef, 0, 15,\n+\t\tgit_project_list_body(\\@forklist, 'age', 0, 15,\n \t\t                      $#forklist <= 15 ? undef :\n \t\t                      $cgi->a({-href => href(action=>\"forks\")}, \"...\"),\n-\t\t                      'noheader');\n+\t\t                      'no_header');\n \t}\n \n \tgit_footer_html();\n-- \ntg: (513dad1..) t/forks/sort-by-age (depends on: t/forks/sort-refactor)\n"}]}