ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
Revision: 1.35
Committed: Sun Jun 17 16:21:06 2012 UTC (12 years, 1 month ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.34: +2 -2 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 root 1.35 use YAML::XS;
7 pippijn 1.1
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 elmex 1.34 our $top_news_cnt = 2;
14 elmex 1.28
15 root 1.19 $pom = $parser->parse ("src/news.pod")
16 pippijn 1.14 or die $parser->error;
17 elmex 1.30 $html = join '', $pom->present ("PodHTML");
18 pippijn 1.14 $html =~ s/\[/</g;
19     $html =~ s/\]/>/g;
20 root 1.24 open FH, ">", "src/news.html.inc" or die "src/news.html.inc: $!";
21 pippijn 1.14 print FH $html;
22     close FH;
23    
24 elmex 1.28 open FH, ">", "src/news.top.html.inc" or die "src/news.top.html.inc: $!";
25     print FH $top_news;
26     close FH;
27    
28 pippijn 1.14 %PodRSS::metadata = %{ $pom->metadata };
29 elmex 1.32 $PodRSS::max_cnt = 20;
30 elmex 1.30 $html = join '', $pom->present ("PodRSS");
31 elmex 1.25 open FH, ">", "src/news.rss" or die "src/news.rss: $!";
32 pippijn 1.14 print FH $html;
33     close FH;
34    
35 root 1.27 system "rsync -avP src/. html/. --exclude CVS";
36 root 1.24
37 pippijn 1.5 =head1 AUTHOR
38    
39 elmex 1.25 Copyright © 2010 The Deliantra Team
40 pippijn 1.5 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 pippijn 1.6 1;
50    
51 elmex 1.26 package PodHTML;
52    
53     use strict;
54     use warnings;
55     use utf8;
56    
57 elmex 1.33 use CGI qw/escapeHTML/;
58    
59 root 1.35 my $rcsid = '$Id: generate,v 1.34 2010-05-05 06:46:33 elmex Exp $';
60 elmex 1.26
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 elmex 1.30 my $str =
80     "<span class=\"date\">"
81     . $item->title
82     . "</span>\n"
83     . $item->content->present ($self)
84     . "\n\n";
85 elmex 1.28
86 elmex 1.34 if ($top_news_cnt-- > 0) {
87     $top_news .= $str
88 elmex 1.28 }
89    
90 elmex 1.30 $str
91 elmex 1.26 }
92    
93     sub view_textblock {
94     my ($self, $item) = @_;
95 elmex 1.32 "<p class=\"news_item\">\n$item\n</p>\n"
96 elmex 1.26 }
97    
98     sub view_seq_bold {
99     my ($self, $item) = @_;
100     "<b>$item</b>"
101     }
102    
103 elmex 1.29 sub view_seq_italic {
104     my ($self, $item) = @_;
105     "<i>$item</i>"
106     }
107    
108 elmex 1.26 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 elmex 1.33 sub view_seq_text {
120     my ($self, $text) = @_;
121     escapeHTML ($text)
122     }
123 elmex 1.26
124 pippijn 1.6 package PodRSS;
125    
126     use strict;
127     use warnings;
128     use utf8;
129    
130 elmex 1.33 use CGI qw/escapeHTML/;
131    
132 pippijn 1.6 use base "Pod::POM::View";
133    
134     our %metadata;
135 elmex 1.32 our $max_cnt;
136 pippijn 1.6
137     sub view_pod {
138     my ($self, $item) = @_;
139 pippijn 1.18 "<?xml version='1.0' encoding='utf-8'?>\n"
140     . "<rss version='2.0'>\n"
141 pippijn 1.17 . $item->content->present ($self)
142     . "</rss>\n"
143 pippijn 1.6 }
144    
145     sub view_head1 {
146     my ($self, $item) = @_;
147 elmex 1.32 " <channel>\n"
148 elmex 1.30 . " <link>$metadata{link}</link>\n"
149     . " <language>$metadata{language}</language>\n"
150 elmex 1.32 . " <title>" . $item->title->present ($self) . "</title>\n"
151 elmex 1.30 . $item->content->present ($self)
152     . " </channel>\n"
153 pippijn 1.6 }
154    
155     sub view_head2 {
156     my ($self, $item) = @_;
157 elmex 1.32 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 pippijn 1.6 }
168    
169 elmex 1.33 sub view_seq_link {
170 pippijn 1.6 my ($self, $item) = @_;
171 elmex 1.33 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 pippijn 1.6 }