#!/usr/bin/env perl use strict; use warnings; use utf8; use Pod::POM; use Template; use YAML; my $parser = new Pod::POM meta => 1; # 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 $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; 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; } } generate "src", "html", @files; generate "monsters", "html\/monsters", @monsters; my $pom = $parser->parse ("src/news.pod") or die $parser->error; my $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; $pom = $parser->parse ("src/news-archive.pod") or die $parser->error; $html = $pom->present ("PodHTML"); $html =~ s/\[//g; open FH, ">", "html/news-archive.html"; print FH $html; close FH; package PodHTML; use strict; use warnings; use utf8; my $rcsid = '$Id: generate,v 1.10 2007/09/16 09:04:57 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, "

" } =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" }