… | |
… | |
19 | print FH $html; |
19 | print FH $html; |
20 | close FH; |
20 | close FH; |
21 | |
21 | |
22 | %PodRSS::metadata = %{ $pom->metadata }; |
22 | %PodRSS::metadata = %{ $pom->metadata }; |
23 | $html = $pom->present ("PodRSS"); |
23 | $html = $pom->present ("PodRSS"); |
24 | open FH, ">", "html/news.rss" or die "html/news.rss: $!"; |
24 | open FH, ">", "src/news.rss" or die "src/news.rss: $!"; |
25 | print FH $html; |
25 | print FH $html; |
26 | close FH; |
26 | close FH; |
27 | |
27 | |
28 | system "rsync -avP src/. html/. --del --delete-excluded --exclude CVS"; |
28 | system "rsync -avP src/. html/. --del --delete-excluded --exclude CVS"; |
29 | |
29 | |
30 | exit; |
|
|
31 | |
|
|
32 | # Static variables |
|
|
33 | my $static = YAML::LoadFile "variables.yml"; |
|
|
34 | |
|
|
35 | my @files = <src/*.html>; |
|
|
36 | my @monsters = <monsters/*.html>; |
|
|
37 | |
|
|
38 | # Directory listings |
|
|
39 | my $list; |
|
|
40 | |
|
|
41 | sub 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 |
|
|
57 | list "doc", "user"; |
|
|
58 | list "doc", "development"; |
|
|
59 | |
|
|
60 | sub 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 | |
|
|
102 | my @rightbar; |
|
|
103 | push @rightbar, "src/images/monsters/$_.png" |
|
|
104 | for @{ $static->{rightbar} }; |
|
|
105 | my @leftbar; |
|
|
106 | push @leftbar, "src/images/runes/$_.png" |
|
|
107 | for @{ $static->{leftbar} }; |
|
|
108 | |
|
|
109 | generate "src", "html", @files; |
|
|
110 | generate "monsters", "html\/monsters", @monsters; |
|
|
111 | |
|
|
112 | system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @rightbar, "html/images/monsters-trans.png"; |
|
|
113 | system "montage", "-background", "none", "+frame", "+shadow", "+label", "-geometry", "+0+0", "-tile", "1x15", @leftbar, "html/images/runes-trans.png"; |
|
|
114 | |
|
|
115 | package PodHTML; |
|
|
116 | |
|
|
117 | use strict; |
|
|
118 | use warnings; |
|
|
119 | use utf8; |
|
|
120 | |
|
|
121 | my $rcsid = '$Id: generate,v 1.24 2010/03/22 20:36:18 root Exp $'; |
|
|
122 | |
|
|
123 | use base "Pod::POM::View"; |
|
|
124 | |
|
|
125 | our $subdir; |
|
|
126 | our $dir; |
|
|
127 | our $menu; |
|
|
128 | |
|
|
129 | sub view_pod { |
|
|
130 | my ($self, $item) = @_; |
|
|
131 | $item->content->present ($self) |
|
|
132 | } |
|
|
133 | |
|
|
134 | sub view_head1 { |
|
|
135 | my ($self, $item) = @_; |
|
|
136 | $item->content->present ($self) |
|
|
137 | } |
|
|
138 | |
|
|
139 | sub view_head2 { |
|
|
140 | my ($self, $item) = @_; |
|
|
141 | "<p><em><span class=\"date\">", $item->title, "</span> ", $item->content->present ($self), "</em></p>" |
|
|
142 | } |
|
|
143 | |
|
|
144 | sub view_textblock { |
|
|
145 | my ($self, $item) = @_; |
|
|
146 | $item, "<br />" |
|
|
147 | } |
|
|
148 | |
|
|
149 | sub view_seq_bold { |
|
|
150 | my ($self, $item) = @_; |
|
|
151 | "<b>$item</b>" |
|
|
152 | } |
|
|
153 | |
|
|
154 | sub view_seq_file { |
|
|
155 | my ($self, $item) = @_; |
|
|
156 | "<tt>$item</tt>" |
|
|
157 | } |
|
|
158 | |
|
|
159 | sub 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 | |
|
|
32 | Copyright © 2010 The Deliantra Team |
167 | Copyright © 2007 Pippijn van Steenhoven |
33 | Copyright © 2007 Pippijn van Steenhoven |
168 | |
34 | |
169 | =head1 LICENSE |
35 | =head1 LICENSE |
170 | |
36 | |
171 | This library is free software, you can redistribute it and/or modify |
37 | This library is free software, you can redistribute it and/or modify |
172 | it under the terms of the GNU General Public License. |
38 | it under the terms of the GNU General Public License. |
173 | |
39 | |
174 | =cut |
40 | =cut |
175 | |
41 | |
176 | 1; |
42 | 1; |
177 | |
|
|
178 | |
43 | |
179 | package PodRSS; |
44 | package PodRSS; |
180 | |
45 | |
181 | use strict; |
46 | use strict; |
182 | use warnings; |
47 | use warnings; |