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.051'; |
20 | our $VERSION = '2.001'; |
21 | |
21 | |
|
|
22 | use Crossfire 1.0; |
22 | use Storable; |
23 | use Storable; |
23 | |
|
|
24 | my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} |
|
|
25 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
|
|
26 | |
|
|
27 | my $arch; |
|
|
28 | |
24 | |
29 | sub escape_html($) { |
25 | sub 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 | |
|
|
35 | $arch = Storable::retrieve "$LIBDIR/archetypes.pst"; |
|
|
36 | |
30 | |
37 | system "rm", -rf => "a"; |
31 | system "rm", -rf => "a"; |
38 | mkdir "a", 0777; |
32 | mkdir "a", 0777; |
39 | |
33 | |
40 | sub print_arch { |
34 | sub print_arch { |
… | |
… | |
58 | print "</li>"; |
52 | print "</li>"; |
59 | } |
53 | } |
60 | print "</ul>"; |
54 | print "</ul>"; |
61 | } |
55 | } |
62 | |
56 | |
|
|
57 | Crossfire::load_archetypes; |
|
|
58 | |
63 | for my $name (sort keys %$arch) { |
59 | for my $name (sort keys %ARCH) { |
64 | open my $fh, ">:utf8", "a/$name.xhtml" |
60 | open my $fh, ">:utf8", "a/$name.xhtml" |
65 | or die "a/$name.xhtml: $!"; |
61 | or die "a/$name.xhtml: $!"; |
66 | |
62 | |
67 | select $fh; |
63 | select $fh; |
68 | |
64 | |
… | |
… | |
74 | "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
70 | "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
75 | "</head>", |
71 | "</head>", |
76 | "<body>", |
72 | "<body>", |
77 | "<h1>Crossfire Archetype '$name'</h1>"; |
73 | "<h1>Crossfire Archetype '$name'</h1>"; |
78 | |
74 | |
79 | print_arch $arch->{$name}; |
75 | print_arch $ARCH{$name}; |
80 | |
76 | |
81 | print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/crossfire'>cfarch2html</a> version $VERSION</p>", |
77 | print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>", |
82 | "</body></html>"; |
78 | "</body></html>"; |
83 | |
79 | |
84 | close $fh; |
80 | close $fh; |
85 | |
81 | |
86 | #system "gzip", "-7f", "arc.xhtml"; |
82 | #system "gzip", "-7f", "arc.xhtml"; |