ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.10
Committed: Tue Nov 22 17:54:41 2005 UTC (18 years, 6 months ago) by root
Branch: MAIN
Changes since 1.9: +2 -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 root 1.10 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
49 root 1.7 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
50 root 1.1 "<head>",
51 root 1.2 "<title>Crossfire Archetypes</title>",
52 root 1.8 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>",
53 root 1.1 "</head>",
54 root 1.2 "<body>",
55     "<h1>Crossfire Archetypes</h1>";
56 root 1.1
57     print "<table>";
58    
59     sub print_arch {
60     my ($a) = @_;
61     print "<ul>";
62     for (sort keys %$a) {
63     next if $_ eq "_name";
64     my $v = escape_html $a->{$_};
65    
66     print "<li>";
67     if ($_ eq "more") {
68     print "more =>\n";
69     print_arch ($a->{more});
70     } elsif ($_ eq "other_arch") {
71     print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
72     } elsif ($_ eq "msg" || $_ eq "lore") {
73 root 1.4 print "$_ =><p class='m'>$v</p>";
74 root 1.1 } else {
75     print "$_ => $v\n";
76     }
77     print "</li>";
78     }
79     print "</ul>";
80     }
81     for my $name (sort keys %$arch) {
82 root 1.7 print "<tr valign='top'><th align='left'><a id='", (lc $name), "'>$name</a></th><td>";
83 root 1.1 print_arch $arch->{$name};
84     print "</td></tr>";
85     }
86    
87 root 1.8 print "</table><p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfarch2html</a> version $VERSION</p>",
88 root 1.1 "</body></html>";
89    
90     close $fh;
91    
92 root 1.10 #system "gzip", "-7f", "arc.xhtml";
93 root 1.7