ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.4
Committed: Fri Nov 18 23:20:26 2005 UTC (18 years, 6 months ago) by root
Branch: MAIN
Changes since 1.3: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3     use Storable;
4    
5     my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
6     or die "\$CROSSFIRE_LIBDIR must be set\n";
7    
8     our $VERSION = '1.0';
9    
10     my $arch;
11    
12     sub escape_html($) {
13     local $_ = shift;
14     s/([<>&])/sprintf "&#%d;", ord $1/ge;
15     $_
16     }
17    
18     $arch = Storable::retrieve "$LIBDIR/archetypes.pst";
19    
20     open my $fh, ">:utf8", "archetypes.html"
21     or die "archetypes.html: $!";
22    
23     select $fh;
24    
25     my $W = $meta->{width} * $T;
26     my $H = $meta->{height} * $T;
27    
28     my (@path) = split /\//, $path;
29    
30     print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">",
31     "<html>",
32     "<head>",
33 root 1.2 "<title>Crossfire Archetypes</title>",
34 root 1.1 "<style type='text/css'><!--\n",
35     "body { background: white; text-color: black; }\n",
36     "a { text-color: blue; }\n",
37     "a:hover { text-color: red; }\n",
38     "a:visited { text-color: #008; }\n",
39    
40     "li { white-space: pre; }\n",
41     "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n",
42     "-->\n</style>",
43     "</head>",
44 root 1.2 "<body>",
45     "<h1>Crossfire Archetypes</h1>";
46 root 1.1
47     print "<table>";
48    
49     sub print_arch {
50     my ($a) = @_;
51     print "<ul>";
52     for (sort keys %$a) {
53     next if $_ eq "_name";
54     my $v = escape_html $a->{$_};
55    
56     print "<li>";
57     if ($_ eq "more") {
58     print "more =>\n";
59     print_arch ($a->{more});
60     } elsif ($_ eq "other_arch") {
61     print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
62     } elsif ($_ eq "msg" || $_ eq "lore") {
63 root 1.4 print "$_ =><p class='m'>$v</p>";
64 root 1.1 } else {
65     print "$_ => $v\n";
66     }
67     print "</li>";
68     }
69     print "</ul>";
70     }
71     for my $name (sort keys %$arch) {
72     print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>";
73     print_arch $arch->{$name};
74     print "</td></tr>";
75     }
76    
77 root 1.4 print "</table><hr/><p style='font-size: 8pt'>created by <b>cfarch2html</b> version $VERSION</p>",
78 root 1.1 "</body></html>";
79    
80     close $fh;
81    
82     system "gzip", "-7f", "archetypes.html";