1 |
#!/opt/bin/perl |
2 |
|
3 |
# cfarch2html - convert deliantra archetypes to html |
4 |
# Copyright (C) 2005,2007,2008 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 = '2.002'; |
21 |
|
22 |
use Deliantra; |
23 |
use Storable; |
24 |
|
25 |
sub escape_html($) { |
26 |
local $_ = shift; |
27 |
s/([<>&])/sprintf "&#%d;", ord $1/ge; |
28 |
$_ |
29 |
} |
30 |
|
31 |
system "rm", -rf => "a"; |
32 |
mkdir "a", 0777; |
33 |
|
34 |
sub print_arch { |
35 |
my ($a) = @_; |
36 |
print "<ul>"; |
37 |
for (sort keys %$a) { |
38 |
next if $_ eq "_name"; |
39 |
next if $_ eq "_atype"; |
40 |
my $v = escape_html $a->{$_}; |
41 |
|
42 |
print "<li>"; |
43 |
if ($_ eq "more") { |
44 |
print "more =>\n"; |
45 |
print_arch ($a->{more}); |
46 |
} elsif ($_ eq "other_arch") { |
47 |
print "$_ => <a href='$a->{$_}'>$v</a>\n"; |
48 |
} elsif ($_ eq "msg" || $_ eq "lore") { |
49 |
print "$_ =><p class='m'>$v</p>"; |
50 |
} else { |
51 |
print "$_ => $v\n"; |
52 |
} |
53 |
print "</li>"; |
54 |
} |
55 |
print "</ul>"; |
56 |
} |
57 |
|
58 |
Deliantra::load_archetypes; |
59 |
|
60 |
for my $name (sort keys %ARCH) { |
61 |
open my $fh, ">:utf8", "a/$name.xhtml" |
62 |
or die "a/$name.xhtml: $!"; |
63 |
|
64 |
select $fh; |
65 |
|
66 |
print "<?xml version='1.0' encoding='utf-8'?>", |
67 |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', |
68 |
"<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>", |
69 |
"<head>", |
70 |
"<title>Deliantra Archetype '$name'</title>", |
71 |
"<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
72 |
"</head>", |
73 |
"<body>", |
74 |
"<h1>Deliantra Archetype '$name'</h1>"; |
75 |
|
76 |
print_arch $ARCH{$name}; |
77 |
|
78 |
print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>", |
79 |
"</body></html>"; |
80 |
|
81 |
close $fh; |
82 |
|
83 |
#system "gzip", "-7f", "arc.xhtml"; |
84 |
} |
85 |
|
86 |
|