ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
(Generate patch)

Comparing cfmaps/cfarch2html (file contents):
Revision 1.2 by root, Fri Nov 18 12:34:13 2005 UTC vs.
Revision 1.11 by root, Wed Nov 23 09:07:21 2005 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3# cfarch2html - convert crossfire archetypes to html
4# Copyright (C) 2005 Marc Lehmann <gvpe@schmorp.de>
5#
6# CFARCH2HTML is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with gvpe; if not, write to the Free Software
18# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20our $VERSION = '1.04';
2 21
3use Storable; 22use Storable;
4 23
5my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} 24my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
6 or die "\$CROSSFIRE_LIBDIR must be set\n"; 25 or die "\$CROSSFIRE_LIBDIR must be set\n";
7
8our $VERSION = '1.0';
9 26
10my $arch; 27my $arch;
11 28
12sub escape_html($) { 29sub escape_html($) {
13 local $_ = shift; 30 local $_ = shift;
15 $_ 32 $_
16} 33}
17 34
18$arch = Storable::retrieve "$LIBDIR/archetypes.pst"; 35$arch = Storable::retrieve "$LIBDIR/archetypes.pst";
19 36
20open my $fh, ">:utf8", "archetypes.html" 37system "rm", -rf => "a";
21 or die "archetypes.html: $!"; 38mkdir "a", 0777;
22
23select $fh;
24
25my $W = $meta->{width} * $T;
26my $H = $meta->{height} * $T;
27
28my (@path) = split /\//, $path;
29
30print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">",
31 "<html>",
32 "<head>",
33 "<title>Crossfire Archetypes</title>",
34 "<style type='text/css'><!--\n",
35 "body { background: white; text-color: black; }\n",
36 "a { text-color: blue; }\n",
37 "a:hover { text-color: red; }\n",
38 "a:visited { text-color: #008; }\n",
39
40 "li { white-space: pre; }\n",
41 "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n",
42 "-->\n</style>",
43 "</head>",
44 "<body>",
45 "<h1>Crossfire Archetypes</h1>";
46
47print "<table>";
48 39
49sub print_arch { 40sub print_arch {
50 my ($a) = @_; 41 my ($a) = @_;
51 print "<ul>"; 42 print "<ul>";
52 for (sort keys %$a) { 43 for (sort keys %$a) {
58 print "more =>\n"; 49 print "more =>\n";
59 print_arch ($a->{more}); 50 print_arch ($a->{more});
60 } elsif ($_ eq "other_arch") { 51 } elsif ($_ eq "other_arch") {
61 print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n"; 52 print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
62 } elsif ($_ eq "msg" || $_ eq "lore") { 53 } elsif ($_ eq "msg" || $_ eq "lore") {
63 print "<p class='m'>$v</p>"; 54 print "$_ =><p class='m'>$v</p>";
64 } else { 55 } else {
65 print "$_ => $v\n"; 56 print "$_ => $v\n";
66 } 57 }
67 print "</li>"; 58 print "</li>";
68 } 59 }
69 print "</ul>"; 60 print "</ul>";
70} 61}
62
71for my $name (sort keys %$arch) { 63for my $name (sort keys %$arch) {
72 print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>"; 64 open my $fh, ">:utf8", "a/$name.xhtml"
65 or die "a/$name.xhtml: $!";
66
67 select $fh;
68
69 print "<?xml version='1.0' encoding='utf-8'?>",
70 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
71 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
72 "<head>",
73 "<title>Crossfire Archetype '$name'</title>",
74 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>",
75 "</head>",
76 "<body>",
77 "<h1>Crossfire Archetype '$name'</h1>";
78
73 print_arch $arch->{$name}; 79 print_arch $arch->{$name};
74 print "</td></tr>"; 80
81 print "<p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfarch2html</a> version $VERSION</p>",
82 "</body></html>";
83
84 close $fh;
85
86 #system "gzip", "-7f", "arc.xhtml";
75} 87}
76 88
77print "</table><hr/><p style='font-size: 6pt'>created by <b>cfarch2html</b> version $VERSION</p>",
78 "</body></html>";
79 89
80close $fh;
81
82system "gzip", "-7f", "archetypes.html";
83__END__
84
85 print_archs $as;
86 print "</div></span>";
87 }
88 print "</td>";
89 }
90 print "</tr>";
91}
92
93}
94

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines