ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.14
Committed: Wed Feb 14 02:33:46 2007 UTC (17 years, 3 months ago) by root
Branch: MAIN
CVS Tags: crossfire_datafiles
Changes since 1.13: +3 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 # cfarch2html - convert crossfire archetypes to html
4 # Copyright (C) 2005,2007 Marc Lehmann <cfmaps@schmorp.de>
5 #
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
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with gvpe; if not, write to the Free Software
18 # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 our $VERSION = '1.052';
21
22 use Storable;
23
24 my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
25 or die "\$CROSSFIRE_LIBDIR must be set\n";
26
27 my $arch;
28
29 sub escape_html($) {
30 local $_ = shift;
31 s/([<>&])/sprintf "&#%d;", ord $1/ge;
32 $_
33 }
34
35 $arch = Storable::retrieve "$LIBDIR/archetypes.pst";
36
37 system "rm", -rf => "a";
38 mkdir "a", 0777;
39
40 sub print_arch {
41 my ($a) = @_;
42 print "<ul>";
43 for (sort keys %$a) {
44 next if $_ eq "_name";
45 my $v = escape_html $a->{$_};
46
47 print "<li>";
48 if ($_ eq "more") {
49 print "more =>\n";
50 print_arch ($a->{more});
51 } elsif ($_ eq "other_arch") {
52 print "$_ => <a href='#$a->{$_}'>$v</a>\n";
53 } elsif ($_ eq "msg" || $_ eq "lore") {
54 print "$_ =><p class='m'>$v</p>";
55 } else {
56 print "$_ => $v\n";
57 }
58 print "</li>";
59 }
60 print "</ul>";
61 }
62
63 for my $name (sort keys %$arch) {
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
79 print_arch $arch->{$name};
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";
87 }
88
89