You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by wa...@apache.org on 2012/01/09 23:54:25 UTC

svn commit: r1229412 - in /incubator/ooo/site/trunk: content/openofficeorg/ppmc-faqs.mdtext lib/view.pm

Author: wave
Date: Mon Jan  9 22:54:24 2012
New Revision: 1229412

URL: http://svn.apache.org/viewvc?rev=1229412&view=rev
Log:
Updated sort_tables in view.pm to include "column groups". Used the new feature on ppmc-faqs.mdtext

Modified:
    incubator/ooo/site/trunk/content/openofficeorg/ppmc-faqs.mdtext
    incubator/ooo/site/trunk/lib/view.pm

Modified: incubator/ooo/site/trunk/content/openofficeorg/ppmc-faqs.mdtext
URL: http://svn.apache.org/viewvc/incubator/ooo/site/trunk/content/openofficeorg/ppmc-faqs.mdtext?rev=1229412&r1=1229411&r2=1229412&view=diff
==============================================================================
--- incubator/ooo/site/trunk/content/openofficeorg/ppmc-faqs.mdtext (original)
+++ incubator/ooo/site/trunk/content/openofficeorg/ppmc-faqs.mdtext Mon Jan  9 22:54:24 2012
@@ -50,30 +50,28 @@ and Juergen Schmidt as members.  New mem
 
 ## Blog
 
-Blog authors:
+Blog authors: You must be a committer. To establish a Roller account [contact Infrastructure][1]. 
 
-| ID        |  Author  | 
-|--^--------|-----------|
-| orcmid	|  Dennis E Hamilton |
+| ID        |  Author # {.w180} | ID        |  Author # {.w180}  |
+|---2-------|-------------------|-----------|--------------------|
 | rbircher	|  Raphael Bircher |
-| robweir	|  Rob Weir |
+| orcmid	|  Dennis E Hamilton |
+| dpharbison    |  Don Harbison |
 | khirano	|  Kazunari Hirano |
+| alg		|  Armin Le Grand |
 | clippka	|  Christian Lippka |
 | jsc		|  Jürgen Schmidt |
-| dpharbison|  Don Harbison |
+| robweir	|  Rob Weir |
 | orw		|  Oliver-Rainer Wittmann |
-| alg		|  Armin Le Grand |
 
-Blog admins:
+Blog admins: Admins authorize new authors once they have first established a Roller account. 
 
-| ID        |  Admin  | 
-|--^--------|-----------|
+| ID        |  Admin # {.w200} | 
+|----------|-----------|
 | wave		|  Dave Fisher |
 | marcus	|  Marcus Lange |
 
 
-Admins can authorize new authors once they have first
-established a Roller account. To establish a Roller account [contact Infrastructure][1]. You must be a committer.
 
 
 ## Bugzilla

Modified: incubator/ooo/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/incubator/ooo/site/trunk/lib/view.pm?rev=1229412&r1=1229411&r2=1229412&view=diff
==============================================================================
--- incubator/ooo/site/trunk/lib/view.pm (original)
+++ incubator/ooo/site/trunk/lib/view.pm Mon Jan  9 22:54:24 2012
@@ -9,9 +9,10 @@ package view;
 
 use strict;
 use warnings;
+use integer;
 use Dotiac::DTL qw/Template *TEMPLATE_DIRS/;
 use Dotiac::DTL::Addon::markup;
-use ASF::Util qw/read_text_file shuffle sort_tables/;
+use ASF::Util qw/read_text_file shuffle/;
 use File::Temp qw/tempfile/;
 
 push our @TEMPLATE_DIRS, "templates";
@@ -142,6 +143,70 @@ 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, $_;
+        /^(\|[ :23456vn^-]+)+\|$/ or next;
+        my($data, $col, $direction, $cur, $numeric, $grps);
+        $cur = 0;
+        while (/\|([ :23456vn^-]+)/g) {
+            $data = $1;
+	    # check for number of row/column groups. There is certainly a better way.
+            $grps = 2 if $data =~ tr/2/2/;
+            $grps = 3 if $data =~ tr/3/3/;
+            $grps = 4 if $data =~ tr/4/4/;
+            $grps = 5 if $data =~ tr/5/5/;
+            $grps = 6 if $data =~ tr/6/6/;
+            # check for numeric sort
+            $numeric = 1 if $data =~ tr/n/n/;
+            # check for sort
+            if ($data =~ tr/v/v/) {
+                $col = $cur;
+                $direction = -1;
+                last;
+            }
+            elsif ($data =~ tr/^/^/) {
+                $col = $cur;
+                $direction = 1;
+                last;
+            }
+            $cur++;
+        }
+        unless (defined $col or defined $grps) { # no special reorganization - simply output
+            push @out, shift @orig while @orig and $orig[0] =~ /^\|/;
+            next;
+        }
+        my @rows;
+        push @rows, [split /\s*\|\s*/, shift(@orig), -1]
+            while @orig and $orig[0] =~ /^\|/;
+        shift @$_, pop @$_ for @rows; # dump empty entries at ends
+        if (defined $col) {  # perform sort
+            @rows = $numeric
+                ? sort { $a->[$col] <=> $b->[$col] } @rows
+                : sort { $a->[$col] cmp $b->[$col] } @rows;
+            @rows = reverse @rows if $direction == -1;
+        }
+        if (defined $grps) {  # row-column groups
+            my($nrows,$icol,$jrow,$row);
+            $nrows = ($#rows / $grps) + 1; # requires use integer
+            for ($jrow = 0; $jrow < $nrows; $jrow++ ) {
+                $row = "| ";
+                for ($icol = $jrow; $icol <= $#rows; $icol += $nrows ) {
+                    $row .= join(" | ", @{$rows [$icol]} ) . " |";
+                }
+                push @out, $row;
+            }
+        }
+        else {
+            push @out, map "| " . join(" | ", @$_) . " |", @rows;
+        }
+    }
+    return join "\n", @out;
+}
+
 1;
 
 =head1 LICENSE