ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
Revision: 1.29
Committed: Wed Apr 28 05:23:41 2010 UTC (14 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.28: +8 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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     $html = $pom->present ("PodHTML");
17     $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     $html = $pom->present ("PodRSS");
29 elmex 1.25 open FH, ">", "src/news.rss" or die "src/news.rss: $!";
30 pippijn 1.14 print FH $html;
31     close FH;
32    
33 root 1.27 system "rsync -avP src/. html/. --exclude CVS";
34 root 1.24
35 pippijn 1.5 =head1 AUTHOR
36    
37 elmex 1.25 Copyright © 2010 The Deliantra Team
38 pippijn 1.5 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 pippijn 1.6 1;
48    
49 elmex 1.26 package PodHTML;
50    
51     use strict;
52     use warnings;
53     use utf8;
54    
55 elmex 1.29 my $rcsid = '$Id: generate,v 1.28 2010-04-27 18:58:31 elmex Exp $';
56 elmex 1.26
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 elmex 1.28 my @str = (
76 elmex 1.29 "<p><span class=\"date\">",
77 elmex 1.28 $item->title,
78     "</span> ",
79     $item->content->present ($self),
80 elmex 1.29 "</p>"
81 elmex 1.28 );
82    
83     unless (defined $top_news) {
84     $top_news = join '', @str;
85     }
86    
87     @str
88 elmex 1.26 }
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 elmex 1.29 sub view_seq_italic {
101     my ($self, $item) = @_;
102     "<i>$item</i>"
103     }
104    
105 elmex 1.26 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 pippijn 1.6 package PodRSS;
118    
119     use strict;
120     use warnings;
121     use utf8;
122    
123     use base "Pod::POM::View";
124    
125     our %metadata;
126    
127     sub view_pod {
128     my ($self, $item) = @_;
129 pippijn 1.18 "<?xml version='1.0' encoding='utf-8'?>\n"
130     . "<rss version='2.0'>\n"
131 pippijn 1.17 . $item->content->present ($self)
132     . "</rss>\n"
133 pippijn 1.6 }
134    
135     sub view_head1 {
136     my ($self, $item) = @_;
137     my $title = $item->title->present ($self);
138     " <channel>\n",
139     " <link>$metadata{link}</link>\n",
140     " <language>$metadata{language}</language>\n",
141     " <title>$title</title>\n",
142     $item->content->present ($self),
143     " </channel>\n"
144     }
145    
146     sub view_head2 {
147     my ($self, $item) = @_;
148     my $title = $item->title->present ($self);
149     " <item>\n",
150     " <title>$title</title>\n",
151     $item->content->present ($self),
152     " </item>\n"
153     }
154    
155     sub view_textblock {
156     my ($self, $item) = @_;
157     " <description><![CDATA[$item]]></description>\n"
158     }