line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Link::Reporter::RepairForm; |
2
|
|
|
|
|
|
|
$REVISION=q$Revision: 1.6 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ ); |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
WWW::Link::Reporter::RepairForm - Build a form for repairing links |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use WWW::Link; |
11
|
|
|
|
|
|
|
use WWW::Link::Reporter::RepairForm; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$link=new WWW::Link; |
14
|
|
|
|
|
|
|
#over time do things to the link ...... |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$::reporter=new WWW::Link::Reporter::RepairForm; |
17
|
|
|
|
|
|
|
$::reporter->examine($link) |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
or see WWW::Link::Selector for a way to recurse through all of the links. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This class will output information about any link that it is given. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
886
|
use WWW::Link; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
29
|
1
|
|
|
1
|
|
6
|
use HTML::Stream; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
30
|
1
|
|
|
1
|
|
6
|
use WWW::Link::Reporter::HTML; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
31
|
1
|
|
|
1
|
|
123460
|
use CGI::Form; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
@ISA=qw(WWW::Link::Reporter::HTML); |
34
|
|
|
|
|
|
|
use warnings; |
35
|
|
|
|
|
|
|
use strict; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
|
|
|
|
|
|
my $class=shift; |
40
|
|
|
|
|
|
|
my $fixlink_cgi=shift; |
41
|
|
|
|
|
|
|
my $index=shift; |
42
|
|
|
|
|
|
|
my $self=WWW::Link::Reporter::new($class, $index); |
43
|
|
|
|
|
|
|
my $stream=shift; |
44
|
|
|
|
|
|
|
$self->{"hstr"} = new HTML::Stream::LinkRepairForm $stream; |
45
|
|
|
|
|
|
|
$self->{"docurl"} = "http://localhost/linkcontroler/docs/"; |
46
|
|
|
|
|
|
|
$self->{"fixlink_cgi"} = $fixlink_cgi; |
47
|
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub not_found { return 1; } #just shut up please. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#...inherited methods..... |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub broken { |
56
|
|
|
|
|
|
|
my $self=shift; |
57
|
|
|
|
|
|
|
my $link=shift; |
58
|
|
|
|
|
|
|
my $url=$link->url(); |
59
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$hstr-> P; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$hstr -> STRONG -> nl |
64
|
|
|
|
|
|
|
->Link_Heading($url, "Link found BROKEN") |
65
|
|
|
|
|
|
|
-> _STRONG -> nl; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$hstr -> auto_form($link, $self->{"fixlink_cgi"}, $url); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if ($self->{"index"}) { |
70
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$hstr-> _P->nl; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub okay { |
77
|
|
|
|
|
|
|
my $self=shift; |
78
|
|
|
|
|
|
|
my $link=shift; |
79
|
|
|
|
|
|
|
my $url=$link->url(); |
80
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$hstr -> P; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link tested okay"); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ($self->{"index"}) { |
87
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$hstr -> _P->nl; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub damaged { |
94
|
|
|
|
|
|
|
my $self=shift; |
95
|
|
|
|
|
|
|
my $link=shift; |
96
|
|
|
|
|
|
|
my $url=$link->url(); |
97
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$hstr -> P; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link may be broken"); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$hstr -> auto_form($link, $self->{"fixlink_cgi"}, $url); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
if ($self->{"index "}) { |
106
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$hstr -> _P->nl; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub not_checked { |
113
|
|
|
|
|
|
|
my $self=shift; |
114
|
|
|
|
|
|
|
my $link=shift; |
115
|
|
|
|
|
|
|
my $url=$link->url(); |
116
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$hstr -> P; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link has not yet been checked"); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$hstr -> correct_form($self->{"fixlink_cgi"}, $url); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
if ($self->{"index"}) { |
125
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$hstr -> _P->nl; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub disallowed { |
132
|
|
|
|
|
|
|
my $self=shift; |
133
|
|
|
|
|
|
|
my $link=shift; |
134
|
|
|
|
|
|
|
my $url=$link->url(); |
135
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$hstr -> P; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link checking is not permitted"); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$hstr -> auto_form($link, $self->{"fixlink_cgi"}, $url); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
if ($self->{"index"}) { |
144
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$hstr -> _P->nl; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub unsupported { |
151
|
|
|
|
|
|
|
my $self=shift; |
152
|
|
|
|
|
|
|
my $link=shift; |
153
|
|
|
|
|
|
|
my $url=$link->url(); |
154
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$hstr -> P; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link uses unsupported protocol"); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
$hstr -> auto_form($link, $self->{"fixlink_cgi"}, $url); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
if ($self->{"index"}) { |
163
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
$hstr -> _P->nl; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub unknown { |
170
|
|
|
|
|
|
|
my $self=shift; |
171
|
|
|
|
|
|
|
my $link=shift; |
172
|
|
|
|
|
|
|
my $url=$link->url(); |
173
|
|
|
|
|
|
|
my $hstr=$self->{"hstr"}; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
$hstr -> P; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$hstr->Link_Heading($url, "Link status unknown; error?"); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$hstr -> auto_form($link, $self->{"fixlink_cgi"}, $url); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
if ($self->{"index"}) { |
182
|
|
|
|
|
|
|
$hstr->page_list( $self->{"index"}->lookup_second($url) ); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$hstr -> _P->nl; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
package HTML::Stream::LinkRepairForm; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
our @ISA; |
193
|
|
|
|
|
|
|
@ISA=qw(HTML::Stream::LinkReport); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
use Carp; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 $self->correct_form() $self->auto_form() |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$self->correct_form(action,url,array_ref) |
200
|
|
|
|
|
|
|
$self->auto_form(link,action,url) |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
These methods write a form which can be used for repairing a broken |
203
|
|
|
|
|
|
|
link. The form has a hidden attribute giving the original link it |
204
|
|
|
|
|
|
|
refered to. It then outputs a list of known suggestions in a radio |
205
|
|
|
|
|
|
|
list and finally outputs a text field in which a completely new |
206
|
|
|
|
|
|
|
suggestion can be input. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
C automatically populates the form with any suggestions and |
209
|
|
|
|
|
|
|
redirections which the link has attached to it. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub auto_form { |
214
|
|
|
|
|
|
|
my $self=shift; |
215
|
|
|
|
|
|
|
my $link=shift; |
216
|
|
|
|
|
|
|
my @urls=$link->redirect_urls(); |
217
|
|
|
|
|
|
|
my $suggestions=$link->fix_suggestions(); |
218
|
|
|
|
|
|
|
unshift @urls, @$suggestions if $suggestions; |
219
|
|
|
|
|
|
|
$self->correct_form(@_, \@urls); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub correct_form { |
223
|
|
|
|
|
|
|
my $self=shift; |
224
|
|
|
|
|
|
|
my $action=shift; |
225
|
|
|
|
|
|
|
my $orig_url=shift; |
226
|
|
|
|
|
|
|
croak "correct_form called without original url\n" unless defined $orig_url; |
227
|
|
|
|
|
|
|
my $array=shift; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
$self->FORM(METHOD=>"POST", ACTION=>$action); |
230
|
|
|
|
|
|
|
$self->INPUT(NAME=>"orig-url", VALUE=>$orig_url, TYPE=>"HIDDEN"); |
231
|
|
|
|
|
|
|
$self->nl->t("Set new end point for link.")->nl->UL; |
232
|
|
|
|
|
|
|
if ($array) { |
233
|
|
|
|
|
|
|
foreach (@$array) { |
234
|
|
|
|
|
|
|
$self -> LI |
235
|
|
|
|
|
|
|
-> INPUT(TYPE=>"radio", NAME=>"canned-suggestion", VALUE=>$_) |
236
|
|
|
|
|
|
|
-> Link($_) |
237
|
|
|
|
|
|
|
-> _LI ->nl; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
$self -> LI |
240
|
|
|
|
|
|
|
-> INPUT(TYPE=>"radio", NAME=>"canned-suggestion", VALUE=>"user") |
241
|
|
|
|
|
|
|
-> t("set new url below") |
242
|
|
|
|
|
|
|
-> _LI ->nl; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
$self -> LI |
245
|
|
|
|
|
|
|
->INPUT(TYPE=>"text", NAME=>"user_suggestion") |
246
|
|
|
|
|
|
|
->INPUT(TYPE=>"submit", NAME=>"Repair Link") |
247
|
|
|
|
|
|
|
-> _LI; |
248
|
|
|
|
|
|
|
$self->_UL |
249
|
|
|
|
|
|
|
->_FORM; |
250
|
|
|
|
|
|
|
return $self; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|