ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
Revision: 1.31
Committed: Wed Apr 28 05:44:37 2010 UTC (14 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.30: +2 -2 lines
Log Message:
style changes

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 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.30 $html = join '', $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.31 my $rcsid = '$Id: generate,v 1.30 2010-04-28 05:41: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.30 my $str =
76     "<span class=\"date\">"
77     . $item->title
78     . "</span>\n"
79     . $item->content->present ($self)
80     . "\n\n";
81 elmex 1.28
82     unless (defined $top_news) {
83 elmex 1.30 $top_news = $str
84 elmex 1.28 }
85    
86 elmex 1.30 $str
87 elmex 1.26 }
88    
89     sub view_textblock {
90     my ($self, $item) = @_;
91 elmex 1.31 "<p class=\"news_item\">$item</p>\n"
92 elmex 1.26 }
93    
94     sub view_seq_bold {
95     my ($self, $item) = @_;
96     "<b>$item</b>"
97     }
98    
99 elmex 1.29 sub view_seq_italic {
100     my ($self, $item) = @_;
101     "<i>$item</i>"
102     }
103    
104 elmex 1.26 sub view_seq_file {
105     my ($self, $item) = @_;
106     "<tt>$item</tt>"
107     }
108    
109     sub view_seq_link {
110     my ($self, $item) = @_;
111     my ($name, $href) = split /\|/, $item, 2;
112     "<a href=\"$href\">$name</a>"
113     }
114    
115    
116 pippijn 1.6 package PodRSS;
117    
118     use strict;
119     use warnings;
120     use utf8;
121    
122     use base "Pod::POM::View";
123    
124     our %metadata;
125    
126     sub view_pod {
127     my ($self, $item) = @_;
128 pippijn 1.18 "<?xml version='1.0' encoding='utf-8'?>\n"
129     . "<rss version='2.0'>\n"
130 pippijn 1.17 . $item->content->present ($self)
131     . "</rss>\n"
132 pippijn 1.6 }
133    
134     sub view_head1 {
135     my ($self, $item) = @_;
136     my $title = $item->title->present ($self);
137 elmex 1.30 " <channel>\n"
138     . " <link>$metadata{link}</link>\n"
139     . " <language>$metadata{language}</language>\n"
140     . " <title>$title</title>\n"
141     . $item->content->present ($self)
142     . " </channel>\n"
143 pippijn 1.6 }
144    
145     sub view_head2 {
146     my ($self, $item) = @_;
147     my $title = $item->title->present ($self);
148 elmex 1.30 " <item>\n"
149     . " <title>$title</title>\n"
150     . " <description>"
151     . $item->content->present ($self)
152     . " </description>"
153     . " </item>\n"
154 pippijn 1.6 }
155    
156     sub view_textblock {
157     my ($self, $item) = @_;
158 elmex 1.30 " <![CDATA[$item]]>\n"
159 pippijn 1.6 }