#!/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-archive.pod") or die $parser->error; $html = $pom->present ("PodHTML"); $html =~ s/\[//g; open FH, ">", "src/news-archive.html"; print FH "News Archive\n\n"; print FH $html; close FH; $pom = $parser->parse ("src/news.pod") or die $parser->error; $html = $pom->present ("PodHTML"); $html =~ s/\[//g; open FH, ">", "html/news.html"; print FH $html; close FH; %PodRSS::metadata = %{ $pom->metadata }; $html = $pom->present ("PodRSS"); $html =~ s/\[//g; 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"; $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.16 2007/09/18 20:25:34 pippijn 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) = @_; "

", $item->title, " ", $item->content->present ($self), "

" } sub view_textblock { my ($self, $item) = @_; $item, "
" } sub view_seq_bold { my ($self, $item) = @_; "$item" } sub view_seq_file { my ($self, $item) = @_; "$item" } sub view_seq_link { my ($self, $item) = @_; my ($name, $href) = split /\|/, $item, 2; "$name" } =head1 AUTHOR Copyright © 2007 Pippijn van Steenhoven =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the terms of the GNU General Public License. =cut 1; package PodRSS; use strict; use warnings; use utf8; use base "Pod::POM::View"; our %metadata; sub view_pod { my ($self, $item) = @_; "\n", "\n", $item->content->present ($self), "\n" } sub view_head1 { my ($self, $item) = @_; my $title = $item->title->present ($self); " \n", " $metadata{link}\n", " $metadata{language}\n", " $title\n", $item->content->present ($self), " \n" } sub view_head2 { my ($self, $item) = @_; my $title = $item->title->present ($self); " \n", " $title\n", $item->content->present ($self), " \n" } sub view_textblock { my ($self, $item) = @_; " \n" }