#!/usr/bin/env perl use strict; use warnings; use utf8; use constant rcsid => '$Id: gennews,v 1.2 2007/09/16 18:54:41 pippijn Exp $'; use Template; use Pod::POM; use YAML; my $parser = new Pod::POM meta => 1; my $static = YAML::LoadFile "variables.yml"; my $pom = $parser->parse ("podmisc/news.pod") or die $parser->error(); %PodRSS::metadata = %{ $pom->metadata () }; open FH, ">", "news.xml"; print FH $pom->present ("PodRSS"); close FH; my $tt = Template->new ({ INCLUDE_PATH => 'lib', INTERPOLATE => 1, POST_CHOMP => 1, EVAL_PERL => 1, }) or die "$Template::ERROR\n"; # Generate sidemenu my $sidemenu = ''; my $vars = $static; $tt->process('sidemenu.tt', $vars, \$sidemenu) or die $tt->error(), "\n"; # Re-initialised with static variables from YAML $vars->{subtitle} = "News"; $vars->{contents} = $pom->present ("PodRSSHTML"); $vars->{sidemenu} = $sidemenu; $vars->{date} = localtime; my $output = ''; # Variable to store the complete page $tt->process('html.tt', $vars, \$output) or die $tt->error(), "\n"; # Save the page to a html file open HTML, ">html/news.html"; print HTML $output; close HTML; 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" } sub view_for { my ($self, $item) = @_; my $format = $item->format; my $text = $item->text; " <$format>$text\n" } package PodRSSHTML; use strict; use warnings; use utf8; use base "Pod::POM::View"; sub view_pod { my ($self, $item) = @_; my $content = $item->content->present ($self); "

$content

\n"; } sub view_head1 { my ($self, $item) = @_; $item->content->present ($self); } sub view_head2 { my ($self, $item) = @_; my $title = $item->title->present ($self); my $content = $item->content->present ($self); "

$title

", $content } sub view_for { my ($self, $item) = @_; my $format = $item->format; my $text = $item->text; return "Reference
" if ($format eq "link"); return "Posted by $text" if ($format eq "author"); return " on $text" if ($format eq "pubDate"); } sub view_textblock { my ($self, $item) = @_; "

$item

\n" } =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 as documented in COPYING. =cut