1 | package CFClient::Pod; |
1 | package CFPlus::Pod; |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | |
4 | |
5 | use Pod::POM; |
5 | use Pod::POM; |
6 | |
6 | |
7 | use CFClient; |
7 | use CFPlus; |
8 | use CFClient::UI; |
8 | use CFPlus::UI; |
9 | |
9 | |
10 | our $VERSION = 1.02; # bump if resultant formatting changes |
10 | our $VERSION = 1.02; # bump if resultant formatting changes |
11 | |
11 | |
12 | our @result; |
12 | our @result; |
13 | our $indent; |
13 | our $indent; |
14 | |
14 | |
15 | package CFClient::Pod::AsMarkup; |
15 | package CFPlus::Pod::AsMarkup; |
16 | |
16 | |
17 | use strict; |
17 | use strict; |
18 | |
18 | |
19 | use base "Pod::POM::View::Text"; |
19 | use base "Pod::POM::View::Text"; |
20 | |
20 | |
21 | *view_seq_file = |
21 | *view_seq_file = |
22 | *view_seq_code = |
22 | *view_seq_code = |
23 | *view_seq_bold = sub { "<b>$_[1]</b>" }; |
23 | *view_seq_bold = sub { "<b>$_[1]</b>" }; |
24 | *view_seq_italic = sub { "<i>$_[1]</i>" }; |
24 | *view_seq_italic = sub { "<i>$_[1]</i>" }; |
25 | *view_seq_space = |
25 | *view_seq_space = |
26 | *view_seq_link = sub { CFClient::asxml $_[1] }; |
26 | *view_seq_link = sub { CFPlus::asxml $_[1] }; |
27 | *view_seq_zero = |
27 | *view_seq_zero = |
28 | *view_seq_index = sub { }; |
28 | *view_seq_index = sub { }; |
29 | |
29 | |
30 | sub view_seq_text { |
30 | sub view_seq_text { |
31 | my $text = $_[1]; |
31 | my $text = $_[1]; |
32 | $text =~ s/\s+/ /g; |
32 | $text =~ s/\s+/ /g; |
33 | CFClient::asxml $text |
33 | CFPlus::asxml $text |
34 | } |
34 | } |
35 | |
35 | |
36 | sub view_item { |
36 | sub view_item { |
37 | ("\t" x ($indent / 4)) |
37 | ("\t" x ($indent / 4)) |
38 | . $_[1]->title->present ($_[0]) |
38 | . $_[1]->title->present ($_[0]) |
… | |
… | |
41 | } |
41 | } |
42 | |
42 | |
43 | sub view_verbatim { |
43 | sub view_verbatim { |
44 | (join "", |
44 | (join "", |
45 | map +("\t" x ($indent / 2)) . "<tt>$_</tt>\n", |
45 | map +("\t" x ($indent / 2)) . "<tt>$_</tt>\n", |
46 | split /\n/, CFClient::asxml $_[1]) |
46 | split /\n/, CFPlus::asxml $_[1]) |
47 | . "\n" |
47 | . "\n" |
48 | } |
48 | } |
49 | |
49 | |
50 | sub view_textblock { |
50 | sub view_textblock { |
51 | ("\t" x ($indent / 2)) . "$_[1]\n" |
51 | ("\t" x ($indent / 2)) . "$_[1]\n" |
… | |
… | |
69 | sub view_over { |
69 | sub view_over { |
70 | local $indent = $indent + $_[1]->indent; |
70 | local $indent = $indent + $_[1]->indent; |
71 | $_[1]->content->present ($_[0]) |
71 | $_[1]->content->present ($_[0]) |
72 | } |
72 | } |
73 | |
73 | |
74 | package CFClient::Pod::AsParagraphs; |
74 | package CFPlus::Pod::AsParagraphs; |
75 | |
75 | |
76 | use strict; |
76 | use strict; |
77 | |
77 | |
78 | use base "Pod::POM::View"; |
78 | use base "Pod::POM::View"; |
79 | |
79 | |
… | |
… | |
86 | *view_seq_index = sub { warn "index<@_>\n"; $result[-1]{index}{$_[1]} = undef }; |
86 | *view_seq_index = sub { warn "index<@_>\n"; $result[-1]{index}{$_[1]} = undef }; |
87 | |
87 | |
88 | sub view_seq_text { |
88 | sub view_seq_text { |
89 | my $text = $_[1]; |
89 | my $text = $_[1]; |
90 | $text =~ s/\s+/ /g; |
90 | $text =~ s/\s+/ /g; |
91 | CFClient::asxml $text |
91 | CFPlus::asxml $text |
92 | } |
92 | } |
93 | |
93 | |
94 | sub view_seq_link { |
94 | sub view_seq_link { |
95 | my (undef, $link) = @_; |
95 | my (undef, $link) = @_; |
96 | |
96 | |
97 | # TODO: |
97 | # TODO: |
98 | # http://... |
98 | # http://... |
99 | # ref |
99 | # ref |
100 | # pod/ref |
100 | # pod/ref |
101 | |
101 | |
102 | "<u>" . (CFClient::asxml $_[1]) . "</u>"; |
102 | "<u>" . (CFPlus::asxml $_[1]) . "</u>"; |
103 | } |
103 | } |
104 | |
104 | |
105 | sub view_item { |
105 | sub view_item { |
106 | push @result, { |
106 | push @result, { |
107 | indent => $indent * 8, |
107 | indent => $indent * 8, |
… | |
… | |
112 | } |
112 | } |
113 | |
113 | |
114 | sub view_verbatim { |
114 | sub view_verbatim { |
115 | push @result, { |
115 | push @result, { |
116 | indent => $indent * 16, |
116 | indent => $indent * 16, |
117 | markup => "<tt>" . (CFClient::asxml $_[1]) . "</tt>\n", |
117 | markup => "<tt>" . (CFPlus::asxml $_[1]) . "</tt>\n", |
118 | }; |
118 | }; |
119 | () |
119 | () |
120 | } |
120 | } |
121 | |
121 | |
122 | sub view_textblock { |
122 | sub view_textblock { |
… | |
… | |
164 | sub view_for { |
164 | sub view_for { |
165 | if ($_[1]->format eq "image") { |
165 | if ($_[1]->format eq "image") { |
166 | push @result, { |
166 | push @result, { |
167 | indent => $indent * 16, |
167 | indent => $indent * 16, |
168 | markup => "\x{fffc}", |
168 | markup => "\x{fffc}", |
169 | widget => [new CFClient::UI::Image path => "pod/" . $_[1]->text], |
169 | widget => [new CFPlus::UI::Image path => "pod/" . $_[1]->text], |
170 | }; |
170 | }; |
171 | } |
171 | } |
172 | () |
172 | () |
173 | } |
173 | } |
174 | |
174 | |
… | |
… | |
176 | my ($self, $type, $item) = @_; |
176 | my ($self, $type, $item) = @_; |
177 | |
177 | |
178 | $item->content->present ($self); |
178 | $item->content->present ($self); |
179 | } |
179 | } |
180 | |
180 | |
181 | package CFClient::Pod; |
181 | package CFPlus::Pod; |
182 | |
182 | |
183 | my $pod_cache = CFClient::db_table "pod_cache"; |
183 | my $pod_cache = CFPlus::db_table "pod_cache"; |
184 | |
184 | |
185 | sub load($$$$) { |
185 | sub load($$$$) { |
186 | my ($path, $filtertype, $filterversion, $filtercb) = @_; |
186 | my ($path, $filtertype, $filterversion, $filtercb) = @_; |
187 | |
187 | |
188 | stat $path |
188 | stat $path |
… | |
… | |
220 | sub as_markup($) { |
220 | sub as_markup($) { |
221 | my ($pom) = @_; |
221 | my ($pom) = @_; |
222 | |
222 | |
223 | local $indent = 0; |
223 | local $indent = 0; |
224 | |
224 | |
225 | $pom->present ("CFClient::Pod::AsMarkup") |
225 | $pom->present ("CFPlus::Pod::AsMarkup") |
226 | } |
226 | } |
227 | |
227 | |
228 | sub as_paragraphs($) { |
228 | sub as_paragraphs($) { |
229 | my ($pom) = @_; |
229 | my ($pom) = @_; |
230 | |
230 | |
231 | local @result = ( { } ); |
231 | local @result = ( { } ); |
232 | local $indent = 0; |
232 | local $indent = 0; |
233 | |
233 | |
234 | $pom->present ("CFClient::Pod::AsParagraphs"); |
234 | $pom->present ("CFPlus::Pod::AsParagraphs"); |
235 | |
235 | |
236 | [grep exists $_->{markup}, @result] |
236 | [grep exists $_->{markup}, @result] |
237 | } |
237 | } |
238 | |
238 | |
239 | sub pod_paragraphs($) { |
239 | sub pod_paragraphs($) { |
240 | load CFClient::find_rcfile "pod/$_[0].pod", |
240 | load CFPlus::find_rcfile "pod/$_[0].pod", |
241 | pod_paragraphs => 1, sub { as_paragraphs $_[0] }; |
241 | pod_paragraphs => 1, sub { as_paragraphs $_[0] }; |
242 | } |
242 | } |
243 | |
243 | |