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

Comparing cfmaps/cfmap2html (file contents):
Revision 1.10 by root, Sun Nov 20 01:05:34 2005 UTC vs.
Revision 1.11 by root, Sun Nov 20 03:31:58 2005 UTC

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 = '1.05'; 20our $VERSION = '1.11';
21 21
22use Storable; 22use Storable;
23 23
24my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} 24my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
25 or die "\$CROSSFIRE_LIBDIR must be set\n"; 25 or die "\$CROSSFIRE_LIBDIR must be set\n";
26 26
27my $T = 32; 27my $T = 32;
28 28
29my $arch; 29my $arch;
30
31umask 022;
32 30
33sub escape_html($) { 31sub escape_html($) {
34 local $_ = shift; 32 local $_ = shift;
35 s/([<>&])/sprintf "&#%d;", ord $1/ge; 33 s/([<>&])/sprintf "&#%d;", ord $1/ge;
36 $_ 34 $_
49 }; 47 };
50 48
51 $arch ||= Storable::retrieve "$LIBDIR/archetypes.pst"; 49 $arch ||= Storable::retrieve "$LIBDIR/archetypes.pst";
52 my $meta = Storable::retrieve "$path.pst"; 50 my $meta = Storable::retrieve "$path.pst";
53 51
54 open my $fh, ">:utf8", "$path.html" 52 open my $fh, ">:utf8", "$path.xhtml"
55 or die "$path.html: $!"; 53 or die "$path.xhtml: $!";
56 54
57 select $fh; 55 select $fh;
58 56
59 my $W = $meta->{width} * $T; 57 my $W = $meta->{width} * $T;
60 my $H = $meta->{height} * $T; 58 my $H = $meta->{height} * $T;
61 59
62 my (@path) = split /\//, $path; 60 my (@path) = split /\//, $path;
63 61
62 print "<?xml version='1.0' encoding='utf-8'?>",
64 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">", 63 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
65 "<html>", 64 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
66 "<head>", 65 "<head>",
67 "<title>Crossfire Map \"$path\"</title>", 66 "<title>Crossfire Map \"$path\"</title>",
68 "<style type='text/css'><!--\n", 67 "<style type='text/css'>\n",
69 "body { background: white; color: black; }\n", 68 "body { background: white; color: black; }\n",
70 "a { color: blue; }\n", 69 "a { color: blue; }\n",
71 "a:hover { color: #800; }\n", 70 "a:hover { color: #800; }\n",
72 "a:active { color: #f00; }\n", 71 "a:active { color: #f00; }\n",
73 "a:visited { color: #008; }\n", 72 "a:visited { color: #008; }\n",
91 ".map div { display: none; position: absolute; min-width: 40em; ", 90 ".map div { display: none; position: absolute; min-width: 40em; ",
92 "font-size: 8pt; border: 0px; background: #eee; border: 3px solid yellow; border-style: ridge; padding: 4px; }\n", 91 "font-size: 8pt; border: 0px; background: #eee; border: 3px solid yellow; border-style: ridge; padding: 4px; }\n",
93 ".map td:hover div { display: block; position: absolute; z-index: 1; top: -1px; left: ${T}px; white-space: pre; }\n", 92 ".map td:hover div { display: block; position: absolute; z-index: 1; top: -1px; left: ${T}px; white-space: pre; }\n",
94 93
95 "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n", 94 "p.m { white-space: pre; margin-left: 2em; background: #ddd; padding: 2px; border: 1px solid black; }\n",
96 "-->\n</style>", 95 "</style>",
97 "</head>", 96 "</head>",
98 "<body>"; 97 "<body>";
99 98
100 print "<table class='nav'>", 99 print "<table class='nav'>",
101 "<tr style='vertical-align: middle;'><td rowspan='3' style='padding-right: 3em'>", 100 "<tr style='vertical-align: middle;'><td rowspan='3' style='padding-right: 3em'>",
104 print "<a href='/'>/</a> "; 103 print "<a href='/'>/</a> ";
105 for (0 .. $#path - 1) { 104 for (0 .. $#path - 1) {
106 print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / "; 105 print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / ";
107 } 106 }
108 107
108 my @dir = qw(none up right down left);
109 my @tile = map { 109 my @tile = map {
110 $meta->{info}{"tile_path_$_"} 110 $meta->{info}{"tile_path_$_"}
111 ? "<a href='$meta->{info}{\"tile_path_$_\"}.html'><img class='tile' src='$meta->{info}{\"tile_path_$_\"}.jpg' alt='tile_path_$_'/></a>" 111 ? "<a href='$meta->{info}{\"tile_path_$_\"}.xhtml'><img class='tile' src='$meta->{info}{\"tile_path_$_\"}.jpg' alt='$dir[$_]'/></a>"
112 : "" 112 : ""
113 } 1..4; 113 } 1..4;
114 #"}"# vim misparses without this comment 114 #"}"# vim misparses without this comment
115 115
116 print "$path[-1]", 116 print "$path[-1]",
147 my $o = $arch->{$a->{_name}}; 147 my $o = $arch->{$a->{_name}};
148 my $type = $a->{type} || $o->{type}; 148 my $type = $a->{type} || $o->{type};
149 my $aname = escape_html $a->{_name}; 149 my $aname = escape_html $a->{_name};
150 my $name = escape_html $a->{name} || $o->{name}; 150 my $name = escape_html $a->{name} || $o->{name};
151 151
152 print "<li><a href='/archetypes.html#", (lc $a->{_name}), "'>$aname \"$name\"</a>\n"; 152 print "<li><a href='/arc.xhtml#", (lc $a->{_name}), "'>$aname \"$name\"</a>\n";
153 for (sort keys %$a) { 153 for (sort keys %$a) {
154 next if $ignore{$_}; 154 next if $ignore{$_};
155 my $v = escape_html $a->{$_}; 155 my $v = escape_html $a->{$_};
156 156
157 if (($type == 66 || $type == 41) && $_ eq "slaying") { # door, teleporter 157 if ($_ eq "slaying" && ($type == 41 || $type == 57 || $type == 66)) { # door, teleporter, player_changer
158 $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 158 $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1
159 if $v eq "/!"; # random map 159 if $v eq "/!"; # random map
160 160
161 print "slaying => <a href='$v.html'>$v</a>\n"; 161 print "slaying => <a href='$v.xhtml'>$v</a>\n";
162 } elsif ($_ eq "other_arch") { 162 } elsif ($_ eq "other_arch") {
163 print "$_ => <a href='/archetypes.html#", (lc $a->{$_}), "'>$v</a>\n"; 163 print "$_ => <a href='/arc.xhtml#", (lc $a->{$_}), "'>$v</a>\n";
164 } elsif ($_ eq "inventory") { 164 } elsif ($_ eq "inventory") {
165 print "inventory =>\n"; 165 print "inventory =>\n";
166 print_archs ($a->{$_}); 166 print_archs ($a->{$_});
167 } elsif ($_ eq "msg") { 167 } elsif ($_ eq "msg") {
168 print "<p class='m'>$v</p>"; 168 print "<p class='m'>$v</p>";
188 print "</table><hr/><p style='font-size: 8pt'>created by <a href='http://software.schmorp.de/#crossfire'>cfmap2html</a> version $VERSION</p>", 188 print "</table><hr/><p style='font-size: 8pt'>created by <a href='http://software.schmorp.de/#crossfire'>cfmap2html</a> version $VERSION</p>",
189 "<p style='width: ${W2}px; height: 600px;'/></body></html>"; 189 "<p style='width: ${W2}px; height: 600px;'/></body></html>";
190 190
191 close $fh; 191 close $fh;
192 192
193 system "gzip", "-7f", "$path.html"; 193 system "gzip", "-7f", "$path.xhtml";
194} 194}
195 195

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines