Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (33 sloc) 1.11 KB
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use Template;
use File::Path qw/rmtree mkpath/;
use Fatal qw/rmtree mkpath/;
use Carp qw/croak/;
my %p = (
template_dir => "$FindBin::Bin/../template",
output_dir => "$FindBin::Bin/../web",
static_dir => "$FindBin::Bin/../static",
);
rmtree $p{output_dir} if -d $p{output_dir};
mkpath "$p{output_dir}/css";
mkpath "$p{output_dir}/images";
system("cp $p{static_dir}/images/* $p{output_dir}/images");
for my $f (glob("static/css/*.scss")) {
(my $base = $f) =~ s/.+\/(.+?)\.scss$/$1/;
print "sassing $base\n";
system("sass --scss $f $p{output_dir}/css/$base.css");
}
my $tt2 = Template->new({ INCLUDE_PATH => [ $p{template_dir} ] });
for my $template (glob "template/*.tt2") {
(my $page = $template) =~ s/.+\/(.+?)\.tt2/$1/;
my $output_file = "$p{output_dir}/$page.html";
unless ($page eq 'index') {
mkpath "$p{output_dir}/$page";
$output_file = "$p{output_dir}/$page/index.html";
}
print "Creating $page.tt2 => $output_file\n";
$tt2->process("$page.tt2", {}, $output_file) || die "TT2 died: " . $tt2->error;
}