| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
15
|
|
|
15
|
|
15895
|
use strict; |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
485
|
|
|
2
|
15
|
|
|
15
|
|
156
|
use warnings; |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
757
|
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin::Link; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: a hyperlink |
|
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::Link::VERSION = '0.202'; |
|
6
|
15
|
|
|
15
|
|
72
|
use parent 'HTML::Widget::Plugin'; |
|
|
15
|
|
|
|
|
24
|
|
|
|
15
|
|
|
|
|
84
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
9
|
|
|
|
|
|
|
#pod |
|
10
|
|
|
|
|
|
|
#pod $widget_factory->link({ |
|
11
|
|
|
|
|
|
|
#pod text => "my favorite D&D pages", |
|
12
|
|
|
|
|
|
|
#pod href => 'http://rjbs.manxome.org/rubric/entries/tags/dnd', |
|
13
|
|
|
|
|
|
|
#pod }); |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod ...or... |
|
16
|
|
|
|
|
|
|
#pod |
|
17
|
|
|
|
|
|
|
#pod $widget_factory->link({ |
|
18
|
|
|
|
|
|
|
#pod html => "some great d&d pages", |
|
19
|
|
|
|
|
|
|
#pod href => 'http://rjbs.manxome.org/rubric/entries/tags/dnd', |
|
20
|
|
|
|
|
|
|
#pod }); |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
23
|
|
|
|
|
|
|
#pod |
|
24
|
|
|
|
|
|
|
#pod This plugin provides a basic input widget. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod =cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
15
|
|
|
15
|
|
812
|
use Carp (); |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
262
|
|
|
29
|
15
|
|
|
15
|
|
72
|
use HTML::Element; |
|
|
15
|
|
|
|
|
22
|
|
|
|
15
|
|
|
|
|
100
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#pod =head1 METHODS |
|
32
|
|
|
|
|
|
|
#pod |
|
33
|
|
|
|
|
|
|
#pod =head2 C< provided_widgets > |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod This plugin provides the following widgets: link |
|
36
|
|
|
|
|
|
|
#pod |
|
37
|
|
|
|
|
|
|
#pod =cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
16
|
|
|
16
|
1
|
69
|
sub provided_widgets { qw(link) } |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#pod =head2 C< link > |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod This method returns a basic text hyperlink. |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod In addition to the generic L attributes, the following |
|
46
|
|
|
|
|
|
|
#pod are valid arguments: |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod =over |
|
49
|
|
|
|
|
|
|
#pod |
|
50
|
|
|
|
|
|
|
#pod =item href |
|
51
|
|
|
|
|
|
|
#pod |
|
52
|
|
|
|
|
|
|
#pod This is the URI to which the link ... um ... links. If no href is supplied, an |
|
53
|
|
|
|
|
|
|
#pod exception is thrown. |
|
54
|
|
|
|
|
|
|
#pod |
|
55
|
|
|
|
|
|
|
#pod =item html |
|
56
|
|
|
|
|
|
|
#pod |
|
57
|
|
|
|
|
|
|
#pod =item text |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod Either of these may contain the text of created link. If passed as C, it |
|
60
|
|
|
|
|
|
|
#pod is not escaped; if passed as C, it is. If no text is supplied, the href |
|
61
|
|
|
|
|
|
|
#pod is used. If both options are provided, an exception is thrown. |
|
62
|
|
|
|
|
|
|
#pod |
|
63
|
|
|
|
|
|
|
#pod =back |
|
64
|
|
|
|
|
|
|
#pod |
|
65
|
|
|
|
|
|
|
#pod =cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
16
|
|
|
16
|
|
75
|
sub _attribute_args { qw(href title) } |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub link { ## no critic Builtin |
|
70
|
6
|
|
|
6
|
1
|
11
|
my ($self, $factory, $arg) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
6
|
100
|
|
|
|
29
|
$arg->{attr}{name} = $arg->{attr}{id} if not defined $arg->{attr}{name}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
6
|
100
|
|
|
|
234
|
Carp::croak "can't create a link without an href" |
|
75
|
|
|
|
|
|
|
unless $arg->{attr}{href}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
5
|
100
|
100
|
|
|
153
|
Carp::croak "text and html arguments for link widget are mutually exclusive" |
|
78
|
|
|
|
|
|
|
if $arg->{text} and $arg->{html}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
22
|
my $widget = HTML::Element->new('a'); |
|
81
|
4
|
|
|
|
|
98
|
$widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; |
|
|
4
|
|
|
|
|
30
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
212
|
my $content; |
|
84
|
4
|
100
|
|
|
|
11
|
if ($arg->{html}) { |
|
85
|
2
|
100
|
|
|
|
9
|
$content = ref $arg->{html} |
|
86
|
|
|
|
|
|
|
? $arg->{html} |
|
87
|
|
|
|
|
|
|
: HTML::Element->new('~literal' => text => $arg->{html}); |
|
88
|
|
|
|
|
|
|
} else { |
|
89
|
2
|
100
|
|
|
|
9
|
$content = defined $arg->{text} ? $arg->{text} : $arg->{attr}{href}; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
4
|
|
|
|
|
39
|
$widget->push_content($content); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# We chomp this to avoid significant whitespace. -- rjbs, 2008-09-22 |
|
95
|
4
|
|
|
|
|
70
|
my $xml = $widget->as_XML; |
|
96
|
4
|
|
|
|
|
1428
|
chomp $xml; |
|
97
|
4
|
|
|
|
|
38
|
return $xml; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |