ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/www/generate
(Generate patch)

Comparing deliantra/www/generate (file contents):
Revision 1.24 by root, Mon Mar 22 20:36:18 2010 UTC vs.
Revision 1.25 by elmex, Mon Apr 26 12:58:35 2010 UTC

19print FH $html; 19print FH $html;
20close FH; 20close FH;
21 21
22%PodRSS::metadata = %{ $pom->metadata }; 22%PodRSS::metadata = %{ $pom->metadata };
23$html = $pom->present ("PodRSS"); 23$html = $pom->present ("PodRSS");
24open FH, ">", "html/news.rss" or die "html/news.rss: $!"; 24open FH, ">", "src/news.rss" or die "src/news.rss: $!";
25print FH $html; 25print FH $html;
26close FH; 26close FH;
27 27
28system "rsync -avP src/. html/. --del --delete-excluded --exclude CVS"; 28system "rsync -avP src/. html/. --del --delete-excluded --exclude CVS";
29 29
30exit;
31
32# Static variables
33my $static = YAML::LoadFile "variables.yml";
34
35my @files = <src/*.html>;
36my @monsters = <monsters/*.html>;
37
38# Directory listings
39my $list;
40
41sub list {
42 my ($a, $b) = @_;
43 my $tmp = "<ul>\n";
44
45 my @listing = <$a/$b/*.html>;
46 for (@listing) {
47 my ($file) = $_ =~ /\/([^\/]+)$/;
48 $tmp .= " <li><a href=\"$a/$b/$file\">$file</a><br/>\n ";
49 $tmp .= do { local $/; open my $fh, "<$_.desc" or die "$_.desc: $!\n"; <$fh> };
50 $tmp .= " </li>\n";
51 }
52 $tmp .= "</ul>\n";
53 $list->{$a}->{$b} = $tmp;
54}
55
56# Directory listings
57list "doc", "user";
58list "doc", "development";
59
60sub generate {
61 my ($indir, $outdir, @list) = @_;
62
63 for my $file (@list) {
64 my @contents = do { open my $fh, "<$file" or die "$file: $!\n"; <$fh> };
65 my $subtitle = shift @contents;
66 chomp $subtitle;
67
68 my $curfile = $file;
69 $curfile =~ s/$indir\/(.+\.html)$/$1/;
70
71 my $tt = new Template {
72 INTERPOLATE => 1,
73 POST_CHOMP => 1,
74 EVAL_PERL => 1,
75 } or die "$Template::ERROR\n";
76
77 my $vars = { list => $list };
78
79 my $contents = "@contents";
80 my $data = ''; # Variable to store processed templates
81 $tt->process (\$contents, $vars, \$data)
82 or die $tt->error;
83
84 # Re-initialised with static variables from YAML
85 $vars = $static;
86 $vars->{subtitle} = $subtitle;
87 $vars->{contents} = $data;
88 $vars->{curfile} = $curfile;
89
90 my $output = ''; # Variable to store the complete page
91 $tt->process ('template.html', $vars, \$output)
92 or die $tt->error;
93
94 # Save the page to a html file
95 $file =~ s/$indir\/(.+\.html)$/$outdir\/$1/;
96 open HTML, ">$file";
97 print HTML $output;
98 close HTML;
99 }
100}
101
102my @rightbar;
103push @rightbar, "src/images/monsters/$_.png"
104 for @{ $static->{rightbar} };
105my @leftbar;
106push @leftbar, "src/images/runes/$_.png"
107 for @{ $static->{leftbar} };
108
109generate "src", "html", @files;
110generate "monsters", "html\/monsters", @monsters;
111
112system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @rightbar, "html/images/monsters-trans.png";
113system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @leftbar, "html/images/runes-trans.png";
114
115package PodHTML;
116
117use strict;
118use warnings;
119use utf8;
120
121my $rcsid = '$Id: generate,v 1.24 2010/03/22 20:36:18 root Exp $';
122
123use base "Pod::POM::View";
124
125our $subdir;
126our $dir;
127our $menu;
128
129sub view_pod {
130 my ($self, $item) = @_;
131 $item->content->present ($self)
132}
133
134sub view_head1 {
135 my ($self, $item) = @_;
136 $item->content->present ($self)
137}
138
139sub view_head2 {
140 my ($self, $item) = @_;
141 "<p><em><span class=\"date\">", $item->title, "</span> ", $item->content->present ($self), "</em></p>"
142}
143
144sub view_textblock {
145 my ($self, $item) = @_;
146 $item, "<br />"
147}
148
149sub view_seq_bold {
150 my ($self, $item) = @_;
151 "<b>$item</b>"
152}
153
154sub view_seq_file {
155 my ($self, $item) = @_;
156 "<tt>$item</tt>"
157}
158
159sub view_seq_link {
160 my ($self, $item) = @_;
161 my ($name, $href) = split /\|/, $item, 2;
162 "<a href=\"$href\">$name</a>"
163}
164
165=head1 AUTHOR 30=head1 AUTHOR
166 31
32Copyright © 2010 The Deliantra Team
167Copyright © 2007 Pippijn van Steenhoven 33Copyright © 2007 Pippijn van Steenhoven
168 34
169=head1 LICENSE 35=head1 LICENSE
170 36
171This library is free software, you can redistribute it and/or modify 37This library is free software, you can redistribute it and/or modify
172it under the terms of the GNU General Public License. 38it under the terms of the GNU General Public License.
173 39
174=cut 40=cut
175 41
1761; 421;
177
178 43
179package PodRSS; 44package PodRSS;
180 45
181use strict; 46use strict;
182use warnings; 47use warnings;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines