ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
Revision: 1.28
Committed: Tue Apr 27 18:58:31 2010 UTC (14 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.27: +20 -3 lines
Log Message:
uhm...

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