ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/www/generate
Revision: 1.35
Committed: Sun Jun 17 16:21:06 2012 UTC (12 years ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.34: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

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