line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Hyperlink::BounceURL; |
2
|
1
|
|
|
1
|
|
35449
|
use Pod::ParseUtils; |
|
1
|
|
|
|
|
9807
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
1000
|
use URI::Escape; |
|
1
|
|
|
|
|
1683
|
|
|
1
|
|
|
|
|
90
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
9
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
558
|
|
6
|
|
|
|
|
|
|
$VERSION = ('$Revision: 1.7 $' =~ /([\d\.]+)/)[0]; |
7
|
|
|
|
|
|
|
@ISA = 'Pod::Hyperlink'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub configure { |
10
|
1
|
|
|
1
|
1
|
696
|
my $self = shift; |
11
|
1
|
|
|
|
|
5
|
my %opts = @_; |
12
|
1
|
50
|
|
|
|
6
|
if ($opts{'URL'}) { |
13
|
1
|
|
|
|
|
7
|
$self->{'___url'} = $opts{'URL'}; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub type { |
18
|
36
|
|
|
36
|
1
|
4098
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# very special case - if we are called explicitly (rather than by our superclass) and with other conditions |
21
|
|
|
|
|
|
|
# 1) a page type with a page value |
22
|
|
|
|
|
|
|
# 2) an item type with a page value |
23
|
|
|
|
|
|
|
# We don't care about any other cases |
24
|
36
|
|
|
|
|
85
|
my ($callpack) = caller(); |
25
|
36
|
100
|
|
|
|
179
|
if ($callpack ne $ISA[0]) { |
26
|
18
|
|
|
|
|
147
|
DUMP(__PACKAGE__."::type", [ $self, @_ ]); |
27
|
|
|
|
|
|
|
} else { |
28
|
18
|
|
|
|
|
53
|
DUMP(" indirect call of ".__PACKAGE__."::type", [ $self, @_ ]); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
36
|
100
|
100
|
|
|
1512
|
if ( |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
32
|
|
|
|
|
|
|
($callpack ne $ISA[0]) |
33
|
|
|
|
|
|
|
&& (($self->{'-type'} eq 'page') || ($self->{'-type'} eq 'item')) |
34
|
|
|
|
|
|
|
&& $self->{'-page'} |
35
|
|
|
|
|
|
|
) { |
36
|
13
|
|
|
|
|
41
|
my $page_esc = uri_escape( $self->{'-page'} ); |
37
|
13
|
|
|
|
|
226
|
my $node_esc = uri_escape( $self->{'-node'} ); |
38
|
13
|
|
|
|
|
174
|
my $url = sprintf( $self->{'___url'}, $page_esc, $node_esc ); |
39
|
13
|
|
|
|
|
46
|
return "bounceurl:$url"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
# in all other cases, let the superclass handle the work |
42
|
23
|
|
|
|
|
97
|
return $self->SUPER::type(@_); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# debug hooks |
46
|
0
|
|
|
0
|
0
|
0
|
sub TRACE {} |
47
|
36
|
|
|
36
|
0
|
53
|
sub DUMP {} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Pod::Hyperlink::BounceURL - Allow off-page links in POD to point to a URL |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Pod::Hyperlink::BounceURL; |
58
|
|
|
|
|
|
|
my $linkparser = new Pod::Hyperlink::BounceURL; |
59
|
|
|
|
|
|
|
$linkparser->configure( URL => '/cgi-perl/support/bounce.pl?page=%s' ); |
60
|
|
|
|
|
|
|
my $pod2xhtml = new Pod::Xhtml( LinkParser => $linkparser ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Some links in your pod may not be resolveable by Pod::Hyperlink, e.g. CSome::ModuleE> - |
65
|
|
|
|
|
|
|
this module allows you to detect such links and generate a hyperlink instead of some static text. |
66
|
|
|
|
|
|
|
The target URL will probably be some kind of dynamic webpage or CGI application which can then serve up |
67
|
|
|
|
|
|
|
the relevant page or send a redirect to the page, hence the "bounce" in this module's name. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This module overrides the type() method and, for relevant links, will return a string which is |
70
|
|
|
|
|
|
|
"bounceurl:" followed by the URL, instead of returning "page" or "item". |
71
|
|
|
|
|
|
|
Your pod-conversion module can then switch on this case and emit the correct kind of markup. |
72
|
|
|
|
|
|
|
L supports the use of this module. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item configure( %OPTIONS ) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Set persistent configuration for this object. See L. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item type() |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Behaves as L's type() method except for the unresolveable links, where the string returned is |
85
|
|
|
|
|
|
|
as described in L. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 OPTIONS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item URL |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The URL to handle the link, which may be absolute or relative, of any protocol - it's just |
96
|
|
|
|
|
|
|
treated as a string and is passed through sprintf(), with two string arguments that are both |
97
|
|
|
|
|
|
|
already URL-escaped. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The first argument is the page name, and will always exist. The second argument is the "node" within the page, and may be |
100
|
|
|
|
|
|
|
empty. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Insert '%s' where you wish the arguments to be interpolated. The string goes through sprintf() so |
103
|
|
|
|
|
|
|
you should have '%%' where you want an actual percent sign. If you need the arguments in a different order, see |
104
|
|
|
|
|
|
|
the perl-specific features of L. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$Revision: 1.7 $ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
P Kent Ecpan _at_ bbc _dot_ co _dot_ ukE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
(c) BBC 2007. This program is free software; you can redistribute it and/or modify it under the GNU GPL. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|