ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.7
Committed: Sun Nov 20 03:31:58 2005 UTC (18 years, 6 months ago) by root
Branch: MAIN
Changes since 1.6: +11 -9 lines
Log Message:
*** empty log message ***

File Contents

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