Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 80 lines (64 sloc) 1.75 KB
#!/usr/bin/perl -w
use strict;
use warnings;
eval 'use Carp::Always'; # Not everyone has it
use Getopt::Long;
use File::Slurp;
use Text::Textile ();
use Template ();
use Template::Constants qw( :debug :chomp );
my $sourcepath = 's';
my $buildpath = 'build';
GetOptions(
'sourcepath:s' => \$sourcepath,
'buildpath:s' => \$buildpath,
) or exit;
-d $buildpath && -w $buildpath or die;
my $pages = [
index => 'Home',
asp => 'ASP',
coldfusion => 'ColdFusion',
csharp => 'C#',
delphi => 'Delphi',
dotnet => '.NET',
java => 'Java',
perl => 'Perl',
php => 'PHP',
python => 'Python',
ruby => 'Ruby',
scheme => 'Scheme',
];
MAIN: {
my $textile = new Text::Textile;
$textile->flavor( 'xhtml1' );
my @sidelinks;
my %tt_defaults = (
INCLUDE_PATH => [ qw( tt ) ],
OUTPUT_PATH => $buildpath,
DEBUG => DEBUG_UNDEF,
TRIM => CHOMP_ALL,
PRE_CHOMP => 1,
POST_CHOMP => 1,
);
my $tt = Template->new( \%tt_defaults );
my @pages = @{$pages};
while ( @pages ) {
my ($section,$desc) = splice( @pages, 0, 2 );
my $path = ($section eq 'index') ? './' : "./$section.html";
push( @sidelinks, {
path => $path,
text => $desc,
} );
}
my $vars = {
sidelinks => \@sidelinks,
};
@pages = @{$pages};
while ( @pages ) {
my ($section,$desc) = splice( @pages, 0, 2 );
my $source = read_file( "$sourcepath/$section.textile" );
$vars->{body} = $textile->process( $source );
$vars->{currlang} = $desc;
$tt->process( 'page.ttml', $vars, "$section.html" ) || die $tt->error;
}
}