Initial support for tt2 and gen_website
[grml.org.git] / gen_website
1 #!/usr/bin/perl
2
3 use strict; 
4 use warnings; 
5
6 use Template;
7 use File::Find::Rule;
8 use File::Path qw(make_path);
9 use File::Basename qw (fileparse);
10 use File::Copy::Recursive qw(fcopy);
11
12 my $out_dir = "out/";
13
14 #find all files
15
16 my @files = File::Find::Rule->file()
17                             ->in('.');
18
19
20 #initialize template toolkit
21
22 my $template = Template->new;
23
24 foreach my $file (@files) {
25         next if $file =~ /^$out_dir/;
26         next if $file =~ /$0$/;
27         if ($file =~ /\.tt2$/) {
28                 my $output;
29                 $template->process($file, undef, \$output);
30                 my ($name,$path,$suffix) = fileparse($file,qw (.tt2));
31                 open (my $fh, '>', "$out_dir/$path/$name.html") or die "$!";
32                 print $fh $output;
33                 close($fh);
34         } else {
35                 fcopy ($file, "$out_dir/$file");
36         }
37 }