| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Apache::Perldoc; |
|
2
|
1
|
|
|
1
|
|
24554
|
use vars qw( $VERSION ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
448
|
|
|
3
|
|
|
|
|
|
|
$VERSION = qw($Revision: 1.11 $)[1]; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub handler { |
|
6
|
0
|
|
|
0
|
0
|
|
my $r = shift; |
|
7
|
0
|
|
|
|
|
|
$r->content_type('text/html'); |
|
8
|
0
|
|
|
|
|
|
$r->send_http_header; |
|
9
|
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
my $pod; |
|
11
|
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
warn $r->filename; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
if ($r->filename =~ m/\.pod$/i) { |
|
15
|
0
|
|
|
|
|
|
$pod = $r->filename; |
|
16
|
|
|
|
|
|
|
} else { |
|
17
|
0
|
|
|
|
|
|
$pod = $r->path_info; |
|
18
|
0
|
|
|
|
|
|
$pod =~ s|/||; |
|
19
|
0
|
|
|
|
|
|
$pod =~ s|/|::|g; |
|
20
|
0
|
|
|
|
|
|
$pod =~ s|\.html$||; # Intermodule links end with .html |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
$pod = 'perl' unless $pod; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$pod =~ |
|
26
|
|
|
|
|
|
|
s/^f::/-f /; # If we specify /f/ as our "base", it's a function search |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
0
|
|
|
|
my $tmp = $r->dir_config('TMP') || "/tmp"; |
|
29
|
0
|
|
|
|
|
|
my $perldoc = $r->dir_config('PERLDOC'); |
|
30
|
0
|
|
|
|
|
|
my $pod2html = $r->dir_config('POD2HTML'); |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if ( $perldoc && $pod2html ) { |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# We want to run tainted |
|
35
|
0
|
|
|
|
|
|
$ENV{PATH} = "/bin"; |
|
36
|
|
|
|
|
|
|
} else { |
|
37
|
0
|
|
0
|
|
|
|
$perldoc ||= "perldoc"; |
|
38
|
0
|
|
0
|
|
|
|
$pod2html ||= "pod2html"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Get the path name and throw away errors on stderr |
|
42
|
0
|
|
|
|
|
|
my $filename = qx( $perldoc -l $pod 2> /dev/null ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if ($?) { |
|
45
|
0
|
|
|
|
|
|
print |
|
46
|
|
|
|
|
|
|
"No such perldoc. Either you don't have that module installed, or the author neglected to provide documentation."; |
|
47
|
|
|
|
|
|
|
} else { |
|
48
|
0
|
|
|
|
|
|
chdir $tmp; |
|
49
|
0
|
|
|
|
|
|
print qx( $perldoc -u $pod | $pod2html --htmlroot=/perldoc --header ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Documentation {{{ |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Apache::Perldoc - mod_perl handler to spooge out HTML perldocs |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A simple mod_perl handler to give you Perl documentation on installed |
|
64
|
|
|
|
|
|
|
modules. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The following configuration should go in your httpd.conf |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
SetHandler perl-script |
|
70
|
|
|
|
|
|
|
PerlHandler Apache::Perldoc |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
You can then get documentation for a module C at the URL |
|
74
|
|
|
|
|
|
|
C |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Note that you can also get the standard Perl documentation with URLs |
|
77
|
|
|
|
|
|
|
like C or just |
|
78
|
|
|
|
|
|
|
C for the main Perl docs. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Finally, you can search for a particular Perl keyword with |
|
81
|
|
|
|
|
|
|
C The 'f' is used by analogy |
|
82
|
|
|
|
|
|
|
with the C<-f> flag to C. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
In addition to Perl modules, you can have C convert |
|
85
|
|
|
|
|
|
|
C<.pod> files to HTML with the following configiration: |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
SetHandler perl-script |
|
89
|
|
|
|
|
|
|
PerlHandler Apache::Perldoc |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This has not been extensively tested, but appears to mostly work. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 Running under C |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
If you have C turned on, then we can't rely on |
|
97
|
|
|
|
|
|
|
C<$ENV{PATH}> to find F and F. You'll have to |
|
98
|
|
|
|
|
|
|
specify the full paths to F and F like so: |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
SetHandler perl-script |
|
102
|
|
|
|
|
|
|
PerlHandler Apache::Perldoc |
|
103
|
|
|
|
|
|
|
PerlSetVar PERLDOC /usr/local/bin/perldoc |
|
104
|
|
|
|
|
|
|
PerlSetVar POD2HTML /usr/local/bin/pod2html |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 Specifying your own C directory |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
C assumes that it can use F as the temp directory |
|
110
|
|
|
|
|
|
|
to run from, since F requires a place to put its work files. |
|
111
|
|
|
|
|
|
|
You can override this with a |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
PerlSetVar TMP /my/temp/directory |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 Author |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Rich Bowen |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
http://www.ApacheAdmin.com/ |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Patches from Andy Lester to make it a little bit more secure. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 Caveat |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Note that this is EXCEEDINGLY insecure. Run this at your own risk, and |
|
126
|
|
|
|
|
|
|
only on internal web sites, if you know what's good for you. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
If someone would like to make this a little more secure, I would be |
|
129
|
|
|
|
|
|
|
delighted to apply any patches you would like to provide. This module |
|
130
|
|
|
|
|
|
|
was written for my own benefit, and put back on CPAN because some folks |
|
131
|
|
|
|
|
|
|
asked me to. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You have been warned. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 Other neat trick - Bookmarklet |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
If you create a browser bookmark to the following URL, you can highlight |
|
138
|
|
|
|
|
|
|
the name of a module on web page, then select the bookmark, and go |
|
139
|
|
|
|
|
|
|
directly to the documentation for that module. Selecting the bookmark |
|
140
|
|
|
|
|
|
|
without having anything highlighted will result in a pop-up dialog in |
|
141
|
|
|
|
|
|
|
which you can type a module name. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Module |
|
144
|
|
|
|
|
|
|
name',''))};if(Qr)location.href='http://localhost/perldoc/'+escape(Qr) |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Note that that's all one line, split here for display purposes. I know |
|
147
|
|
|
|
|
|
|
this works in Netscape and Mozilla. Can't vouch for IE. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 LICENSE |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This code is released under the HJTI license ("Here, Just Take It"), or, |
|
152
|
|
|
|
|
|
|
if you really want a real license, take your pick of the GPL and the |
|
153
|
|
|
|
|
|
|
Artistic License. Which is to say, this is release under the same terms |
|
154
|
|
|
|
|
|
|
as Perl itself. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The author makes no particular claims to ownership, as this is a really |
|
157
|
|
|
|
|
|
|
obvious idea, and a lot of other people have been doing this for ages. I |
|
158
|
|
|
|
|
|
|
just appear to be the first to put it on CPAN. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# }}} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|