1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # convert given .pod files to wiki style |
3 | # convert given .pod files to wiki style |
4 | |
4 | |
5 | # base path of arch tree, only used for new arch graphics |
5 | # base path of arch tree, only used for new arch graphics |
6 | my $ARCH = "/root/devel/cvs/cf.schmorp.de/arch"; |
6 | my $ARCH = "/root/src/cf.schmorp.de/arch"; |
7 | |
7 | |
8 | use strict; |
8 | use strict; |
9 | |
9 | |
10 | use Storable; |
10 | use Storable; |
11 | use Pod::POM; |
11 | use Pod::POM; |
… | |
… | |
77 | } |
77 | } |
78 | |
78 | |
79 | sub view_seq_link { |
79 | sub view_seq_link { |
80 | my (undef, $link) = @_; |
80 | my (undef, $link) = @_; |
81 | |
81 | |
82 | my $text = $link =~ s/^(.*)\|// ? $1 : $link; |
82 | $link =~ s/^(.*)\|// |
|
|
83 | or $link =~ /([^\/]*)$/; |
|
|
84 | |
|
|
85 | my $text = $1; |
83 | |
86 | |
84 | if ($link =~ /http:/) { |
87 | if ($link =~ /http:/) { |
85 | "<u>" . (::asxml $link) . "</u>" |
88 | "<u>" . (::asxml $link) . "</u>" |
86 | } elsif ($link =~ /^\$ARCH\/(.+)$/) { |
89 | } elsif ($link =~ /^\$ARCH\/(.+\....)$/) { |
87 | my $path = $1; |
90 | my $file = $1; |
88 | (my $base = $path) =~ s/.*\///; |
91 | |
89 | -f "$ARCH/$path" && system "rsync -av -c \Q$ARCH/$path\E \Qresources/arch/$base"; |
92 | unless (-f "resources/arch/$file.png") { |
|
|
93 | print "ARCHIMG $file is missing, trying to supply... "; |
|
|
94 | my ($path) = split /\x00/, qx<find \Q$ARCH\E -name \Q$file.64x64.png*\E -print0>; |
|
|
95 | -f $path or die "$file: could not find arch image"; |
|
|
96 | print "$path\n"; |
|
|
97 | system "rsync -a \Q$path\E resources/arch/\Q$file.png" |
|
|
98 | and die "rsync failed: $?"; |
|
|
99 | system "cvs add -kb resources/arch/\Q$file.png" |
|
|
100 | and ((unlink "resources/arch/$file.png"), die "cvs add failed: $?"); |
|
|
101 | } |
|
|
102 | |
90 | ::special image => "arch/$base", 1; |
103 | ::special image => "arch/$file.png", 1; |
91 | } else { |
104 | } else { |
92 | ::special link => $text, $link |
105 | ::special link => $text, $link |
93 | } |
106 | } |
94 | } |
107 | } |
95 | |
108 | |
… | |
… | |
105 | |
118 | |
106 | sub view_head1 { |
119 | sub view_head1 { |
107 | push @result, [ $indent * 16, $level ]; |
120 | push @result, [ $indent * 16, $level ]; |
108 | my $title = $_[1]->title->present ($_[0]); |
121 | my $title = $_[1]->title->present ($_[0]); |
109 | $result[-1][P_MARKUP] = ::special h1 => $title if length $title; |
122 | $result[-1][P_MARKUP] = ::special h1 => $title if length $title; |
110 | $title = ::flatten $title; unshift @{ $result[-1][P_INDEX] }, $title if length $title; |
123 | $title = ::flatten $title; |
|
|
124 | unshift @{ $result[-1][P_INDEX] }, $title |
|
|
125 | if !$result[-1][P_INDEX]; |
111 | local $level = $level + 1; |
126 | local $level = $level + 1; |
112 | $_[1]->content->present ($_[0]); |
127 | $_[1]->content->present ($_[0]); |
113 | () |
128 | () |
114 | }; |
129 | }; |
115 | |
130 | |
116 | sub view_head2 { |
131 | sub view_head2 { |
117 | push @result, [ $indent * 16, $level ]; |
132 | push @result, [ $indent * 16, $level ]; |
118 | my $title = $_[1]->title->present ($_[0]); |
133 | my $title = $_[1]->title->present ($_[0]); |
119 | $result[-1][P_MARKUP] = ::special h2 => $title if length $title; |
134 | $result[-1][P_MARKUP] = ::special h2 => $title if length $title; |
120 | $title = ::flatten $title; unshift @{ $result[-1][P_INDEX] }, $title if length $title; |
135 | $title = ::flatten $title; |
|
|
136 | unshift @{ $result[-1][P_INDEX] }, $title |
|
|
137 | if !$result[-1][P_INDEX]; |
121 | local $level = $level + 1; |
138 | local $level = $level + 1; |
122 | $_[1]->content->present ($_[0]); |
139 | $_[1]->content->present ($_[0]); |
123 | () |
140 | () |
124 | }; |
141 | }; |
125 | |
142 | |
126 | sub view_head3 { |
143 | sub view_head3 { |
127 | push @result, [ $indent * 16, $level ]; |
144 | push @result, [ $indent * 16, $level ]; |
128 | my $title = $_[1]->title->present ($_[0]); |
145 | my $title = $_[1]->title->present ($_[0]); |
129 | $result[-1][P_MARKUP] = ::special h3 => $title if length $title; |
146 | $result[-1][P_MARKUP] = ::special h3 => $title if length $title; |
130 | $title = ::flatten $title; unshift @{ $result[-1][P_INDEX] }, $title if length $title; |
147 | $title = ::flatten $title; |
|
|
148 | unshift @{ $result[-1][P_INDEX] || [] }, $title |
|
|
149 | if !$result[-1][P_INDEX]; |
131 | local $level = $level + 1; |
150 | local $level = $level + 1; |
132 | $_[1]->content->present ($_[0]); |
151 | $_[1]->content->present ($_[0]); |
133 | () |
152 | () |
134 | }; |
153 | }; |
135 | |
154 | |
… | |
… | |
142 | |
161 | |
143 | sub view_item { |
162 | sub view_item { |
144 | push @result, [ $indent * 8, $level ]; |
163 | push @result, [ $indent * 8, $level ]; |
145 | my $title = $_[1]->title->present ($_[0]); |
164 | my $title = $_[1]->title->present ($_[0]); |
146 | $result[-1][P_MARKUP] = "$title\n" if length $title; |
165 | $result[-1][P_MARKUP] = "$title\n" if length $title; |
147 | $title = ::flatten $title; unshift @{ $result[-1][P_INDEX] }, $title if length $title; |
166 | $title = ::flatten $title; |
|
|
167 | unshift @{ $result[-1][P_INDEX] || [] }, $title |
|
|
168 | if !$result[-1][P_INDEX]; |
148 | local $level = $level + 1; |
169 | local $level = $level + 1; |
149 | $_[1]->content->present ($_[0]); |
170 | $_[1]->content->present ($_[0]); |
150 | () |
171 | () |
151 | } |
172 | } |
152 | |
173 | |
… | |
… | |
185 | [grep $_->[P_INDEX] || defined $_->[P_MARKUP], @result] |
206 | [grep $_->[P_INDEX] || defined $_->[P_MARKUP], @result] |
186 | } |
207 | } |
187 | |
208 | |
188 | ############################################################################# |
209 | ############################################################################# |
189 | |
210 | |
|
|
211 | $| = 1; |
|
|
212 | |
190 | my %wiki; |
213 | my %wiki; |
191 | |
214 | |
192 | sub add_node($) { |
215 | sub add_node($) { |
193 | my ($node) = @_; |
216 | my ($node) = @_; |
194 | |
217 | |
195 | for (@{ $node->[N_KW] || {} }) { |
218 | for (@{ $node->[N_KW] || {} }) { |
196 | push @{$wiki{lc $_}}, $node; |
219 | push @{$wiki{$_}}, $node; |
197 | } |
220 | } |
198 | } |
221 | } |
199 | |
222 | |
200 | my $root; |
223 | my $root; |
201 | $root->[N_KW] = ["pod"]; |
224 | $root->[N_KW] = ["Documents", "pod"]; |
|
|
225 | $root->[N_DOC] = [[0, 0, ::special link => "All Documents", "pod/*"]]; |
202 | |
226 | |
203 | for my $path (@ARGV) { |
227 | for my $path (@ARGV) { |
204 | $path =~ /([^\/\\]+)\.pod$/ or die "$path: illegal pathname"; |
228 | $path =~ /([^\/\\]+)\.pod$/ or die "$path: illegal pathname"; |
205 | my $base = $1; |
229 | my $base = $1; |
206 | my $pom = Pod::POM->new->parse_text (do { |
230 | my $pom = Pod::POM->new->parse_text (do { |