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

Comparing cfmaps/cfarch2html (file contents):
Revision 1.1 by root, Fri Nov 18 12:04:12 2005 UTC vs.
Revision 1.7 by root, Sun Nov 20 03:31:58 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.02';
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" 37open my $fh, ">:utf8", "arc.xhtml"
21 or die "archetypes.html: $!"; 38 or die "arc.xhtml: $!";
22 39
23select $fh; 40select $fh;
24 41
25my $W = $meta->{width} * $T; 42my $W = $meta->{width} * $T;
26my $H = $meta->{height} * $T; 43my $H = $meta->{height} * $T;
27 44
28my (@path) = split /\//, $path; 45my (@path) = split /\//, $path;
29 46
47print "<?xml version='1.0' encoding='utf-8'?>",
30print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">", 48 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
31 "<html>", 49 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
32 "<head>", 50 "<head>",
33 "<title>archetypes</title>", 51 "<title>Crossfire Archetypes</title>",
34 "<style type='text/css'><!--\n", 52 "<style type='text/css'>\n",
35 "body { background: white; text-color: black; }\n", 53 "body { background: white; text-color: black; }\n",
36 "a { text-color: blue; }\n", 54 "a { text-color: blue; }\n",
37 "a:hover { text-color: red; }\n", 55 "a:hover { text-color: red; }\n",
38 "a:visited { text-color: #008; }\n", 56 "a:visited { text-color: #008; }\n",
39 57
40 "li { white-space: pre; }\n", 58 "li { white-space: pre; }\n",
41 "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n", 59 "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n",
42 "-->\n</style>", 60 "\n</style>",
43 "</head>", 61 "</head>",
44 "<body>"; 62 "<body>",
63 "<h1>Crossfire Archetypes</h1>";
45 64
46print "<table>"; 65print "<table>";
47 66
48sub print_arch { 67sub print_arch {
49 my ($a) = @_; 68 my ($a) = @_;
57 print "more =>\n"; 76 print "more =>\n";
58 print_arch ($a->{more}); 77 print_arch ($a->{more});
59 } elsif ($_ eq "other_arch") { 78 } elsif ($_ eq "other_arch") {
60 print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n"; 79 print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
61 } elsif ($_ eq "msg" || $_ eq "lore") { 80 } elsif ($_ eq "msg" || $_ eq "lore") {
62 print "<p class='m'>$v</p>"; 81 print "$_ =><p class='m'>$v</p>";
63 } else { 82 } else {
64 print "$_ => $v\n"; 83 print "$_ => $v\n";
65 } 84 }
66 print "</li>"; 85 print "</li>";
67 } 86 }
68 print "</ul>"; 87 print "</ul>";
69} 88}
70for my $name (sort keys %$arch) { 89for my $name (sort keys %$arch) {
71 print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>"; 90 print "<tr valign='top'><th align='left'><a id='", (lc $name), "'>$name</a></th><td>";
72 print_arch $arch->{$name}; 91 print_arch $arch->{$name};
73 print "</td></tr>"; 92 print "</td></tr>";
74} 93}
75 94
76print "</table><hr/><p style='font-size: 6pt'>created by <b>cfarch2html</b> version $VERSION</p>", 95print "</table><hr/><p style='font-size: 8pt'>created by <a href='http://software.schmorp.de/#crossfire'>cfarch2html</a> version $VERSION</p>",
77 "</body></html>"; 96 "</body></html>";
78 97
79close $fh; 98close $fh;
80 99
81system "gzip", "-7f", "archetypes.html"; 100system "gzip", "-7f", "arc.xhtml";
82__END__
83 101
84 print_archs $as;
85 print "</div></span>";
86 }
87 print "</td>";
88 }
89 print "</tr>";
90}
91
92}
93

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines