ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.5
Committed: Sun Nov 20 00:58:57 2005 UTC (18 years, 6 months ago) by root
Branch: MAIN
Changes since 1.4: +17 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.5 # 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 root 1.1 use Storable;
21    
22     my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
23     or die "\$CROSSFIRE_LIBDIR must be set\n";
24    
25     our $VERSION = '1.0';
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", "archetypes.html"
38     or die "archetypes.html: $!";
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 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">",
48     "<html>",
49     "<head>",
50 root 1.2 "<title>Crossfire Archetypes</title>",
51 root 1.1 "<style type='text/css'><!--\n",
52     "body { background: white; text-color: black; }\n",
53     "a { text-color: blue; }\n",
54     "a:hover { text-color: red; }\n",
55     "a:visited { text-color: #008; }\n",
56    
57     "li { white-space: pre; }\n",
58     "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n",
59     "-->\n</style>",
60     "</head>",
61 root 1.2 "<body>",
62     "<h1>Crossfire Archetypes</h1>";
63 root 1.1
64     print "<table>";
65    
66     sub print_arch {
67     my ($a) = @_;
68     print "<ul>";
69     for (sort keys %$a) {
70     next if $_ eq "_name";
71     my $v = escape_html $a->{$_};
72    
73     print "<li>";
74     if ($_ eq "more") {
75     print "more =>\n";
76     print_arch ($a->{more});
77     } elsif ($_ eq "other_arch") {
78     print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
79     } elsif ($_ eq "msg" || $_ eq "lore") {
80 root 1.4 print "$_ =><p class='m'>$v</p>";
81 root 1.1 } else {
82     print "$_ => $v\n";
83     }
84     print "</li>";
85     }
86     print "</ul>";
87     }
88     for my $name (sort keys %$arch) {
89     print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>";
90     print_arch $arch->{$name};
91     print "</td></tr>";
92     }
93    
94 root 1.4 print "</table><hr/><p style='font-size: 8pt'>created by <b>cfarch2html</b> version $VERSION</p>",
95 root 1.1 "</body></html>";
96    
97     close $fh;
98    
99     system "gzip", "-7f", "archetypes.html";