Author: fmeschbe
Date: Fri Dec 14 14:14:09 2012
New Revision: 1421874
URL: http://svn.apache.org/viewvc?rev=1421874&view=rev
Log:
FELIX-3816 Add conversion and site build tools from Apache Infra and Sling
Added:
felix/site/tools/
- copied from r1421417, sling/site/tools/
felix/site/tools/markdownd (with props)
Modified:
felix/site/tools/conversion/convert_cwiki_markup.pl
felix/site/tools/conversion/export_site.pl
Modified: felix/site/tools/conversion/convert_cwiki_markup.pl
URL:
http://svn.apache.org/viewvc/felix/site/tools/conversion/convert_cwiki_markup.pl?rev=1421874&r1=1421417&r2=1421874&view=diff
==============================================================================
--- felix/site/tools/conversion/convert_cwiki_markup.pl (original)
+++ felix/site/tools/conversion/convert_cwiki_markup.pl Fri Dec 14 14:14:09 2012
@@ -107,6 +107,7 @@ print OUT "\n";
# Convert it
my $in = "";
+my $openDiv = 0;
foreach my $line (@contents) {
if($in eq "noformat") {
if($line =~ /^\s*^{noformat}/) {
@@ -149,11 +150,33 @@ foreach my $line (@contents) {
# $line = "<a name=\"$compressedPageName-$name\"></a>\n".$line;
}
+ # Remove {anchor:name}
+ if($line =~ /\{anchor:/) {
+ $line =~ s/\{anchor:[^}]*\}//g;
+ }
+
+ # note / warning / info / tip
+ if($line =~ /\{(note|warning|info|tip)([^}]*)\}/) {
+ if($openDiv) {
+ $line = "</div>\n";
+ $openDiv = 0;
+ } else {
+ $line = "<div class=\"$1\" markdown=\"1\">\n";
+ if($2 =~ /title=(.*)$/) {
+ $line .= "**$1**\n";
+ }
+ $openDiv = 1;
+ }
+ }
+
# Old-style bold / italic
$line =~ s/\{\{(.*?)\}\}/`$1`/g;
$line =~ s/_(.*?)_/*$1*/g;
# $line =~ s/\{\{(.*?)\}\}/*$1*/g;
$line =~ s/\{\{\{(.*?)\}\}\}/**$1**/g;
+
+ # Remove Confluence HTML marker
+ $line =~ s/\{html\}//g;
# Links
if($line =~ /(\[(.*?)\])/) {
Modified: felix/site/tools/conversion/export_site.pl
URL:
http://svn.apache.org/viewvc/felix/site/tools/conversion/export_site.pl?rev=1421874&r1=1421417&r2=1421874&view=diff
==============================================================================
--- felix/site/tools/conversion/export_site.pl (original)
+++ felix/site/tools/conversion/export_site.pl Fri Dec 14 14:14:09 2012
@@ -7,6 +7,9 @@ use warnings;
use RPC::XML;
use RPC::XML::Client;
+use File::Basename;
+use File::Path qw(make_path);
+
my $confluence = "https://cwiki.apache.org/confluence/";
my $RPCURL = $confluence."rpc/xmlrpc";
@@ -39,12 +42,58 @@ my $token = $response->value;
$response = $client->send_request('confluence1.getPages', $token, $siteName);
$response->is_fault and die "ERROR: could not get pages for $siteName: ",
$response->value->{faultString};
+#collect pages into page hash
my @pages = @{$response->value};
-
+my %mddocs = ();
foreach my $page (@pages) {
my $title = $page->{title};
+
+ my $fileName = $title;
+ $fileName =~ s/\s/-/g;
+ $fileName =~ s/\W/-/g;
+ $fileName =~ s/--/-/g;
+ $fileName =~ s/--/-/g;
+ $fileName =~ s/-$//g;
+ $fileName = lc($fileName);
+
+ my %currentPage = (
+ title => $title,
+ parentId => $page->{parentId},
+ url => $page->{url},
+ fileName => $fileName,
+ path => ""
+ );
+ $mddocs{ $page->{id} } = \%currentPage;
+}
+
+sub getPath {
+ my $id = shift(@_);
+ if( $id ) {
+ my $path = $mddocs{ $id }->{ path };
+ if( $path ) {
+ return $path;
+ }
+ my $parentPath = getPath( $mddocs{ $id }->{ parentId } );
+ $path = $parentPath . "/" . $mddocs{ $id }->{ fileName };
+ $mddocs{ $id }->{ path } = $path;
+ return $path;
+ } else {
+ return "";
+ }
+}
+
+# my $count = 0;
+# foreach my $key (keys( %mddocs )) {
+# $count++;
+# print $count . " : " . getPath( $key ) . "\n";
+# }
+# print $count . " pages\n";
+
+# Iterate pages, download and convert
+while (my($id, $page) = each %mddocs) {
+ my $title = $page->{title};
- print "Fetching $title (".$page->{id}.")\n";
+ print "Fetching $title (".$id." / ".$page->{parentId}.")\n";
$response = $client->send_request('confluence1.getPage', $token, $siteName,
$title);
$response->is_fault and die "ERROR: could not get page details: ",
$response->value->{faultString};
@@ -53,21 +102,20 @@ foreach my $page (@pages) {
print "Processing $title from ".$page->{url}."\n";
- my $page = $title;
- $page =~ s/\s/-/g;
- $page =~ s/\W/-/g;
- $page =~ s/--/-/g;
- $page =~ s/--/-/g;
- $page =~ s/-$//g;
-
- my $cwikiFile = "content/".lc($page).".cwiki";
+ # remove index prefix from page path
+ my $fileName = getPath( $id );
+ $fileName =~ s/^\/index\///;
+
+ my $cwikiFile = "confluence/" . $fileName . ".cwiki";
+ my $mdFile = "content/" . $fileName . ".mdtext";
+
+ make_path( dirname( $cwikiFile ) );
+ make_path( dirname( $mdFile ) );
+
open(CWIKI, ">$cwikiFile");
print CWIKI $content;
close CWIKI;
- my $mdFile = $cwikiFile;
- $mdFile =~ s/\.cwiki/.mdtext/;
-
print " Generating markdown file $mdFile\n";
`$binPath/convert_cwiki_markup.pl "$title" "$cwikiFile" "$mdFile"`;
Added: felix/site/tools/markdownd
URL:
http://svn.apache.org/viewvc/felix/site/tools/markdownd?rev=1421874&view=auto
==============================================================================
--- felix/site/tools/markdownd (added)
+++ felix/site/tools/markdownd Fri Dec 14 14:14:09 2012
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+PGMDIR=$1
+if [ -z "$PGMDIR" ] ; then
+ echo usage markdownd build-tool-path
+ exit 1
+fi
+
+
+export MARKDOWN_SOCKET="$PGMDIR/../markdown.socket" PYTHONPATH="$PGMDIR"
+echo "Markdown listening on MARKDOWN_SOCKET=${MARKDOWN_SOCKET}"
+python "$PGMDIR/markdownd.py"
Propchange: felix/site/tools/markdownd
------------------------------------------------------------------------------
svn:executable = *