[FFmpeg-devel] [PATCH 4/5] [FATESERVER] index: use one parameter "sort" for both ascending and descending sorting

Timothy Gu timothygu99 at gmail.com
Sun Jun 1 01:45:49 CEST 2014


Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
---
 index.cgi | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/index.cgi b/index.cgi
index d6a0a38..2246920 100755
--- a/index.cgi
+++ b/index.cgi
@@ -80,8 +80,8 @@ $allfail = 100 * $allfail / @reps;
 my $warn = 100 - $allpass - $allfail;
 
 my @sort = ('subarch', 'os', 'cc', 'comment', 'slot');
-my $sort = param('asort') || param('dsort');
-my $sdir = param('dsort') ? -1 : 1;
+my $sort = param('sort');
+my $sdir = 1; # default to ascending sorting
 defined $sort and unshift @sort, $sort eq 'arch'? 'subarch': $sort;
 $sort ||= $sort[0];
 
@@ -93,6 +93,10 @@ sub nscmp {
 sub repcmp {
     my $r;
     for my $s (@sort) {
+        if ($s =~ /desc/) {
+            $s =~ s/desc//;
+            $sdir = -1;
+        }
         last if $r = $sdir * nscmp $$a{$s}, $$b{$s};
     }
     return $r;
@@ -101,14 +105,17 @@ sub repcmp {
 sub lsort {
     my $params = join '&', map param($_), grep $_ !~ 'sort', param;
     $params .= '&' if $params;
-    my ($text, $key, $p) = @_;
-    if ($sort eq $key) {
-        $p = param('asort') ? 'dsort' : 'asort';
-    }
-    if (!$p) {
-        $p = 'asort';
+    my ($text, $key) = @_;
+
+    if ($sort eq $key) {                           # $sort = $key
+        if ($key =~ /desc/) {                      # $sort = desc*
+            $key =~ s/desc//;
+        } else {                                   # $sort = *
+            $key = "desc$key";
+        }
     }
-    anchor $text, href => "$uri?$params$p=$key";
+
+    anchor $text, href => "$uri?${params}sort=$key";
 }
 
 sub category {
@@ -206,7 +213,7 @@ span ' ', class => 'fail', style => "width: ${allfail}%" if $allfail;
 end 'td';
 end 'tr';
 start 'tr';
-start 'th'; lsort 'Time',     'date', 'dsort'; end 'th';
+start 'th'; lsort 'Time',     'descdate';      end 'th';
 start 'th'; lsort 'Rev',      'rev';           end 'th';
 start 'th'; lsort 'Arch',     'arch';          end 'th';
 start 'th'; lsort 'OS',       'os';            end 'th';
-- 
1.9.1



More information about the ffmpeg-devel mailing list