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