ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/doc/gennews
Revision: 1.2
Committed: Sun Sep 16 18:54:41 2007 UTC (16 years, 8 months ago) by pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
Log Message:
#defines to enum

File Contents

# Content
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use utf8;
6
7 use constant rcsid => '$Id: gennews,v 1.1 2007-08-28 17:14:42 pippijn Exp $';
8
9 use Template;
10 use Pod::POM;
11 use YAML;
12
13 my $parser = new Pod::POM meta => 1;
14 my $static = YAML::LoadFile "variables.yml";
15
16 my $pom = $parser->parse ("podmisc/news.pod")
17 or die $parser->error();
18 %PodRSS::metadata = %{ $pom->metadata () };
19 open FH, ">", "news.xml";
20 print FH $pom->present ("PodRSS");
21 close FH;
22
23 my $tt = Template->new ({
24 INCLUDE_PATH => 'lib',
25 INTERPOLATE => 1,
26 POST_CHOMP => 1,
27 EVAL_PERL => 1,
28 }) or die "$Template::ERROR\n";
29
30 # Generate sidemenu
31 my $sidemenu = '';
32 my $vars = $static;
33 $tt->process('sidemenu.tt', $vars, \$sidemenu)
34 or die $tt->error(), "\n";
35
36 # Re-initialised with static variables from YAML
37 $vars->{subtitle} = "News";
38 $vars->{contents} = $pom->present ("PodRSSHTML");
39 $vars->{sidemenu} = $sidemenu;
40 $vars->{date} = localtime;
41
42 my $output = ''; # Variable to store the complete page
43 $tt->process('html.tt', $vars, \$output)
44 or die $tt->error(), "\n";
45
46 # Save the page to a html file
47 open HTML, ">html/news.html";
48 print HTML $output;
49 close HTML;
50
51
52 package PodRSS;
53
54 use strict;
55 use warnings;
56 use utf8;
57
58 use base "Pod::POM::View";
59
60 our %metadata;
61
62 sub view_pod {
63 my ($self, $item) = @_;
64 "<?xml version='1.0' encoding='utf-8'?>\n",
65 "<rss version='2.0'>\n",
66 $item->content->present ($self),
67 "</rss>\n"
68 }
69
70 sub view_head1 {
71 my ($self, $item) = @_;
72 my $title = $item->title->present ($self);
73 " <channel>\n",
74 " <link>$metadata{link}</link>\n",
75 " <language>$metadata{language}</language>\n",
76 " <title>$title</title>\n",
77 $item->content->present ($self),
78 " </channel>\n"
79 }
80
81 sub view_head2 {
82 my ($self, $item) = @_;
83 my $title = $item->title->present ($self);
84 " <item>\n",
85 " <title>$title</title>\n",
86 $item->content->present ($self),
87 " </item>\n"
88 }
89
90 sub view_textblock {
91 my ($self, $item) = @_;
92 " <description><![CDATA[$item]]></description>\n"
93 }
94
95 sub view_for {
96 my ($self, $item) = @_;
97 my $format = $item->format;
98 my $text = $item->text;
99
100 " <$format>$text</$format>\n"
101 }
102
103
104 package PodRSSHTML;
105
106 use strict;
107 use warnings;
108 use utf8;
109
110 use base "Pod::POM::View";
111
112 sub view_pod {
113 my ($self, $item) = @_;
114 my $content = $item->content->present ($self);
115 "<p id='news'>$content</p>\n";
116 }
117
118 sub view_head1 {
119 my ($self, $item) = @_;
120 $item->content->present ($self);
121 }
122
123 sub view_head2 {
124 my ($self, $item) = @_;
125 my $title = $item->title->present ($self);
126 my $content = $item->content->present ($self);
127 "<h4>$title</h4>",
128 $content
129 }
130
131 sub view_for {
132 my ($self, $item) = @_;
133 my $format = $item->format;
134 my $text = $item->text;
135
136 return "<span class='small'><a href='$text'>Reference</a></span><br/>"
137 if ($format eq "link");
138
139 return "<span class='small'>Posted by $text"
140 if ($format eq "author");
141
142 return " on $text</span>"
143 if ($format eq "pubDate");
144 }
145
146 sub view_textblock {
147 my ($self, $item) = @_;
148 " <p>$item</p>\n"
149 }
150
151
152 =head1 AUTHOR
153
154 Copyright © 2007 Pippijn van Steenhoven
155
156 =head1 LICENSE
157
158 This library is free software, you can redistribute it and/or modify
159 it under the terms of the GNU General Public License as documented in COPYING.
160
161 =cut