ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfarch2html
Revision: 1.15
Committed: Thu Jun 21 01:09:52 2007 UTC (16 years, 11 months ago) by root
Branch: MAIN
Changes since 1.14: +6 -10 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.5 # cfarch2html - convert crossfire archetypes to html
4 root 1.14 # Copyright (C) 2005,2007 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.15 our $VERSION = '2.001';
21 root 1.6
22 root 1.15 use Crossfire 1.0;
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     my $v = escape_html $a->{$_};
40    
41     print "<li>";
42     if ($_ eq "more") {
43     print "more =>\n";
44     print_arch ($a->{more});
45     } elsif ($_ eq "other_arch") {
46 root 1.12 print "$_ => <a href='#$a->{$_}'>$v</a>\n";
47 root 1.1 } elsif ($_ eq "msg" || $_ eq "lore") {
48 root 1.4 print "$_ =><p class='m'>$v</p>";
49 root 1.1 } else {
50     print "$_ => $v\n";
51     }
52     print "</li>";
53     }
54     print "</ul>";
55     }
56 root 1.11
57 root 1.15 Crossfire::load_archetypes;
58    
59     for my $name (sort keys %ARCH) {
60 root 1.11 open my $fh, ">:utf8", "a/$name.xhtml"
61     or die "a/$name.xhtml: $!";
62    
63     select $fh;
64    
65     print "<?xml version='1.0' encoding='utf-8'?>",
66     '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
67     "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
68     "<head>",
69     "<title>Crossfire Archetype '$name'</title>",
70     "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>",
71     "</head>",
72     "<body>",
73     "<h1>Crossfire Archetype '$name'</h1>";
74    
75 root 1.15 print_arch $ARCH{$name};
76 root 1.1
77 root 1.14 print "<p class='footer'>created by <a href='http://software.schmorp.de/pkg/cfmaps'>cfarch2html</a> version $VERSION</p>",
78 root 1.11 "</body></html>";
79    
80     close $fh;
81 root 1.1
82 root 1.11 #system "gzip", "-7f", "arc.xhtml";
83     }
84 root 1.1
85 root 1.7