#!/usr/bin/perl ###################### # Build Docs From GoogleCode wiki ###################### use strict; use warnings; use Text::GooglewikiFormat; use Pod::From::GoogleWiki; use FindBin qw/$Bin/; use Cwd qw/abs_path/; use File::Copy; use File::Spec; my $trunk_dir = abs_path( File::Spec->catdir( $Bin, '..', '..' ) ); my $wiki_dir = abs_path( File::Spec->catdir( $trunk_dir, '..', 'wiki' ) ); my $project_url = 'http://code.google.com/p/foorum'; my @filenames = ( 'README', 'INSTALL', 'Configure', 'I18N', 'TroubleShooting', 'AUTHORS', 'RULES', 'HowRSS', 'Tutorial1', 'Tutorial2', 'Tutorial3', 'Tutorial4', 'Tutorial5', 'PreRelease', 'Upgrade' ); my %tags = %Text::GooglewikiFormat::tags; my $pfg = Pod::From::GoogleWiki->new(); # replace link sub my $linksub = sub { my ( $link, $opts ) = @_; $opts ||= {}; my $ori_text = $link; ( $link, my $title ) = Text::GooglewikiFormat::find_link_title( $link, $opts ); ( $link, my $is_relative ) = Text::GooglewikiFormat::escape_link( $link, $opts ); unless ($is_relative) { return qq|$title|; } elsif ( grep { $link eq $_ } @filenames ) { return qq|$ori_text|; } else { return $ori_text; } }; $tags{link} = $linksub; my $indexpage; # build in trunk/docs dir foreach my $filename (@filenames) { { local $/; open( my $fh, '<', File::Spec->catfile( $wiki_dir, "$filename\.wiki" ) ) or do { print "Skip $filename\n"; next; }; flock( $fh, 1 ); my $string = <$fh>; close($fh); my $org_string = $string; # back for later to POD $string =~ s/&/&/gs; $string =~ s/>/>/gs; $string =~ s/</gs; my $html = Text::GooglewikiFormat::format( $string, \%tags ); buildhtml( $filename, $html ); $indexpage .= qq~