1 |
root |
1.1 |
#!/opt/bin/perl |
2 |
|
|
|
3 |
root |
1.19 |
# cfarch2html - convert deliantra archetypes to html |
4 |
|
|
# Copyright (C) 2005,2007,2008 Marc Lehmann <cfmaps@schmorp.de> |
5 |
root |
1.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 |
root |
1.19 |
our $VERSION = '2.002'; |
21 |
root |
1.6 |
|
22 |
root |
1.19 |
use Deliantra; |
23 |
root |
1.1 |
use Storable; |
24 |
|
|
|
25 |
|
|
sub escape_html($) { |
26 |
|
|
local $_ = shift; |
27 |
|
|
s/([<>&])/sprintf "&#%d;", ord $1/ge; |
28 |
|
|
$_ |
29 |
|
|
} |
30 |
|
|
|
31 |
root |
1.11 |
system "rm", -rf => "a"; |
32 |
|
|
mkdir "a", 0777; |
33 |
root |
1.1 |
|
34 |
|
|
sub print_arch { |
35 |
|
|
my ($a) = @_; |
36 |
|
|
print "<ul>"; |
37 |
|
|
for (sort keys %$a) { |
38 |
|
|
next if $_ eq "_name"; |
39 |
root |
1.16 |
next if $_ eq "_atype"; |
40 |
root |
1.1 |
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 |
root |
1.17 |
print "$_ => <a href='$a->{$_}'>$v</a>\n"; |
48 |
root |
1.1 |
} elsif ($_ eq "msg" || $_ eq "lore") { |
49 |
root |
1.4 |
print "$_ =><p class='m'>$v</p>"; |
50 |
root |
1.1 |
} else { |
51 |
|
|
print "$_ => $v\n"; |
52 |
|
|
} |
53 |
|
|
print "</li>"; |
54 |
|
|
} |
55 |
|
|
print "</ul>"; |
56 |
|
|
} |
57 |
root |
1.11 |
|
58 |
root |
1.19 |
Deliantra::load_archetypes; |
59 |
root |
1.15 |
|
60 |
|
|
for my $name (sort keys %ARCH) { |
61 |
root |
1.11 |
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 |
root |
1.18 |
"<title>Deliantra Archetype '$name'</title>", |
71 |
root |
1.11 |
"<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>", |
72 |
|
|
"</head>", |
73 |
|
|
"<body>", |
74 |
root |
1.18 |
"<h1>Deliantra Archetype '$name'</h1>"; |
75 |
root |
1.11 |
|
76 |
root |
1.15 |
print_arch $ARCH{$name}; |
77 |
root |
1.1 |
|
78 |
root |
1.14 |
print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>", |
79 |
root |
1.11 |
"</body></html>"; |
80 |
|
|
|
81 |
|
|
close $fh; |
82 |
root |
1.1 |
|
83 |
root |
1.11 |
#system "gzip", "-7f", "arc.xhtml"; |
84 |
|
|
} |
85 |
root |
1.1 |
|
86 |
root |
1.7 |
|