#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Pod::POM;
use Template;
use YAML;
my $parser = new Pod::POM meta => 1;
my ($pom, $html);
$pom = $parser->parse ("src/news.pod")
or die $parser->error;
$html = $pom->present ("PodHTML");
$html =~ s/\[//g;
open FH, ">", "src/news.html";
print FH "News\n\n
News
";
print FH $html;
close FH;
%PodRSS::metadata = %{ $pom->metadata };
$html = $pom->present ("PodRSS");
open FH, ">", "html/news.rss";
print FH $html;
close FH;
# Static variables
my $static = YAML::LoadFile "variables.yml";
my @files = ;
my @monsters = ;
# Directory listings
my $list;
sub list {
my ($a, $b) = @_;
my $tmp = "
\n";
my @listing = <$a/$b/*.html>;
for (@listing) {
my ($file) = $_ =~ /\/([^\/]+)$/;
$tmp .= "
$file \n ";
$tmp .= do { local $/; open my $fh, "<$_.desc" or die "$_.desc: $!\n"; <$fh> };
$tmp .= "
\n";
}
$tmp .= "
\n";
$list->{$a}->{$b} = $tmp;
}
# Directory listings
list "doc", "user";
list "doc", "development";
sub generate {
my ($indir, $outdir, @list) = @_;
for my $file (@list) {
my @contents = do { open my $fh, "<$file" or die "$file: $!\n"; <$fh> };
my $subtitle = shift @contents;
chomp $subtitle;
my $curfile = $file;
$curfile =~ s/$indir\/(.+\.html)$/$1/;
my $tt = new Template {
INTERPOLATE => 1,
POST_CHOMP => 1,
EVAL_PERL => 1,
} or die "$Template::ERROR\n";
my $vars = { list => $list };
my $contents = "@contents";
my $data = ''; # Variable to store processed templates
$tt->process (\$contents, $vars, \$data)
or die $tt->error;
# Re-initialised with static variables from YAML
$vars = $static;
$vars->{subtitle} = $subtitle;
$vars->{contents} = $data;
$vars->{curfile} = $curfile;
my $output = ''; # Variable to store the complete page
$tt->process ('template.html', $vars, \$output)
or die $tt->error;
# Save the page to a html file
$file =~ s/$indir\/(.+\.html)$/$outdir\/$1/;
open HTML, ">$file";
print HTML $output;
close HTML;
}
}
my @rightbar;
push @rightbar, "src/images/monsters/$_.png"
for @{ $static->{rightbar} };
my @leftbar;
push @leftbar, "src/images/runes/$_.png"
for @{ $static->{leftbar} };
generate "src", "html", @files;
generate "monsters", "html\/monsters", @monsters;
system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @rightbar, "html/images/monsters-trans.png";
system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @leftbar, "html/images/runes-trans.png";
package PodHTML;
use strict;
use warnings;
use utf8;
my $rcsid = '$Id: generate,v 1.20 2007/10/14 15:34:46 root Exp $';
use base "Pod::POM::View";
our $subdir;
our $dir;
our $menu;
sub view_pod {
my ($self, $item) = @_;
$item->content->present ($self)
}
sub view_head1 {
my ($self, $item) = @_;
$item->content->present ($self)
}
sub view_head2 {
my ($self, $item) = @_;
"