ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
Revision: 1.32
Committed: Wed Apr 28 06:06:55 2010 UTC (14 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.31: +16 -12 lines
Log Message:
tweaking the rss and html output.

File Contents

# Content
1 #!/opt/perl/bin/perl
2
3 use common::sense;
4
5 use Pod::POM;
6 use YAML;
7
8 my $parser = new Pod::POM meta => 1;
9
10 my ($pom, $html);
11
12 our $top_news;
13
14 $pom = $parser->parse ("src/news.pod")
15 or die $parser->error;
16 $html = join '', $pom->present ("PodHTML");
17 $html =~ s/\[/</g;
18 $html =~ s/\]/>/g;
19 open FH, ">", "src/news.html.inc" or die "src/news.html.inc: $!";
20 print FH $html;
21 close FH;
22
23 open FH, ">", "src/news.top.html.inc" or die "src/news.top.html.inc: $!";
24 print FH $top_news;
25 close FH;
26
27 %PodRSS::metadata = %{ $pom->metadata };
28 $PodRSS::max_cnt = 20;
29 $html = join '', $pom->present ("PodRSS");
30 open FH, ">", "src/news.rss" or die "src/news.rss: $!";
31 print FH $html;
32 close FH;
33
34 system "rsync -avP src/. html/. --exclude CVS";
35
36 =head1 AUTHOR
37
38 Copyright © 2010 The Deliantra Team
39 Copyright © 2007 Pippijn van Steenhoven
40
41 =head1 LICENSE
42
43 This library is free software, you can redistribute it and/or modify
44 it under the terms of the GNU General Public License.
45
46 =cut
47
48 1;
49
50 package PodHTML;
51
52 use strict;
53 use warnings;
54 use utf8;
55
56 my $rcsid = '$Id: generate,v 1.31 2010-04-28 05:44:37 elmex Exp $';
57
58 use base "Pod::POM::View";
59
60 our $subdir;
61 our $dir;
62 our $menu;
63
64 sub view_pod {
65 my ($self, $item) = @_;
66 $item->content->present ($self)
67 }
68
69 sub view_head1 {
70 my ($self, $item) = @_;
71 $item->content->present ($self)
72 }
73
74 sub view_head2 {
75 my ($self, $item) = @_;
76 my $str =
77 "<span class=\"date\">"
78 . $item->title
79 . "</span>\n"
80 . $item->content->present ($self)
81 . "\n\n";
82
83 unless (defined $top_news) {
84 $top_news = $str
85 }
86
87 $str
88 }
89
90 sub view_textblock {
91 my ($self, $item) = @_;
92 "<p class=\"news_item\">\n$item\n</p>\n"
93 }
94
95 sub view_seq_bold {
96 my ($self, $item) = @_;
97 "<b>$item</b>"
98 }
99
100 sub view_seq_italic {
101 my ($self, $item) = @_;
102 "<i>$item</i>"
103 }
104
105 sub view_seq_file {
106 my ($self, $item) = @_;
107 "<tt>$item</tt>"
108 }
109
110 sub view_seq_link {
111 my ($self, $item) = @_;
112 my ($name, $href) = split /\|/, $item, 2;
113 "<a href=\"$href\">$name</a>"
114 }
115
116
117 package PodRSS;
118
119 use strict;
120 use warnings;
121 use utf8;
122
123 use base "Pod::POM::View";
124
125 our %metadata;
126 our $max_cnt;
127
128 sub view_pod {
129 my ($self, $item) = @_;
130 "<?xml version='1.0' encoding='utf-8'?>\n"
131 . "<rss version='2.0'>\n"
132 . $item->content->present ($self)
133 . "</rss>\n"
134 }
135
136 sub view_head1 {
137 my ($self, $item) = @_;
138 " <channel>\n"
139 . " <link>$metadata{link}</link>\n"
140 . " <language>$metadata{language}</language>\n"
141 . " <title>" . $item->title->present ($self) . "</title>\n"
142 . $item->content->present ($self)
143 . " </channel>\n"
144 }
145
146 sub view_head2 {
147 my ($self, $item) = @_;
148 my $r =
149 $max_cnt-- > 0
150 ? " <item>\n"
151 . " <title>" . $item->title->present ($self) . "</title>\n"
152 . " <description>"
153 . $item->content->present ($self)
154 . " </description>"
155 . " </item>\n"
156 : "";
157 $r
158 }
159
160 sub view_textblock {
161 my ($self, $item) = @_;
162 " <![CDATA[$item]]>\n"
163 }