ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cfmaps/cfarch2html
Revision: 1.9
Committed: Sun Nov 20 20:37:13 2005 UTC (20 years, 10 months ago) by root
Branch: MAIN
Changes since 1.8: +0 -1 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.8 our $VERSION = '1.03';
21 root 1.6
22 root 1.1 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 root 1.7 open my $fh, ">:utf8", "arc.xhtml"
38     or die "arc.xhtml: $!";
39 root 1.1
40     select $fh;
41    
42     my $W = $meta->{width} * $T;
43     my $H = $meta->{height} * $T;
44    
45     my (@path) = split /\//, $path;
46    
47 root 1.7 print "<?xml version='1.0' encoding='utf-8'?>",
48     "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
49 root 1.1 "<head>",
50 root 1.2 "<title>Crossfire Archetypes</title>",
51 root 1.8 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>",
52 root 1.1 "</head>",
53 root 1.2 "<body>",
54     "<h1>Crossfire Archetypes</h1>";
55 root 1.1
56     print "<table>";
57    
58     sub print_arch {
59     my ($a) = @_;
60     print "<ul>";
61     for (sort keys %$a) {
62     next if $_ eq "_name";
63     my $v = escape_html $a->{$_};
64    
65     print "<li>";
66     if ($_ eq "more") {
67     print "more =>\n";
68     print_arch ($a->{more});
69     } elsif ($_ eq "other_arch") {
70     print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
71     } elsif ($_ eq "msg" || $_ eq "lore") {
72 root 1.4 print "$_ =><p class='m'>$v</p>";
73 root 1.1 } else {
74     print "$_ => $v\n";
75     }
76     print "</li>";
77     }
78     print "</ul>";
79     }
80     for my $name (sort keys %$arch) {
81 root 1.7 print "<tr valign='top'><th align='left'><a id='", (lc $name), "'>$name</a></th><td>";
82 root 1.1 print_arch $arch->{$name};
83     print "</td></tr>";
84     }
85    
86 root 1.8 print "</table><p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfarch2html</a> version $VERSION</p>",
87 root 1.1 "</body></html>";
88    
89     close $fh;
90    
91 root 1.7 system "gzip", "-7f", "arc.xhtml";
92