1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | # cfmap2html - convert deliantra maps to html |
3 | # cfmap2html - convert deliantra maps to html |
4 | # Copyright (C) 2005,2007,2008 Marc Lehmann <cfmaps@schmorp.de> |
4 | # Copyright (C) 2005,2007,2008,2009 Marc Lehmann <cfmaps@schmorp.de> |
5 | # |
5 | # |
6 | # CFMAP2HTML is free software; you can redistribute it and/or modify |
6 | # CFMAP2HTML 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 cfmaps; if not, write to the Free Software |
17 | # along with cfmaps; 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 | |
20 | our $VERSION = '2.112'; |
20 | our $VERSION = '2.122'; |
21 | |
21 | |
22 | use strict; |
22 | use strict; |
23 | |
23 | |
24 | use List::Util qw(min max); |
24 | use List::Util qw(min max); |
25 | use Deliantra; |
25 | use Deliantra; |
… | |
… | |
46 | } |
46 | } |
47 | |
47 | |
48 | system "cfmap2png", @cfmap2png |
48 | system "cfmap2png", @cfmap2png |
49 | if @cfmap2png; |
49 | if @cfmap2png; |
50 | |
50 | |
|
|
51 | Deliantra::load_archetypes; |
|
|
52 | |
51 | for my $path (@ARGV) { |
53 | for my $path (@ARGV) { |
52 | (my $base = $path) =~ s/\.map//; |
54 | (my $base = $path) =~ s/\.map//; |
53 | if (!-e "$base.xhtml" |
55 | if (!-e "$base.xhtml" |
54 | || -M "$base.xhtml" > -M "$base.map") { |
56 | || -M "$base.xhtml" > -M "$base.map") { |
55 | |
57 | |
56 | Deliantra::load_archetypes |
|
|
57 | unless %ARCH; |
|
|
58 | |
|
|
59 | my $meta = read_arch "$base.map"; |
58 | my $meta = eval { read_arch "$base.map" } |
|
|
59 | or next; |
60 | my $arch = $meta->{arch}; |
60 | my $arch = $meta->{arch}; |
61 | |
61 | |
62 | open my $fh, ">:utf8", "$base.xhtml" |
62 | open my $fh, ">:utf8", "$base.xhtml" |
63 | or die "$base.xhtml: $!"; |
63 | or die "$base.xhtml: $!"; |
64 | |
64 | |
… | |
… | |
124 | |
124 | |
125 | print "<p class='m'>", |
125 | print "<p class='m'>", |
126 | escape_html delete $info->{msg}, |
126 | escape_html delete $info->{msg}, |
127 | "</p>"; |
127 | "</p>"; |
128 | |
128 | |
|
|
129 | if (open my $fh, "<", "$base.png.err") { |
|
|
130 | local $/; |
|
|
131 | print "<p class='m'>", |
|
|
132 | (escape_html scalar <$fh>), |
|
|
133 | "</p>"; |
|
|
134 | } |
|
|
135 | |
129 | print "<table class='i'>", |
136 | print "<table class='i'>", |
130 | (map "<tr><td>" . (escape_html $_) . "</td><td>" . (escape_html $info->{$_}) . "</td></tr>", |
137 | (map "<tr><td>" . (escape_html $_) . "</td><td>" . (escape_html $info->{$_}) . "</td></tr>", |
131 | grep !/^_/, keys %$info), |
138 | grep !/^_/, keys %$info), |
132 | "</table>", |
139 | "</table>", |
133 | "<p />"; |
140 | "<p />"; |