line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache2::Pod::HTML; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Apache2::Pod::HTML - base class for converting Pod files to prettier forms |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
9737
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
81
|
|
10
|
2
|
|
|
2
|
|
11
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
104
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.27'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.27 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
20
|
use Apache2::Pod; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
21
|
2
|
|
|
2
|
|
896
|
use Apache2::Const -compile => qw( OK NOT_FOUND SERVER_ERROR ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Apache2::Pod::PodSimpleHTML; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
A simple mod_perl handler to easily convert Pod to HTML or other forms. |
27
|
|
|
|
|
|
|
You can also emulate F. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 CONFIGURATION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 Pod-to-HTML conversion |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Add the following lines to your F. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
SetHandler perl-script |
37
|
|
|
|
|
|
|
PerlHandler Apache2::Pod::HTML |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
All F<*.pod> files will magically be converted to HTML. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 F emulation |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The following configuration should go in your httpd.conf |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
SetHandler perl-script |
48
|
|
|
|
|
|
|
PerlHandler Apache2::Pod::HTML |
49
|
|
|
|
|
|
|
PerlSetVar STYLESHEET auto |
50
|
|
|
|
|
|
|
PerlSetVar LINKBASE http://www.example.com/docs/ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
You can then get documentation for a module C at the URL |
54
|
|
|
|
|
|
|
C |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Note that you can also get the standard Perl documentation with URLs |
57
|
|
|
|
|
|
|
like C or just |
58
|
|
|
|
|
|
|
C for the main Perl docs. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Finally, you can search for a particular Perl keyword with |
61
|
|
|
|
|
|
|
C The 'f' is used by analogy |
62
|
|
|
|
|
|
|
with the C<-f> flag to C. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 CONFIGURATION VARIABLES |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 STYLESHEET |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Specifies the stylesheet to use with the output HTML file. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
SetHandler perl-script |
72
|
|
|
|
|
|
|
PerlHandler Apache2::Pod::HTML |
73
|
|
|
|
|
|
|
PerlSetVar STYLESHEET auto |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Specifying 'auto' for the stylesheet will cause the built-in CSS |
77
|
|
|
|
|
|
|
stylesheet to be used. If you prefer, you can replace the word 'auto' |
78
|
|
|
|
|
|
|
with the URL of your own custom stylesheet file. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 INDEX |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
When INDEX is true, a table of contents is added at the top of the |
83
|
|
|
|
|
|
|
HTML document. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
SetHandler perl-script |
87
|
|
|
|
|
|
|
PerlHandler Apache2::Pod::HTML |
88
|
|
|
|
|
|
|
PerlSetVar INDEX 1 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
By default, this is off. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 GZIP |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
When GZIP is true, the whole HTTP body is compressed. The user's browser must |
96
|
|
|
|
|
|
|
accept gzip, and L must be available. Otherwise, GZIP is ignored. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
SetHandler perl-script |
100
|
|
|
|
|
|
|
PerlHandler Apache2::Pod::HTML |
101
|
|
|
|
|
|
|
PerlSetVar GZIP 1 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
By default, this is off. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 LINKBASE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Specifying an optional C variable changes the external |
109
|
|
|
|
|
|
|
HTTP links to use a URL prefix of your specification instead of using |
110
|
|
|
|
|
|
|
L's default. Using the magic word C will make |
111
|
|
|
|
|
|
|
links local instead of external. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub handler { |
116
|
|
|
|
|
|
|
my $r = shift; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
if ( $r->path_info eq '/auto.css' ) { |
119
|
|
|
|
|
|
|
$r->content_type( 'text/css' ); |
120
|
|
|
|
|
|
|
$r->print( _css() ); |
121
|
|
|
|
|
|
|
return Apache2::Const::OK; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $body; |
125
|
|
|
|
|
|
|
my $file = Apache2::Pod::getpodfile( $r ); |
126
|
|
|
|
|
|
|
my $fun = undef; |
127
|
|
|
|
|
|
|
my $parser = Apache2::Pod::PodSimpleHTML->new; |
128
|
|
|
|
|
|
|
$parser->no_errata_section(1); |
129
|
|
|
|
|
|
|
$parser->complain_stderr(1); |
130
|
|
|
|
|
|
|
$parser->output_string( \$body ); |
131
|
|
|
|
|
|
|
$parser->index( $r->dir_config('INDEX') ); |
132
|
|
|
|
|
|
|
if ( my $prefix = $r->dir_config('LINKBASE') ) { |
133
|
|
|
|
|
|
|
if ( $prefix eq 'LOCAL' ) { |
134
|
|
|
|
|
|
|
$prefix = $r->location . '/'; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
$parser->perldoc_url_prefix( $prefix ); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
if ( $file ) { |
139
|
|
|
|
|
|
|
if ( $file =~ /^-f<([^>]*)>::(.*)$/ ) { |
140
|
|
|
|
|
|
|
$fun = $1; |
141
|
|
|
|
|
|
|
$file = $2; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
if ( $fun ) { |
144
|
|
|
|
|
|
|
my $document = Apache2::Pod::getpodfuncdoc( $file, $fun ); |
145
|
|
|
|
|
|
|
$parser->parse_string_document( $document ); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else { |
148
|
|
|
|
|
|
|
$parser->parse_file( $file ); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
# TODO: Send the timestamp of the file in the header here |
151
|
|
|
|
|
|
|
} else { |
152
|
|
|
|
|
|
|
my $modstr = Apache2::Pod::resolve_modname( $r ) || $r->filename || ''; |
153
|
|
|
|
|
|
|
my $document = sprintf "=item %1\$s\n\nNo documentation found for \"%1\$s\".\n", $modstr; |
154
|
|
|
|
|
|
|
$parser->parse_string_document( $document ); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
my $stylesheet = $r->dir_config('STYLESHEET') || ''; |
157
|
|
|
|
|
|
|
$stylesheet = $r->location . '/auto.css' if $stylesheet =~ /^auto/i; |
158
|
|
|
|
|
|
|
if ( $stylesheet ) { |
159
|
|
|
|
|
|
|
# Stick in a link to our stylesheet |
160
|
|
|
|
|
|
|
$stylesheet = qq(); |
161
|
|
|
|
|
|
|
$body =~ s{(?=
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
if ( $r->dir_config('GZIP') && ($r->header_in('Accept-Encoding') =~ /gzip/) ) { |
164
|
|
|
|
|
|
|
local $@; |
165
|
|
|
|
|
|
|
eval { |
166
|
|
|
|
|
|
|
require Compress::Zlib; |
167
|
|
|
|
|
|
|
$body = Compress::Zlib::memGzip( $body ); |
168
|
|
|
|
|
|
|
$r->header_out('Content-Encoding','gzip'); |
169
|
|
|
|
|
|
|
}; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
$r->content_type('text/html'); |
172
|
|
|
|
|
|
|
$r->print( $body ); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
return Apache2::Const::OK; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub _css { |
178
|
|
|
|
|
|
|
return <<'EOF'; |
179
|
|
|
|
|
|
|
BODY { |
180
|
|
|
|
|
|
|
background: white; |
181
|
|
|
|
|
|
|
color: black; |
182
|
|
|
|
|
|
|
font-family: times,serif; |
183
|
|
|
|
|
|
|
margin: 0; |
184
|
|
|
|
|
|
|
padding: 1ex; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
TABLE { |
188
|
|
|
|
|
|
|
border-collapse: collapse; |
189
|
|
|
|
|
|
|
border-spacing: 0; |
190
|
|
|
|
|
|
|
border-width: 0; |
191
|
|
|
|
|
|
|
color: inherit; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
A:link, A:visited { |
195
|
|
|
|
|
|
|
background: transparent; |
196
|
|
|
|
|
|
|
color: #006699; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
PRE { |
200
|
|
|
|
|
|
|
background: #eeeeee; |
201
|
|
|
|
|
|
|
border: 1px solid #888888; |
202
|
|
|
|
|
|
|
color: black; |
203
|
|
|
|
|
|
|
padding-top: 1em; |
204
|
|
|
|
|
|
|
padding-bottom: 1em; |
205
|
|
|
|
|
|
|
white-space: pre; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
H1 { |
209
|
|
|
|
|
|
|
background: transparent; |
210
|
|
|
|
|
|
|
color: #006699; |
211
|
|
|
|
|
|
|
font-size: x-large; |
212
|
|
|
|
|
|
|
font-family: tahoma,sans-serif; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
H2 { |
216
|
|
|
|
|
|
|
background: transparent; |
217
|
|
|
|
|
|
|
color: #006699; |
218
|
|
|
|
|
|
|
font-size: large; |
219
|
|
|
|
|
|
|
font-family: tahoma,sans-serif; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
.block { |
223
|
|
|
|
|
|
|
background: transparent; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
TD .block { |
227
|
|
|
|
|
|
|
color: #006699; |
228
|
|
|
|
|
|
|
background: #dddddd; |
229
|
|
|
|
|
|
|
padding: 0.2em; |
230
|
|
|
|
|
|
|
font-size: large; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
HR { |
234
|
|
|
|
|
|
|
display: none; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
EOF |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 SEE ALSO |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L, |
242
|
|
|
|
|
|
|
L |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Theron Lewis C<< >> |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 HISTORY |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Adapteded from Andy Lester's C<< >> Apache::Pod |
251
|
|
|
|
|
|
|
package which was adapted from |
252
|
|
|
|
|
|
|
Apache2::Perldoc by Rich Bowen C<< >> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Thanks also to |
257
|
|
|
|
|
|
|
Pete Krawczyk, |
258
|
|
|
|
|
|
|
Kjetil Skotheim, |
259
|
|
|
|
|
|
|
Kate Yoak |
260
|
|
|
|
|
|
|
and |
261
|
|
|
|
|
|
|
Chris Eade |
262
|
|
|
|
|
|
|
for contributions. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 LICENSE |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This package is licensed under the same terms as Perl itself. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
1; |