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.2 by root, Sun Aug 13 03:20:56 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;
16
17my $MA_BEG = "\x{fcd0}";
18my $MA_SEP = "\x{fcd1}";
19my $MA_END = "\x{fcd2}";
14 20
15sub asxml($) { 21sub asxml($) {
16 local $_ = $_[0]; 22 local $_ = $_[0];
17 23
18 s/&/&/g; 24 s/&/&/g;
29 s/^\s+//; 35 s/^\s+//;
30 s/\s+$//; 36 s/\s+$//;
31 s/\s+/ /g; 37 s/\s+/ /g;
32 38
33 $_ 39 $_
40}
41
42sub special {
43 $MA_BEG . (join $MA_SEP, @_) . $MA_END
34} 44}
35 45
36package AsParagraphs; 46package AsParagraphs;
37 47
38use strict; 48use strict;
54} 64}
55 65
56sub view_seq_link { 66sub view_seq_link {
57 my (undef, $link) = @_; 67 my (undef, $link) = @_;
58 68
59 # TODO: 69 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
60 # http://...
61 # ref
62 # pod/ref
63 70
71 if ($link =~ /http:/) {
64 "<u>" . (::asxml $_[1]) . "</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;
78 } else {
79 ::special link => $text, $link
80 }
65} 81}
66 82
67sub view_item { 83sub view_item {
68 push @result, { 84 push @result, {
69 indent => $indent * 8, 85 indent => $indent * 8,
70 level => $level, 86 level => $level,
71 }; 87 };
72 my $title = $_[1]->title->present ($_[0]); 88 my $title = $_[1]->title->present ($_[0]);
73 $result[-1]{markup} = "$title\n\n" if length $title; 89 $result[-1]{markup} = "$title\n" if length $title;
74 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title; 90 $title = ::flatten $title; unshift @{ $result[-1]{index} }, $title if length $title;
75 local $level = $level + 1; 91 local $level = $level + 1;
76 $_[1]->content->present ($_[0]); 92 $_[1]->content->present ($_[0]);
77 () 93 ()
78} 94}
144sub view_for { 160sub view_for {
145 if ($_[1]->format eq "image") { 161 if ($_[1]->format eq "image") {
146 push @result, { 162 push @result, {
147 indent => $indent * 16, 163 indent => $indent * 16,
148 level => $level, 164 level => $level,
149 markup => "\x{fffc}", 165 markup => (::special image => "pod/" . $_->text),
150 widget => [["CFPlus::UI::Image" => path => "pod/" . $_[1]->text]],
151 }; 166 };
152 } 167 }
168 ()
169}
170
171sub view_begin {
153 () 172 ()
154} 173}
155 174
156sub view { 175sub view {
157 my ($self, $type, $item) = @_; 176 my ($self, $type, $item) = @_;
179 198
180sub add_node($) { 199sub add_node($) {
181 my ($node) = @_; 200 my ($node) = @_;
182 201
183 for (@{ $node->{kw} || {} }) { 202 for (@{ $node->{kw} || {} }) {
184 push @{$wiki{$_}}, $node; 203 push @{$wiki{lc $_}}, $node;
185 } 204 }
186} 205}
187 206
188my $root = { 207my $root = {
189 kw => ["pod"], 208 kw => ["pod"],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines