Author: jfthomps
Date: Mon Apr 27 19:28:58 2015
New Revision: 1676362

URL: http://svn.apache.org/r1676362
Log:
These are some scripts and supporting css files that can be used to export 
content from the wiki into a format we can check in to the cms space. It 
generates html rather than markdown since that is mainly what the wiki exports. 
These are based on some scripts shared from ASF for exporting wiki content for 
cms space when they moved away from the autoexport plugin.

Added:
    vcl/sandbox/useful_scripts/code.css
    vcl/sandbox/useful_scripts/convert_cwiki_markup.pl   (with props)
    vcl/sandbox/useful_scripts/vcl.css
    vcl/sandbox/useful_scripts/wiki_downloader.pl   (with props)

Added: vcl/sandbox/useful_scripts/code.css
URL: 
http://svn.apache.org/viewvc/vcl/sandbox/useful_scripts/code.css?rev=1676362&view=auto
==============================================================================
--- vcl/sandbox/useful_scripts/code.css (added)
+++ vcl/sandbox/useful_scripts/code.css Mon Apr 27 19:28:58 2015
@@ -0,0 +1,69 @@
+.codehilite pre {
+  white-space: pre-wrap;       /* css-3 */
+  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
+  white-space: -pre-wrap;      /* Opera 4-6 */
+  white-space: -o-pre-wrap;    /* Opera 7 */
+  word-wrap: break-word;       /* Internet Explorer 5.5+ */
+}
+.codehilite .hll { background-color: #ffffcc }
+/*.codehilite  { background: #f0f0f0; }*/ /* commented out because we set our 
own background for the codehilite pre element */
+.codehilite .c { color: #60a0b0; font-style: italic } /* Comment */
+/*.codehilite .err { border: 1px solid #FF0000 }*/ /* Error - commented out 
because open curly brackets are getting marked as .err */
+.codehilite .k { color: #007020; font-weight: bold } /* Keyword */
+.codehilite .o { color: #666666 } /* Operator */
+.codehilite .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
+.codehilite .cp { color: #007020 } /* Comment.Preproc */
+.codehilite .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
+.codehilite .cs { color: #60a0b0; background-color: #fff0f0 } /* 
Comment.Special */
+.codehilite .gd { color: #A00000 } /* Generic.Deleted */
+.codehilite .ge { font-style: italic } /* Generic.Emph */
+.codehilite .gr { color: #FF0000 } /* Generic.Error */
+.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.codehilite .gi { color: #00A000 } /* Generic.Inserted */
+.codehilite .go { color: #808080 } /* Generic.Output */
+.codehilite .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.codehilite .gs { font-weight: bold } /* Generic.Strong */
+.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.codehilite .gt { color: #0040D0 } /* Generic.Traceback */
+.codehilite .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.codehilite .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.codehilite .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.codehilite .kp { color: #007020 } /* Keyword.Pseudo */
+.codehilite .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.codehilite .kt { color: #902000 } /* Keyword.Type */
+.codehilite .m { color: #40a070 } /* Literal.Number */
+.codehilite .s { color: #4070a0 } /* Literal.String */
+.codehilite .na { color: #4070a0 } /* Name.Attribute */
+.codehilite .nb { color: #007020 } /* Name.Builtin */
+.codehilite .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.codehilite .no { color: #60add5 } /* Name.Constant */
+.codehilite .nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.codehilite .ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.codehilite .ne { color: #007020 } /* Name.Exception */
+.codehilite .nf { color: #06287e } /* Name.Function */
+.codehilite .nl { color: #002070; font-weight: bold } /* Name.Label */
+.codehilite .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.codehilite .nt { color: #062873; font-weight: bold } /* Name.Tag */
+.codehilite .nv { color: #bb60d5 } /* Name.Variable */
+.codehilite .ow { color: #007020; font-weight: bold } /* Operator.Word */
+.codehilite .w { color: #bbbbbb } /* Text.Whitespace */
+.codehilite .mf { color: #40a070 } /* Literal.Number.Float */
+.codehilite .mh { color: #40a070 } /* Literal.Number.Hex */
+.codehilite .mi { color: #40a070 } /* Literal.Number.Integer */
+.codehilite .mo { color: #40a070 } /* Literal.Number.Oct */
+.codehilite .sb { color: #4070a0 } /* Literal.String.Backtick */
+.codehilite .sc { color: #4070a0 } /* Literal.String.Char */
+.codehilite .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.codehilite .s2 { color: #4070a0 } /* Literal.String.Double */
+.codehilite .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape 
*/
+.codehilite .sh { color: #4070a0 } /* Literal.String.Heredoc */
+.codehilite .si { color: #70a0d0; font-style: italic } /* 
Literal.String.Interpol */
+.codehilite .sx { color: #c65d09 } /* Literal.String.Other */
+.codehilite .sr { color: #235388 } /* Literal.String.Regex */
+.codehilite .s1 { color: #4070a0 } /* Literal.String.Single */
+.codehilite .ss { color: #517918 } /* Literal.String.Symbol */
+.codehilite .bp { color: #007020 } /* Name.Builtin.Pseudo */
+.codehilite .vc { color: #bb60d5 } /* Name.Variable.Class */
+.codehilite .vg { color: #bb60d5 } /* Name.Variable.Global */
+.codehilite .vi { color: #bb60d5 } /* Name.Variable.Instance */
+.codehilite .il { color: #40a070 } /* Literal.Number.Integer.Long */

Added: vcl/sandbox/useful_scripts/convert_cwiki_markup.pl
URL: 
http://svn.apache.org/viewvc/vcl/sandbox/useful_scripts/convert_cwiki_markup.pl?rev=1676362&view=auto
==============================================================================
--- vcl/sandbox/useful_scripts/convert_cwiki_markup.pl (added)
+++ vcl/sandbox/useful_scripts/convert_cwiki_markup.pl Mon Apr 27 19:28:58 2015
@@ -0,0 +1,438 @@
+#!/usr/bin/perl
+# Converts a CWiki markup to MarkDown syntax
+use strict;
+use warnings;
+use Data::Dumper;
+
+use Text::Wrap qw/wrap $huge/;
+$huge = "overflow";
+
+my $atchurl = "https://cwiki.apache.org/confluence/download/attachments";;
+
+my $pageid = shift;
+
+my $pageName = shift;
+my $compressedPageName = $pageName;
+$compressedPageName =~ s/\s//g;
+
+my $source = shift;
+unless($source && -f $source) {
+   print "Use:\n";
+   print "  $0 <page id> <page name> <cwiki template> [export.html]\n";
+   exit 1;
+}
+my $dest = shift;
+unless($dest) {
+   $dest = $source;
+   $dest .= ".html";
+}
+
+sub convertURL {
+   my $url = shift;
+   if($url =~ /^http/) {
+      return $url;
+   }
+   $url =~ s/\s/-/g;
+   $url = lc($url).".html";
+   return $url;
+}
+
+sub title2filename {
+       my ($title) = @_;
+       $title =~ s/\s/-/g;
+       $title =~ s/"//g;
+       $title =~ s/'//g;
+       $title = lc($title) . ".cwiki.html";
+       $title =~ s/\(//g;
+       $title =~ s/\)//g;
+       $title =~ s/&//g;
+       return $title;
+}
+
+open(INP, "<$source");
+open(OUT, ">$dest");
+
+print OUT "<html>\n";
+print OUT "<head> \n";
+print OUT "<link type=\"text/css\" rel=\"stylesheet\" href=\"code.css\">\n";
+print OUT "<link type=\"text/css\" rel=\"stylesheet\" href=\"vcl.css\">\n";
+print OUT "<title>$pageName</title>\n";
+print OUT "</head>\n";
+print OUT "<body>\n";
+print OUT "<h1>$pageName</h1>\n";
+
+# Load the file into a temporary array, and do some line wrapping on
+#  the paragraphs
+my @contents;
+my $all = "";
+while(my $line = <INP>) {
+   $line =~ s/\r//;
+=cut
+   unless($line =~ /^\s*$/) {
+      my @parts = split(/( \[)/, $line);
+      $line = "";
+      foreach my $p (@parts) {
+         if($p =~ /^(.*?\])(.*)$/) {
+            $p = $1."\n".wrap("","",$2);
+         } else {
+            $p = wrap("","",$p);
+         }
+         $line .= $p;
+      }
+      unless($line =~ /\n$/s) { $line .= "\n"; }
+   }
+=cut
+       $line =~ s/<\/p>/<\/p>\n/g;
+       $line =~ s/<\/ac:image>/<\/ac:image>\n/g;
+       $line =~ s/<\/ac:plain-text-link-body>/<\/ac:plain-text-link-body>\n/g;
+       $line =~ s/<\/ac:link>/<\/ac:link>\n/g;
+       $line =~ s/<\/ac:macro>/<\/ac:macro>\n/g;
+       $all .= $line;
+}
+
+@contents = split(/\n/, $all);
+
+# Convert it
+my $in = "";
+my @macrolist = ();
+my @items;
+foreach my $line (@contents) {
+=cut
+   if($in eq "noformat") {
+      if($line =~ /^\s*^{noformat}/) {
+         print OUT "\n";
+         $in = "";
+      } else {
+         print OUT "    ".$line;
+      }
+      next;
+   } elsif($in eq "code:xml" || $in eq "code:text") {
+      if($line =~ /^\s*^{code}/) {
+         print OUT "\n";
+         $in = "";
+      } else {
+         print OUT "    ".$line;
+      }
+      next;
+   } elsif($in eq "table") {
+      if($line =~ /^\s*$/) {
+         print OUT "</table>\n";
+         $in = "";
+      }
+   } elsif($in) {
+      warn("Unexpected block '$in' for $line");
+      $in = "";
+   }
+
+   # Numbered lists
+   if($line =~ /^\s*#/) {
+      $line =~ s/^\s*#\s*/1. /;
+   }
+
+   # Headings
+   if($line =~ /^h(\d)\.\s?(.*)$/) {
+      # Build the heading entry
+      $line = ("#"x$1)." ".$2."\n";
+      # Now replicate the a name
+      my $name = $2;
+      $name =~ s/\s//g;
+      $line = "<a name=\"$compressedPageName-$name\"></a>\n".$line;
+   }
+
+   # Links
+   if($line =~ /(\[(.*?)\])/) {
+      my ($all,$text,$link) = ($1,$2,"");
+      if($text =~ /^(.*?)\|(.*)/) {
+         ($text,$link) = ($1,$2);
+      }
+
+      my $newlink;
+      if($link) {
+         $newlink = "[$text](".convertURL($link).")";
+      } else {
+         $newlink = "[$text](".convertURL($text).")";
+      }
+      $line =~ s/\Q$all\E/$newlink/;
+   }
+
+   # Old-style bold / italic
+   $line =~ s/\{\{(.*?)\}\}/*$1*/g;
+   $line =~ s/\{\{\{(.*?)\}\}\}/**$1**/g;
+
+   # No-Format
+   if($line =~ /^\s*^{noformat}/) {
+      $in = "noformat";
+      $line = "\n";
+   }
+
+   # Code blocks
+   if($line =~ /^\s*^{code:xml}/) {
+      $in = "code:xml";
+      $line = "\n";
+   }
+   if($line =~ /^\s*^{code:title=(.*?)}/) {
+      $in = "code:text";
+      $line = '<DIV class="code panel" style="border-style: 
solid;border-width: 1px;"><DIV class="codeHeader panelHeader" 
style="border-bottom-width: 1px;border-bottom-style: 
solid;"><B>'.$1.'</B></DIV><DIV class="codeContent panelContent">'."\n";
+   }
+   if($line =~ /^\s*^{code}/) {
+      $in = "code:text";
+      $line = "\n";
+   }
+
+   # Forced breaks
+   if($line =~ /\\\\/) {
+      $line = "  \n  \n";
+   }
+
+   # Tables
+   if($line =~ /^\|/) {
+      unless($in eq "table") {
+         print OUT "<table>\n";
+         $in = "table";
+      }
+      $line =~ s/\|\|/<\/th><th>/g;
+      $line =~ s/\|/<\/td><td>/g;
+      $line =~ s/<t[dh]>\s*$//gs;
+      $line =~ s/^\s*<\/t[dh]>//gs;
+      $line = "<tr>".$line."</tr>\n";
+   }
+=cut
+
+       # anchor macros
+       if(@items = $line =~ /<ac:macro 
ac:name="anchor"><ac:default-parameter>([^<]+)<\/ac:default-parameter><\/ac:macro>/)
 {
+               $line =~ s/<ac:macro 
ac:name="anchor"><ac:default-parameter>[^<]+<\/ac:default-parameter><\/ac:macro>/<span
 id="anchor-$items[0]" \/>/;
+       }
+
+       # excerpt macros
+       # TODO - do we need to do something with excerpts?
+       if($line =~ /<ac:macro 
ac:name="excerpt">(<ac:parameter.*<\/ac:parameter>)?<ac:rich-text-body>/) {
+               $line =~ s/<ac:macro 
ac:name="excerpt">(<ac:parameter.*<\/ac:parameter>)?<ac:rich-text-body>//;
+       }
+
+       # iframe macros
+       if($line =~ /<ac:macro ac:name="iframe">/) {
+               @items = $line =~ /<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>/g;
+               my %hash = ();
+               for(my $i = 0; $i < scalar(@items); $i+=2) {
+                       $hash{$items[$i]} = $items[$i + 1];
+               }
+               my $params = "";
+               foreach my $key (keys %hash) {
+                       $params .= " $key=\"$hash{$key}\"";
+               }
+               my $replace = "<iframe$params>";
+               $line =~ s/<ac:macro 
ac:name="iframe">.*<\/ac:parameter><ac:rich-text-body>/$replace/;
+               push @macrolist, "iframe";
+       }
+
+       # include macros - TODO just drop them for now
+       if($line =~ /<ac:macro 
ac:name="include">(<ac:default-parameter>([^<]+)<\/ac:default-parameter>)*<\/ac:macro>/)
 {
+               $line =~ s/<ac:macro 
ac:name="include">(<ac:default-parameter>([^<]+)<\/ac:default-parameter>)*<\/ac:macro>//;
+       }
+
+       # multimedia macros - TODO print that they are not supported
+       if($line =~ /<ac:macro ac:name="multimedia">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/) {
+               $line =~ s/<ac:macro ac:name="multimedia">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/(exporting multimedia 
macros not supported)/;
+       }
+
+       # children macros - TODO print that they are not supported
+       if($line =~ /<ac:macro ac:name="(children|pagetree)">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/) {
+               $line =~ s/<ac:macro 
ac:name="(children|pagetree)">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/(exporting content from 
child pages not supported)/;
+       }
+
+       # gliffy macros
+       if($line =~ /<ac:macro ac:name="gliffy">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/) {
+               @items = $line =~ /<ac:parameter 
ac:name="name">([^<]+)<\/ac:parameter>/;
+               my $name = $items[0] . ".png";
+               $name =~ s/ /%20/g;
+               $line =~ s/<ac:macro ac:name="gliffy">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/<img 
src="$atchurl\/$pageid\/$name" \/>/;
+       }
+
+       # toc macro - TODO skip for now, could parse content and generate our 
own
+       if($line =~ /<ac:macro ac:name="toc">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>/) {
+               $line =~ s/<ac:macro ac:name="toc">(<ac:parameter 
ac:name="([^"]+)">([^<]+)<\/ac:parameter>)*<\/ac:macro>//;
+       }
+
+       # close macros
+       if($line =~ /<\/ac:macro>/ && $line !~ /<ac:macro.*<\/ac:macro>/) {
+               if(scalar(@macrolist)) {
+                       if($macrolist[-1] eq "code" ||
+                          $macrolist[-1] eq "noformat") {
+                               $line =~ s/<\/ac:macro>/<\/pre><\/div>/;
+                       }
+                       elsif($macrolist[-1] eq "iframe") {
+                               $line =~ s/<\/ac:macro>/<\/iframe>/;
+                       }
+                       else {
+                               $line =~ s/<\/ac:macro>/<\/div>/;
+                       }
+                       pop @macrolist;
+               }
+               else {
+                       $line =~ s/<\/ac:macro>//;
+               }
+       }
+
+       # other macros
+       if(@items = $line =~ /<ac:macro ac:name="([a-zA-Z0-9]+)">/) {
+               push @macrolist, $items[0];
+               if($macrolist[-1] eq "code" ||
+                  $macrolist[-1] eq "noformat") {
+                       $line =~ s/<ac:macro ac:name="$items[0]">/<div 
class="codehilite"><pre>/;
+               }
+               else {
+                       $line =~ s/<ac:macro ac:name="$items[0]">(<ac:parameter 
ac:name="[^"]+">[^<]+<\/ac:parameter>)*/<div class="hilite">/;
+               }
+               # TODO might want to set a different class for name=note and/or 
name=tip
+               # TODO handle icons for notes, tips, etc
+
+               # if line also has a close macro, zap it here
+               if($line =~ /<\/ac:macro>$/) {
+                       if($macrolist[-1] eq "code" ||
+                          $macrolist[-1] eq "noformat") {
+                               $line =~ s/<\/ac:macro>/<\/pre><\/div>/;
+                       }
+                       else {
+                               $line =~ s/<\/ac:macro>/<\/div>/;
+                       }
+                       pop @macrolist;
+               }
+       }
+
+       if($line =~ /<ac:plain-text-body>/) {
+               $line =~ s/<ac:plain-text-body>//;
+       }
+       if($line =~ /<\/ac:plain-text-body>/) {
+               $line =~ s/<\/ac:plain-text-body>//;
+       }
+       if($line =~ /<ac:rich-text-body>/) {
+               $line =~ s/<ac:rich-text-body>//;
+       }
+       if($line =~ /<\/ac:rich-text-body>/) {
+               $line =~ s/<\/ac:rich-text-body>//;
+       }
+       if($line =~ /<!\[CDATA\[/) {
+               $line =~ s/<!\[CDATA\[//;
+       }
+       if($line =~ /\]\]>/) {
+               $line =~ s/\]\]>//;
+       }
+
+       # images
+       if($line =~ /<ac:image[^>]*><ri:attachment ri:filename="[^"]+" \/>/) {
+               @items = $line =~ /(border|width|height)="([^"]+)"/g;
+               my %hash = ();
+               my $match = q{<ac:image[^>]*><ri:attachment 
ri:filename="([^"]+)" />};
+               for(my $i = 0; $i < scalar(@items); $i+=2) {
+                       $hash{$items[$i]} = $items[$i + 1];
+               }
+               my $style = "";
+               foreach my $key (keys %hash) {
+                       if($key =~ /(width|height)/) {
+                               $style .= "$key: $hash{$key}px; ";
+                       }
+                       elsif($key eq "border" && $hash{$key} eq "true") {
+                               $style .= "border: 1px solid; ";
+                       }
+               }
+               my $thumb = "";
+               ($thumb) = $line =~ /thumbnail="([^"]+)"/;
+               if($thumb && $thumb ne "" && $thumb eq "true" && $style !~ 
/width/ && $style !~ /height/) {
+                       $style .= "width: 50%; ";
+               }
+               if($style ne "") {
+                       $style = "style=\"$style\" ";
+               }
+               @items = $line =~ /filename="([^"]+)"/;
+               my $replace = "<a href=\"$atchurl/$pageid/$items[0]\"><img 
$style src=\"$atchurl/$pageid/$items[0]\" /></a>";
+
+               $line =~ s/$match/$replace/;
+       }
+       if($line =~ /<\/ac:image>/) {
+               $line =~ s/<\/ac:image>//;
+       }
+
+       # links
+       if(@items = $line =~ /<ac:link><ri:page ri:content-title="([^"]+)" 
\/><ac:plain-text-link-body>([^<]+)<\/ac:plain-text-link-body>/) {
+               my $link = $items[0];
+               my $title = $items[1];
+               $link = title2filename($link);
+
+               $line =~ s/<ac:link><ri:page ri:content-title="([^"]+)" 
\/><ac:plain-text-link-body>[^<]+<\/ac:plain-text-link-body>/<a 
href="$link">$title<\/a>/;
+       }
+       if(@items = $line =~ /<ac:link><ri:page ri:content-title="([^"]+)" 
\/><ac:link-body>([^<]+)<\/ac:link-body>/) {
+               my $link = $items[0];
+               my $title = $items[1];
+               $link = title2filename($link);
+
+               $line =~ s/<ac:link><ri:page ri:content-title="([^"]+)" 
\/><ac:link-body>[^<]+<\/ac:link-body>/<a href="$link">$title<\/a>/;
+       }
+       if(@items = $line =~ /<ac:link><ri:page ri:content-title="([^"]+)" 
\/>/) {
+               my $link = $items[0];
+               my $title = $link;
+               $link = title2filename($link);
+
+               $line =~ s/<ac:link><ri:page ri:content-title="([^"]+)" \/>/<a 
href="$link">$title<\/a>/;
+       }
+       if($line =~ /<\/ac:link>/) {
+               $line =~ s/<\/ac:link>//;
+       }
+       if(@items = $line =~ /<ac:link ac:anchor="([^"]+)"><ri:page 
ri:content-title="([^"]+)" 
\/><ac:plain-text-link-body>([^<]+)<\/ac:plain-text-link-body>/) {
+               my $anchor = $items[0];
+               my $link = $items[1];
+               my $title = $items[2];
+               $link = title2filename($link);
+               $line =~ 
s/<ac:link[^>]+><ri:page[^>]+><ac:plain[^>]+>[^<]+<\/ac:plain-text-link-body>/<a
 href="$link#anchor-$anchor">$title<\/a>/;
+       }
+       if(@items = $line =~ /<ac:link 
ac:anchor="([^"]+)"><ac:plain-text-link-body>([^<]+)<\/ac:plain-text-link-body>/)
 {
+               my $anchor = $items[0];
+               my $title = $items[1];
+               my $link = $dest;
+               $line =~ 
s/<ac:link[^>]+><ac:plain[^>]+>[^<]+<\/ac:plain-text-link-body>/<a 
href="$link#anchor-$anchor">$title<\/a>/;
+       }
+
+   # Table of contents
+   if($line =~ /\s*^{toc}/) {
+      my @headings = grep(/^h/, @contents);
+      $line = "";
+      foreach my $h (@headings) { 
+         $h =~ /^\s*h(\d).\s+(.*?)\s*$/s;
+         my $hnum = $1;
+         my $text = $2;
+         my $name = $2;
+         $name =~ s/\s//g;
+
+         my $l = "   "x($hnum-1);
+         $l .= "* [$text](#$compressedPageName-$name)\n";
+         $line .= $l;
+      }
+   }
+
+       # TODO might need to check for <?php as part of content, look at "Web 
Code Overview" for an example
+
+   print OUT "$line\n";
+}
+print OUT "</body>\n";
+print OUT "</html>\n";
+
+close INP;
+close OUT;
+
+=head1 LICENSE
+
+           Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+
+             http://www.apache.org/licenses/LICENSE-2.0
+
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.

Propchange: vcl/sandbox/useful_scripts/convert_cwiki_markup.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: vcl/sandbox/useful_scripts/vcl.css
URL: 
http://svn.apache.org/viewvc/vcl/sandbox/useful_scripts/vcl.css?rev=1676362&view=auto
==============================================================================
--- vcl/sandbox/useful_scripts/vcl.css (added)
+++ vcl/sandbox/useful_scripts/vcl.css Mon Apr 27 19:28:58 2015
@@ -0,0 +1,178 @@
+body {
+       background-color: white;
+       color: black;
+       font-family: Arial, Helvetica, sans-serif;
+       font-size: 12pt;
+       margin: 0px;
+}  
+
+a {
+       color: #000066;
+}
+
+h1,h2 {
+       font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+       color: #990000;
+       font-weight: bold;
+       border-bottom: solid #990000 1px;
+}
+
+h3,h4,h5,h6 {
+       font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+       color: #990000;
+       font-weight: bold;
+       /*border-bottom: solid #990000 1px;*/
+}
+
+#content {
+       margin-left:200px;
+       padding-top: 10px;
+       padding-left: 15px;
+       padding-right: 15px;
+       padding-bottom: 20px;
+       clear: right;
+}
+
+#content h1.title {
+       margin: 0px;
+       font-size: 26pt;
+       font-weight: bolder;
+}
+
+#sitetitle {
+       padding: 0px 0px 0px 0px;
+       margin: 0;
+       color: white;
+       font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+       font-weight: bolder;
+       background-image: url(/img/title-background.png);
+       background-repeat: repeat-y;
+       font-size: 42px;
+       border-bottom: thin solid #990000;
+}
+
+#sitetitle a {
+       color: white;
+       text-decoration: none;
+}
+
+#sitetitle img {
+    border-style: none;
+}
+
+#navigation {
+       float:left;
+       width: 200px;
+       background-color: #F4F5FB;
+       font-size: 11pt;
+       margin-top: -1px;
+       margin-right: 0px;
+       margin-left: 0px;
+       margin-bottom: 10px;
+       border: thin solid #990000;
+       border-left: none;
+       border-top-right-radius: 2em;
+}
+
+#navigation a {
+       display: block;
+       text-decoration: none;
+}
+#navigation a:hover {
+       background-color: #FFF;
+       color: #990000;
+}
+
+#navigation ul {
+       display: block;
+       list-style-type: none;
+       margin-bottom: 20px;
+       padding-top: 0px;
+       padding-right: 0px;
+       padding-bottom: 0px;
+       padding-left: 0px;
+}
+
+#navigation ul li  {
+       font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+       text-transform: uppercase;
+       margin-top: 5px;
+       margin-left: 10px;
+       font-weight: bold;
+}
+
+#navigation ul li a  {
+       padding-right: 5px;
+}
+
+#navigation ul li ul li  {
+       font-family: Arial, Helvetica, sans-serif;
+       text-transform: none;
+       border-bottom: thin dotted #666;
+       font-weight: normal;
+}
+
+#navigation ul li ul li ul {
+       margin-bottom: 0;
+}
+
+#navigation ul li ul li ul li {
+       padding-top: 4px;
+       margin-top: 0;
+       border-top: thin dotted #666;
+       border-bottom: none;
+}
+
+#footer {
+       font-size:60%;
+       color:#999;
+       padding: 10px;
+       clear: both;
+       text-align: center;
+}
+
+.codehilite pre {
+       margin: 3px 1.5em 3px 1.5em;
+       border: 1px solid #a5b0ff;
+       padding: 0.5em;
+       border-radius: 5px;
+       background-color: #e3e9ff;
+}
+
+.docnote {
+       display: inline-block;
+       background: url(/img/icon_i.png) center left no-repeat;
+       background-position: 0px 10px;
+       margin-left: 1.5em;
+       border: 1px solid #9ec49f;
+       padding: 0.5em 0.5em 0.5em 2.5em;
+       border-radius: 5px;
+       background-color: #ddfade;
+}
+
+.hilite {
+       margin: 3px 1.5em 3px 1.5em;
+       border: 1px solid #cccccc;
+       padding: 0.5em;
+       border-radius: 5px;
+       background-color: #f0f0f0;
+}
+
+table {
+       border-collapse: collapse;
+}
+
+table th {
+       border: 1px solid #ddd;
+       padding: 7px 10px;
+       vertical-align: top;
+       text-align: left;
+       background-color: #f0f0f0;
+}
+
+table td {
+       border: 1px solid #ddd;
+       padding: 7px 10px;
+       vertical-align: top;
+       text-align: left;
+}

Added: vcl/sandbox/useful_scripts/wiki_downloader.pl
URL: 
http://svn.apache.org/viewvc/vcl/sandbox/useful_scripts/wiki_downloader.pl?rev=1676362&view=auto
==============================================================================
--- vcl/sandbox/useful_scripts/wiki_downloader.pl (added)
+++ vcl/sandbox/useful_scripts/wiki_downloader.pl Mon Apr 27 19:28:58 2015
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+use XML::Simple;
+use Data::Dumper;
+
+my $path = "/tmp/vcl_wiki_content";
+my $startindex = 0;
+my $downloadcnt = 25;
+
+if(! -e "$path/$filename") {
+       mkdir $path
+}
+
+my $browser = LWP::UserAgent->new(
+       ssl_opts => {verify_hostname => 0}
+);
+my $apiurl = 
"https://cwiki.apache.org/confluence/rest/prototype/1/search/site?type=page&spaceKey=VCL&startIndex=$startindex&pageSize=$downloadcnt";;
+
+sub getContent {
+       my ($key, $id, $title) = @_;
+       my $filename = $title;
+       $filename =~ s/\s/-/g;
+       $filename =~ s/"//g;
+       $filename =~ s/'//g;
+       $filename = lc($filename) . ".cwiki";
+       $filename =~ s/\(//g;
+       $filename =~ s/\)//g;
+       $filename =~ s/&//g;
+       #print "filename: $path/$filename\n";
+       if(-e "$path/$filename") {
+               print "skipping $filename\n";
+               return;
+       }
+       $contenturl = 
"https://cwiki.apache.org/confluence/rest/prototype/1/content/$id";;
+       my $response = $browser->get($contenturl);
+       if(! $response->is_success) {
+               return;
+       }
+
+       # TODO check content for macro including children
+       # <ac:macro ac:name="children"><ac:parameter 
ac:name="all">true</ac:parameter><ac:parameter 
ac:name="style">h3</ac:parameter></ac:macro>
+       # and create a page from the child pages
+
+       my $data = XMLin($response->content);
+       #print $data->{'title'} . "\n";
+       my $title = $data->{'title'};
+       $title =~ s/"//g;
+       $title =~ s/'//g;
+       open(FILE1, ">$path/$filename") || die "failed to open $path/$filename";
+       print FILE1 $data->{'body'}->{'content'} . "\n" || die "failed to write 
to $path/$filename";
+       close(FILE1);
+       print "running './convert_cwiki_markup.pl $key \"$title\" 
$path/$filename'\n";
+       my $out = `./convert_cwiki_markup.pl $key "$title" $path/$filename`;
+       print "convert output: $out\n";
+       #print $data->{'body'}->{'content'} . "\n";
+       #print "==========================================================\n";
+       sleep 10;
+}
+
+my $response = $browser->get($apiurl);
+die 'Error getting content' unless $response->is_success;
+
+my $data = XMLin($response->content);
+foreach $key (keys %{$data->{'result'}}) {
+       #print "Title: " . $data->{'result'}->{$key}->{'title'} . "\n";
+       foreach $link (@{$data->{'result'}->{$key}->{'link'}}) {
+               if(my @id = $link->{'href'} =~ 
/confluence\/rest\/prototype\/1\/content\/([0-9]+)$/) {
+                       #print $id[0] . ": " . $link->{'href'} . "\n";
+                       getContent($key, $id[0], 
$data->{'result'}->{$key}->{'title'});
+               }
+       }
+}
+
+=head1 LICENSE
+
+           Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+
+             http://www.apache.org/licenses/LICENSE-2.0
+
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.

Propchange: vcl/sandbox/useful_scripts/wiki_downloader.pl
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to