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 | |
20 | our $VERSION = '1.03'; |
20 | our $VERSION = '1.052'; |
21 | |
21 | |
22 | use Storable; |
22 | use Storable; |
23 | |
23 | |
24 | my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} |
24 | my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} |
25 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
25 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
… | |
… | |
32 | $_ |
32 | $_ |
33 | } |
33 | } |
34 | |
34 | |
35 | $arch = Storable::retrieve "$LIBDIR/archetypes.pst"; |
35 | $arch = Storable::retrieve "$LIBDIR/archetypes.pst"; |
36 | |
36 | |
37 | open my $fh, ">:utf8", "arc.xhtml" |
37 | system "rm", -rf => "a"; |
38 | or die "arc.xhtml: $!"; |
38 | mkdir "a", 0777; |
39 | |
|
|
40 | select $fh; |
|
|
41 | |
|
|
42 | my $W = $meta->{width} * $T; |
|
|
43 | my $H = $meta->{height} * $T; |
|
|
44 | |
|
|
45 | my (@path) = split /\//, $path; |
|
|
46 | |
|
|
47 | print "<?xml version='1.0' encoding='utf-8'?>", |
|
|
48 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', |
|
|
49 | "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>", |
|
|
50 | "<head>", |
|
|
51 | "<title>Crossfire Archetypes</title>", |
|
|
52 | "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
|
|
53 | "</head>", |
|
|
54 | "<body>", |
|
|
55 | "<h1>Crossfire Archetypes</h1>"; |
|
|
56 | |
|
|
57 | print "<table>"; |
|
|
58 | |
39 | |
59 | sub print_arch { |
40 | sub print_arch { |
60 | my ($a) = @_; |
41 | my ($a) = @_; |
61 | print "<ul>"; |
42 | print "<ul>"; |
62 | for (sort keys %$a) { |
43 | for (sort keys %$a) { |
… | |
… | |
66 | print "<li>"; |
47 | print "<li>"; |
67 | if ($_ eq "more") { |
48 | if ($_ eq "more") { |
68 | print "more =>\n"; |
49 | print "more =>\n"; |
69 | print_arch ($a->{more}); |
50 | print_arch ($a->{more}); |
70 | } elsif ($_ eq "other_arch") { |
51 | } elsif ($_ eq "other_arch") { |
71 | print "$_ => <a href='#", (lc $a->{$_}), "'>$v</a>\n"; |
52 | print "$_ => <a href='#$a->{$_}'>$v</a>\n"; |
72 | } elsif ($_ eq "msg" || $_ eq "lore") { |
53 | } elsif ($_ eq "msg" || $_ eq "lore") { |
73 | print "$_ =><p class='m'>$v</p>"; |
54 | print "$_ =><p class='m'>$v</p>"; |
74 | } else { |
55 | } else { |
75 | print "$_ => $v\n"; |
56 | print "$_ => $v\n"; |
76 | } |
57 | } |
77 | print "</li>"; |
58 | print "</li>"; |
78 | } |
59 | } |
79 | print "</ul>"; |
60 | print "</ul>"; |
80 | } |
61 | } |
|
|
62 | |
81 | for my $name (sort keys %$arch) { |
63 | for my $name (sort keys %$arch) { |
82 | print "<tr valign='top'><th align='left'><a id='", (lc $name), "'>$name</a></th><td>"; |
64 | open my $fh, ">:utf8", "a/$name.xhtml" |
|
|
65 | or die "a/$name.xhtml: $!"; |
|
|
66 | |
|
|
67 | select $fh; |
|
|
68 | |
|
|
69 | print "<?xml version='1.0' encoding='utf-8'?>", |
|
|
70 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', |
|
|
71 | "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>", |
|
|
72 | "<head>", |
|
|
73 | "<title>Crossfire Archetype '$name'</title>", |
|
|
74 | "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
|
|
75 | "</head>", |
|
|
76 | "<body>", |
|
|
77 | "<h1>Crossfire Archetype '$name'</h1>"; |
|
|
78 | |
83 | print_arch $arch->{$name}; |
79 | print_arch $arch->{$name}; |
84 | print "</td></tr>"; |
80 | |
|
|
81 | print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>", |
|
|
82 | "</body></html>"; |
|
|
83 | |
|
|
84 | close $fh; |
|
|
85 | |
|
|
86 | #system "gzip", "-7f", "arc.xhtml"; |
85 | } |
87 | } |
86 | |
88 | |
87 | print "</table><p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfarch2html</a> version $VERSION</p>", |
|
|
88 | "</body></html>"; |
|
|
89 | |
89 | |
90 | close $fh; |
|
|
91 | |
|
|
92 | #system "gzip", "-7f", "arc.xhtml"; |
|
|
93 | |
|
|