ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.1
Committed: Fri Nov 18 12:04:12 2005 UTC (18 years, 6 months ago) by root
Branch: MAIN
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     "<title>archetypes</title>",
34     "<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     "<body>";
45    
46     print "<table>";
47    
48     sub print_arch {
49     my ($a) = @_;
50     print "<ul>";
51     for (sort keys %$a) {
52     next if $_ eq "_name";
53     my $v = escape_html $a->{$_};
54    
55     print "<li>";
56     if ($_ eq "more") {
57     print "more =>\n";
58     print_arch ($a->{more});
59     } elsif ($_ eq "other_arch") {
60     print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n";
61     } elsif ($_ eq "msg" || $_ eq "lore") {
62     print "<p class='m'>$v</p>";
63     } else {
64     print "$_ => $v\n";
65     }
66     print "</li>";
67     }
68     print "</ul>";
69     }
70     for my $name (sort keys %$arch) {
71     print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>";
72     print_arch $arch->{$name};
73     print "</td></tr>";
74     }
75    
76     print "</table><hr/><p style='font-size: 6pt'>created by <b>cfarch2html</b> version $VERSION</p>",
77     "</body></html>";
78    
79     close $fh;
80    
81     system "gzip", "-7f", "archetypes.html";
82     __END__
83    
84     print_archs $as;
85     print "</div></span>";
86     }
87     print "</td>";
88     }
89     print "</tr>";
90     }
91    
92     }
93