| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Adsense; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
25380
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
77
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
61
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1579
|
use Class::Accessor; |
|
|
2
|
|
|
|
|
3824
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
58
|
use base qw(Class::Accessor); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1081
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
HTML::Adsense->mk_accessors(qw(client width height format type channel border bg link text url)); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
1
|
|
|
1
|
1
|
453
|
my ($class, %args) = @_; |
|
16
|
1
|
|
|
|
|
5
|
my $self = bless { %args }, $class; |
|
17
|
1
|
|
|
|
|
6
|
$self->set_defaults(); |
|
18
|
1
|
|
|
|
|
2
|
return $self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub set_defaults { |
|
22
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
|
23
|
1
|
|
|
|
|
6
|
$self->client('pub-4763368282156432'); |
|
24
|
1
|
|
|
|
|
22
|
$self->set_format('text 468x60'); |
|
25
|
1
|
|
|
|
|
3
|
$self->border('FFFFFF'); |
|
26
|
1
|
|
|
|
|
10
|
$self->bg('FFFFFF'); |
|
27
|
1
|
|
|
|
|
9
|
$self->link('CC6600'); |
|
28
|
1
|
|
|
|
|
9
|
$self->text('000000'); |
|
29
|
1
|
|
|
|
|
9
|
$self->url('008000'); |
|
30
|
1
|
|
|
|
|
7
|
return 1; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub set_format { |
|
34
|
3
|
|
|
3
|
1
|
764
|
my ($self, $format) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
18
|
my %formats = ( |
|
37
|
|
|
|
|
|
|
'text 468x60' => ['468x60_as', 468, 60, 'text'], |
|
38
|
|
|
|
|
|
|
'text 728x90' => ['728x90_as', 728, 90, 'text'], |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
3
|
|
66
|
|
|
19
|
$format = $formats{$format} || $formats{'text 468x60'}; |
|
42
|
3
|
|
|
|
|
12
|
$self->format($format->[0]); |
|
43
|
3
|
|
|
|
|
42
|
$self->width($format->[1]); |
|
44
|
3
|
|
|
|
|
30
|
$self->height($format->[2]); |
|
45
|
3
|
|
|
|
|
30
|
$self->type($format->[3]); |
|
46
|
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
31
|
return 1; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub render { |
|
51
|
4
|
|
|
4
|
1
|
995
|
my ($self) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
4
|
50
|
|
|
|
11
|
if (! $self->client) { die 'A client ID must be provided.'; } |
|
|
0
|
|
|
|
|
0
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
49
|
my $ad = ''; |
|
56
|
4
|
|
|
|
|
8
|
$ad .= <<'EOF'; |
|
57
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
EOF |
|
74
|
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
24
|
return $ad; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
HTML::Adsense - Create adsense widgets easily |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This module wraps Google Adsense ad creation in OO perl code. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use HTML::Adsense; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $myad = HTML::Adsense->new( |
|
91
|
|
|
|
|
|
|
'client' => 'pub-4763368282156432', |
|
92
|
|
|
|
|
|
|
); # OR |
|
93
|
|
|
|
|
|
|
$myad->client('pub-4763368282156432'); |
|
94
|
|
|
|
|
|
|
print $myadd->render(); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 new |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Creates the HTML::Adsense object. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 render |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns a the adsense code. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 set_defaults |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Sets several defaults, used in object creation. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 set_format |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Sets the height, width, type and format variables based on a format name |
|
113
|
|
|
|
|
|
|
and a list of preset values. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item client |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The client ID. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item width |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The ad width. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item height |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The ad height. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item format |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The ad format. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item type |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The ad type. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item channel |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
The ad channel. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item border |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The ad border color. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item bg |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
The ad background color. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item link |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The ad link color. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item text |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
The ad text color. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item url |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The ad url color. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SUPPORTED AD FORMATS |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This module has several height/width/type formats to select from. See the |
|
168
|
|
|
|
|
|
|
adsense formats page for more information on available adsense formats. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
https://www.google.com/adsense/adformats |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This doesn't prevent you from using your own formats and colors. See the |
|
173
|
|
|
|
|
|
|
accessor methods for more information. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item text 468x60 |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item text 728x90 |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Nick Gerakines, C<< >> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 CAVEATS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
[A] There is a default client ID set. You Must either pass the client ID when |
|
190
|
|
|
|
|
|
|
creating the object or set it via an accessor or you will B get paid. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
[B] The current list of supported ad preset formats is very limited. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 BUGS |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
197
|
|
|
|
|
|
|
C, or through the web interface at |
|
198
|
|
|
|
|
|
|
L. |
|
199
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
200
|
|
|
|
|
|
|
your bug as I make changes. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SUPPORT |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
perldoc HTML::Adsense |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
You can also look for information at: |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=over 4 |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
L |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item * Search CPAN |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
L |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * Google Adsense Home Page |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * Google Adsense Blog |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * Google Adsense Supported Formats |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Copyright 2006 Nick Gerakines, all rights reserved. |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
247
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |