ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
(Generate patch)

Comparing cfmaps/cfarch2html (file contents):
Revision 1.5 by root, Sun Nov 20 00:58:57 2005 UTC vs.
Revision 1.16 by root, Thu Jun 21 01:11:44 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# cfarch2html - convert crossfire archetypes to html 3# cfarch2html - convert crossfire archetypes to html
4# Copyright (C) 2005 Marc Lehmann <gvpe@schmorp.de> 4# Copyright (C) 2005,2007 Marc Lehmann <cfmaps@schmorp.de>
5# 5#
6# CFARCH2HTML is free software; you can redistribute it and/or modify 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 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 8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version. 9# (at your option) any later version.
15# 15#
16# You should have received a copy of the GNU General Public License 16# You should have received a copy of the GNU General Public License
17# along with gvpe; if not, write to the Free Software 17# along with gvpe; if not, write to the Free Software
18# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 19
20our $VERSION = '2.001';
21
22use Crossfire 1.0;
20use Storable; 23use Storable;
21
22my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
23 or die "\$CROSSFIRE_LIBDIR must be set\n";
24
25our $VERSION = '1.0';
26
27my $arch;
28 24
29sub escape_html($) { 25sub escape_html($) {
30 local $_ = shift; 26 local $_ = shift;
31 s/([<>&])/sprintf "&#%d;", ord $1/ge; 27 s/([<>&])/sprintf "&#%d;", ord $1/ge;
32 $_ 28 $_
33} 29}
34 30
35$arch = Storable::retrieve "$LIBDIR/archetypes.pst"; 31system "rm", -rf => "a";
36 32mkdir "a", 0777;
37open my $fh, ">:utf8", "archetypes.html"
38 or die "archetypes.html: $!";
39
40select $fh;
41
42my $W = $meta->{width} * $T;
43my $H = $meta->{height} * $T;
44
45my (@path) = split /\//, $path;
46
47print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">",
48 "<html>",
49 "<head>",
50 "<title>Crossfire Archetypes</title>",
51 "<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 "<body>",
62 "<h1>Crossfire Archetypes</h1>";
63
64print "<table>";
65 33
66sub print_arch { 34sub print_arch {
67 my ($a) = @_; 35 my ($a) = @_;
68 print "<ul>"; 36 print "<ul>";
69 for (sort keys %$a) { 37 for (sort keys %$a) {
70 next if $_ eq "_name"; 38 next if $_ eq "_name";
39 next if $_ eq "_atype";
71 my $v = escape_html $a->{$_}; 40 my $v = escape_html $a->{$_};
72 41
73 print "<li>"; 42 print "<li>";
74 if ($_ eq "more") { 43 if ($_ eq "more") {
75 print "more =>\n"; 44 print "more =>\n";
76 print_arch ($a->{more}); 45 print_arch ($a->{more});
77 } elsif ($_ eq "other_arch") { 46 } elsif ($_ eq "other_arch") {
78 print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n"; 47 print "$_ => <a href='#$a->{$_}'>$v</a>\n";
79 } elsif ($_ eq "msg" || $_ eq "lore") { 48 } elsif ($_ eq "msg" || $_ eq "lore") {
80 print "$_ =><p class='m'>$v</p>"; 49 print "$_ =><p class='m'>$v</p>";
81 } else { 50 } else {
82 print "$_ => $v\n"; 51 print "$_ => $v\n";
83 } 52 }
84 print "</li>"; 53 print "</li>";
85 } 54 }
86 print "</ul>"; 55 print "</ul>";
87} 56}
57
58Crossfire::load_archetypes;
59
88for my $name (sort keys %$arch) { 60for my $name (sort keys %ARCH) {
89 print "<tr valign='top'><th align='left'><a name='", (lc $name), "'>$name</a></th><td>"; 61 open my $fh, ">:utf8", "a/$name.xhtml"
62 or die "a/$name.xhtml: $!";
63
64 select $fh;
65
66 print "<?xml version='1.0' encoding='utf-8'?>",
67 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
68 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
69 "<head>",
70 "<title>Crossfire Archetype '$name'</title>",
71 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>",
72 "</head>",
73 "<body>",
74 "<h1>Crossfire Archetype '$name'</h1>";
75
90 print_arch $arch->{$name}; 76 print_arch $ARCH{$name};
91 print "</td></tr>"; 77
78 print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>",
79 "</body></html>";
80
81 close $fh;
82
83 #system "gzip", "-7f", "arc.xhtml";
92} 84}
93 85
94print "</table><hr/><p style='font-size: 8pt'>created by <b>cfarch2html</b> version $VERSION</p>",
95 "</body></html>";
96 86
97close $fh;
98
99system "gzip", "-7f", "archetypes.html";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines