ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pod2wiki
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pod2wiki (file contents):
Revision 1.3 by root, Sun Aug 13 18:48:57 2006 UTC vs.
Revision 1.10 by root, Sat Sep 9 23:31:58 2006 UTC

1#! perl 1#! perl
2 2
3# convert given .pod files to wiki style
4
5# base path of arch tree, only used for new arch graphics
6my $ARCH = "/root/devel/cvs/cf.schmorp.de/arch";
7
8use strict;
9
3use Storable; 10use Storable;
4
5# convert given .pod files to wiki style
6
7use strict;
8
9use Pod::POM; 11use Pod::POM;
10 12
11our @result; 13our @result;
12our $indent; 14our $indent;
13our $level; 15our $level;
33 s/^\s+//; 35 s/^\s+//;
34 s/\s+$//; 36 s/\s+$//;
35 s/\s+/ /g; 37 s/\s+/ /g;
36 38
37 $_ 39 $_
40}
41
42sub special {
43 $MA_BEG . (join $MA_SEP, @_) . $MA_END
38} 44}
39 45
40package AsParagraphs; 46package AsParagraphs;
41 47
42use strict; 48use strict;
58} 64}
59 65
60sub view_seq_link { 66sub view_seq_link {
61 my (undef, $link) = @_; 67 my (undef, $link) = @_;
62 68
69 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
70
63 if ($link =~ /http:/) { 71 if ($link =~ /http:/) {
64 "<u>" . (::asxml $link) . "</u>" 72 "<u>" . (::asxml $link) . "</u>"
73 } elsif ($link =~ /^\$ARCH\/(.+)$/) {
74 my $path = $1;
75 (my $base = $path) =~ s/.*\///;
76 -f "$ARCH/$path" && system "rsync -av -c \Q$ARCH/$path\E \Qresources/arch/$base";
77 ::special image => "arch/$base", 1;
65 } else { 78 } else {
66 "${MA_BEG}link${MA_SEP}$link$MA_END" 79 ::special link => $text, $link
67 } 80 }
68} 81}
69 82
70sub view_item { 83sub view_item {
71 push @result, { 84 push @result, {
72 indent => $indent * 8, 85 indent => $indent * 8,
73 level => $level, 86 level => $level,
74 }; 87 };
75 my $title = $_[1]->title->present ($_[0]); 88 my $title = $_[1]->title->present ($_[0]);
76 $result[-1]{markup} = "$title\n\n" if length $title; 89 $result[-1]{markup} = "$title\n" if length $title;
77 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title; 90 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title;
78 local $level = $level + 1; 91 local $level = $level + 1;
79 $_[1]->content->present ($_[0]); 92 $_[1]->content->present ($_[0]);
80 () 93 ()
81} 94}
147sub view_for { 160sub view_for {
148 if ($_[1]->format eq "image") { 161 if ($_[1]->format eq "image") {
149 push @result, { 162 push @result, {
150 indent => $indent * 16, 163 indent => $indent * 16,
151 level => $level, 164 level => $level,
152 markup => "${MA_BEG}image${MA_SEP}pod/" . $_->text . $MA_END, 165 markup => (::special image => "pod/" . $_->text),
153 }; 166 };
154 } 167 }
168 ()
169}
170
171sub view_begin {
155 () 172 ()
156} 173}
157 174
158sub view { 175sub view {
159 my ($self, $type, $item) = @_; 176 my ($self, $type, $item) = @_;
181 198
182sub add_node($) { 199sub add_node($) {
183 my ($node) = @_; 200 my ($node) = @_;
184 201
185 for (@{ $node->{kw} || {} }) { 202 for (@{ $node->{kw} || {} }) {
186 push @{$wiki{$_}}, $node; 203 push @{$wiki{lc $_}}, $node;
187 } 204 }
188} 205}
189 206
190my $root = { 207my $root = {
191 kw => ["pod"], 208 kw => ["pod"],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines