incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1164747 - /incubator/ooo/site/trunk/lib/view.pm
Date Fri, 02 Sep 2011 22:28:41 GMT
Author: joes
Date: Fri Sep  2 22:28:40 2011
New Revision: 1164747

URL: http://svn.apache.org/viewvc?rev=1164747&view=rev
Log:
sort_tables is exported by ASF::Util now

Modified:
    incubator/ooo/site/trunk/lib/view.pm

Modified: incubator/ooo/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/incubator/ooo/site/trunk/lib/view.pm?rev=1164747&r1=1164746&r2=1164747&view=diff
==============================================================================
--- incubator/ooo/site/trunk/lib/view.pm (original)
+++ incubator/ooo/site/trunk/lib/view.pm Fri Sep  2 22:28:40 2011
@@ -11,7 +11,7 @@ use strict;
 use warnings;
 use Dotiac::DTL qw/Template *TEMPLATE_DIRS/;
 use Dotiac::DTL::Addon::markup;
-use ASF::Util qw/read_text_file shuffle/;
+use ASF::Util qw/read_text_file shuffle sort_tables/;
 use File::Temp qw/tempfile/;
 use LWP::Simple;
 
@@ -143,49 +143,6 @@ sub breadcrumbs {
     return join " &raquo ", @rv;
 }
 
-# arbitrary number of tables supported, but only one col per table may be sorted
-
-sub sort_tables {
-    my @orig = split /\n/, shift, -1;
-    my @out;
-    while (defined(local $_ = shift @orig))  {
-        push @out, $_;
-        /^(\|[ :vn^-]+)+\|$/ or next;
-        my($data, $col, $direction, $cur, $numeric);
-        $cur = 0;
-        while (/\|([ :vn^-]+)/g) {
-            $data = $1;
-            if ($data =~ tr/v/v/) {
-                $col = $cur;
-                $direction = -1;
-                last;
-            }
-            elsif ($data =~ tr/^/^/) {
-                $col = $cur;
-                $direction = 1;
-                last;
-            }
-            $cur++;
-        }
-        unless (defined $col) {
-            push @out, shift @orig while @orig and $orig[0] =~ /^\|/;
-            next;
-        }
-        $numeric = 1 if $data =~ tr/n/n/;
-        my @rows;
-        push @rows, [split /\s*\|\s*/, shift(@orig), -1]
-            while @orig and $orig[0] =~ /^\|/;
-        shift @$_, pop @$_ for @rows; # dump empty entries at ends
-        @rows = $numeric
-            ? sort { $a->[$col] <=> $b->[$col] } @rows
-            : sort { $a->[$col] cmp $b->[$col] } @rows;
-        @rows = reverse @rows if $direction == -1;
-        push @out, map "| " . join(" | ", @$_) . " |", @rows;
-    }
-
-    return join "\n", @out;
-}
-
 1;
 
 =head1 LICENSE



Mime
View raw message