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

Comparing cfmaps/cfmap2html (file contents):
Revision 1.5 by root, Fri Nov 18 12:04:12 2005 UTC vs.
Revision 1.7 by root, Fri Nov 18 23:20:26 2005 UTC

9 9
10my $arch; 10my $arch;
11 11
12umask 022; 12umask 022;
13 13
14our $VERSION = '1.0'; 14our $VERSION = '1.01';
15 15
16sub escape_html($) { 16sub escape_html($) {
17 local $_ = shift; 17 local $_ = shift;
18 s/([<>&])/sprintf "&#%d;", ord $1/ge; 18 s/([<>&])/sprintf "&#%d;", ord $1/ge;
19 $_ 19 $_
45 my (@path) = split /\//, $path; 45 my (@path) = split /\//, $path;
46 46
47 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">", 47 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">",
48 "<html>", 48 "<html>",
49 "<head>", 49 "<head>",
50 "<title>$path</title>", 50 "<title>Crossfire Map \"$path\"</title>",
51 "<style type='text/css'><!--\n", 51 "<style type='text/css'><!--\n",
52 "body { background: white; text-color: black; }\n", 52 "body { background: white; text-color: black; }\n",
53 "a { text-color: blue; }\n", 53 "a { text-color: blue; }\n",
54 "a:hover { text-color: red; }\n",
55 "a:visited { text-color: #008; }\n", 54 "a:visited { text-color: #008; }\n",
55 "img { display: block; }\n",
56 56
57 "#nav { border-spacing: 0px; margin: 10px; padding: 0px; }\n", 57 "#nav { border-spacing: 0px; margin: 10px; padding: 0px; }\n",
58 "#nav td { margin: 0px; padding: 0px; border: 0px; }\n", 58 "#nav td { margin: 0px; padding: 0px; border: 0px; }\n",
59 "#thumb { border: 2px solid yellow; width: $meta->{width}px; height: $meta->{height}px; padding: 0px; }\n", 59 "#thumb { border: 3px solid yellow; width: $meta->{width}px; height: $meta->{height}px; padding: 0px; }\n",
60 ".tile { border: 3px solid blue; }\n",
61 ".tile:hover { border: 3px solid yellow; }\n",
60 62
61 "#map { table-layout: fixed; width: ${W}px; height: ${H}px; border: 2px solid #777; border-spacing: 0px; ", 63 "#map { table-layout: fixed; width: ${W}px; height: ${H}px; border: 2px solid #777; border-spacing: 0px; ",
62 "background-image: url($path[-1].png); background-position: 0px 0px; background-repeat: no-repeat; background-attachment: relative; }\n", 64 "background-image: url($path[-1].png); background-position: 0px 0px; background-repeat: no-repeat; background-attachment: relative; }\n",
63 "#map tr { width: ${W}px; height: ${T}px; border-style: none; margin: 0px; padding: 0px; }\n", 65 "#map tr { width: ${W}px; height: ${T}px; border-style: none; margin: 0px; padding: 0px; }\n",
64 66
75 "-->\n</style>", 77 "-->\n</style>",
76 "</head>", 78 "</head>",
77 "<body>"; 79 "<body>";
78 80
79 print "<table id='nav'>", 81 print "<table id='nav'>",
80 "<tr valign='center'><td rowspan='3' style='padding-right: 3em'><h1>"; 82 "<tr valign='center'><td rowspan='3' style='padding-right: 3em'>",
83 "Crossfire Map<br/>",
84 "<span style='font-size: 18pt'>";
81 print "<a href='/'>/</a> "; 85 print "<a href='/'>/</a> ";
82 for (0 .. $#path - 1) { 86 for (0 .. $#path - 1) {
83 print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / "; 87 print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / ";
84 } 88 }
85 89
86 my @tile = map { 90 my @tile = map {
87 $meta->{info}{"tile_path_$_"} 91 $meta->{info}{"tile_path_$_"}
88 ? "<a href='$meta->{info}{\"tile_path_$_\"}.html'><img style='border: 2px solid blue;' src='$meta->{info}{\"tile_path_$_\"}.jpg'/></a>" 92 ? "<a href='$meta->{info}{\"tile_path_$_\"}.html'><img class='tile' src='$meta->{info}{\"tile_path_$_\"}.jpg'/></a>"
89 : "" 93 : ""
90 } 1..4; 94 } 1..4;
91 #"}"# vim misparses without this comment 95 #"}"# vim misparses without this comment
92 96
93 print "$path[-1]", 97 print "$path[-1]",
94 "</h1>", 98 "</span>",
95 "<p style='font-size: 8pt;'><a href='/about.txt'>[more about cfmaps.schmorp.de]</a></p>", 99 "<p style='font-size: 8pt;'><a href='/about.txt'>[more about cfmaps.schmorp.de]</a></p>",
96 "</td>", 100 "</td>",
97 "<td/><td>$tile[0]</td><td/></tr>", 101 "<td/><td>$tile[0]</td><td/></tr>",
98 "<tr><td>$tile[3]</td>", 102 "<tr><td>$tile[3]</td>",
99 "<td><img id='thumb' src='@path[-1].jpg'/></td>", 103 "<td><img id='thumb' src='@path[-1].jpg'/></td>",
107 escape_html $meta->{info}{msg}, 111 escape_html $meta->{info}{msg},
108 "</p>"; 112 "</p>";
109 113
110 print "<table id='map'>"; 114 print "<table id='map'>";
111 115
112 my %ignore = map +($_ => 1), qw(_name x y); 116 my %ignore = map +($_ => 1), qw(name _name x y);
113 117
114 for my $y (0.. $meta->{height} - 1) { 118 for my $y (0.. $meta->{height} - 1) {
115 print "<tr>"; 119 print "<tr>";
116 for my $x (0.. $meta->{width} - 1) { 120 for my $x (0.. $meta->{width} - 1) {
117 print "<td>"; 121 print "<td>";
120 124
121 sub print_archs { 125 sub print_archs {
122 print "<ul>"; 126 print "<ul>";
123 for my $a (@{$_[0]}) { 127 for my $a (@{$_[0]}) {
124 my $o = $arch->{$a->{_name}}; 128 my $o = $arch->{$a->{_name}};
129 my $aname = escape_html $a->{_name};
130 my $name = escape_html $a->{name} || $o->{name};
125 print "<li><a href='/archetypes.html#", (lc $a->{_name}), "'>\"$o->{name}\" ($a->{_name})</a>\n"; 131 print "<li><a href='/archetypes.html#", (lc $a->{_name}), "'>$aname \"$name\"</a>\n";
126 for (sort keys %$a) { 132 for (sort keys %$a) {
127 next if $ignore{$_}; 133 next if $ignore{$_};
128 my $v = escape_html $a->{$_}; 134 my $v = escape_html $a->{$_};
129 135
130 if (($o->{type} == 66 || $o->{type} == 41) && $_ eq "slaying") { # door, teleporter 136 if (($o->{type} == 66 || $o->{type} == 41) && $_ eq "slaying") { # door, teleporter
153 print "</td>"; 159 print "</td>";
154 } 160 }
155 print "</tr>"; 161 print "</tr>";
156 } 162 }
157 163
158 print "</table></p><hr/><p style='font-size: 6pt'>created by <b>cfmap2html</b> version $VERSION</p>", 164 print "</table></p><hr/><p style='font-size: 8pt'>created by <b>cfmap2html</b> version $VERSION</p>",
159 "<p style='height: 600px;'/></body></html>"; 165 "<p style='height: 600px;'/></body></html>";
160 166
161 close $fh; 167 close $fh;
162 168
163 system "gzip", "-7f", "$path.html"; 169 system "gzip", "-7f", "$path.html";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines