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.4 by root, Sun Aug 13 19:47:06 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;
62 68
63 my $text = $link =~ s/^(.*)\|// ? $1 : $link; 69 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
64 70
65 if ($link =~ /http:/) { 71 if ($link =~ /http:/) {
66 "<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;
67 } else { 78 } else {
68 "${MA_BEG}link$MA_SEP$text$MA_SEP$link$MA_END" 79 ::special link => $text, $link
69 } 80 }
70} 81}
71 82
72sub view_item { 83sub view_item {
73 push @result, { 84 push @result, {
74 indent => $indent * 8, 85 indent => $indent * 8,
75 level => $level, 86 level => $level,
76 }; 87 };
77 my $title = $_[1]->title->present ($_[0]); 88 my $title = $_[1]->title->present ($_[0]);
78 $result[-1]{markup} = "$title\n\n" if length $title; 89 $result[-1]{markup} = "$title\n" if length $title;
79 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title; 90 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title;
80 local $level = $level + 1; 91 local $level = $level + 1;
81 $_[1]->content->present ($_[0]); 92 $_[1]->content->present ($_[0]);
82 () 93 ()
83} 94}
149sub view_for { 160sub view_for {
150 if ($_[1]->format eq "image") { 161 if ($_[1]->format eq "image") {
151 push @result, { 162 push @result, {
152 indent => $indent * 16, 163 indent => $indent * 16,
153 level => $level, 164 level => $level,
154 markup => "${MA_BEG}image${MA_SEP}pod/" . $_->text . $MA_END, 165 markup => (::special image => "pod/" . $_->text),
155 }; 166 };
156 } 167 }
168 ()
169}
170
171sub view_begin {
157 () 172 ()
158} 173}
159 174
160sub view { 175sub view {
161 my ($self, $type, $item) = @_; 176 my ($self, $type, $item) = @_;
183 198
184sub add_node($) { 199sub add_node($) {
185 my ($node) = @_; 200 my ($node) = @_;
186 201
187 for (@{ $node->{kw} || {} }) { 202 for (@{ $node->{kw} || {} }) {
188 push @{$wiki{$_}}, $node; 203 push @{$wiki{lc $_}}, $node;
189 } 204 }
190} 205}
191 206
192my $root = { 207my $root = {
193 kw => ["pod"], 208 kw => ["pod"],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines