| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Google::Calendar::WebContent; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Net::Google::Calendar::WebContent::VERSION = '1.05'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1549
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
7
|
1
|
|
|
1
|
|
366
|
use XML::Atom; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::Atom::Link; |
|
9
|
|
|
|
|
|
|
#use XML::LibXML; |
|
10
|
|
|
|
|
|
|
#use XML::Atom::Namespace; |
|
11
|
|
|
|
|
|
|
use base qw(XML::Atom::Link Net::Google::Calendar::Base); |
|
12
|
|
|
|
|
|
|
use vars qw(@ISA); |
|
13
|
|
|
|
|
|
|
unshift @ISA, 'XML::Atom::Link'; |
|
14
|
|
|
|
|
|
|
my $ns = XML::Atom::Namespace->new( |
|
15
|
|
|
|
|
|
|
gCal => 'http://schemas.google.com/gCal/2005' |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Net::Google::Calendar::WebContent - handle web content |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Web content can be images ... |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $content = Net::Google::Calendar::WebContent->new( |
|
28
|
|
|
|
|
|
|
title => 'World Cup', |
|
29
|
|
|
|
|
|
|
href => 'http://www.google.com/calendar/images/google-holiday.gif', |
|
30
|
|
|
|
|
|
|
web_content => { |
|
31
|
|
|
|
|
|
|
url => "http://www.google.com/logos/worldcup06.gif" |
|
32
|
|
|
|
|
|
|
width => 276, |
|
33
|
|
|
|
|
|
|
height => 120, |
|
34
|
|
|
|
|
|
|
type => 'image/gif', |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
$entry->add_link($content); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
or html ... |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $content = Net::Google::Calendar::WebContent->new( |
|
42
|
|
|
|
|
|
|
title => 'Embedded HTML', |
|
43
|
|
|
|
|
|
|
href => 'http://www.example.com/favico.icon', |
|
44
|
|
|
|
|
|
|
web_content => { |
|
45
|
|
|
|
|
|
|
url => "http://www.example.com/some.html" |
|
46
|
|
|
|
|
|
|
width => 276, |
|
47
|
|
|
|
|
|
|
height => 120, |
|
48
|
|
|
|
|
|
|
type => 'text/html', |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
$entry->add_link($content); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
or special Google Gadgets (http://www.google.com/ig/directory) |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $content = Net::Google::Calendar::WebContent->new( |
|
57
|
|
|
|
|
|
|
title => 'DateTime Gadget (a classic!)', |
|
58
|
|
|
|
|
|
|
href => 'http://www.google.com/favicon.ico', |
|
59
|
|
|
|
|
|
|
web_content => { |
|
60
|
|
|
|
|
|
|
url => 'http://google.com/ig/modules/datetime.xml', |
|
61
|
|
|
|
|
|
|
width => 300, |
|
62
|
|
|
|
|
|
|
height => 136, |
|
63
|
|
|
|
|
|
|
type => 'application/x-google-gadgets+xml', |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
or |
|
69
|
|
|
|
|
|
|
my $content = Net::Google::Calendar::WebContent->new( |
|
70
|
|
|
|
|
|
|
title => 'Word of the Day', |
|
71
|
|
|
|
|
|
|
href => 'http://www.thefreedictionary.com/favicon.ico', |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
$content->web_content( |
|
74
|
|
|
|
|
|
|
url => 'http://www.thefreedictionary.com/_/WoD/wod-module.xml', |
|
75
|
|
|
|
|
|
|
width => 300, |
|
76
|
|
|
|
|
|
|
height => 136, |
|
77
|
|
|
|
|
|
|
type => 'application/x-google-gadgets+xml', |
|
78
|
|
|
|
|
|
|
prefs => { Days => 1, Format => 0 }, |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
(note the ability to set webContentGadgetPrefs using the special prefs attribute). |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 new [opt[s]] |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Options can be |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item title |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The title of the web content |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item href |
|
96
|
|
|
|
|
|
|
A url of an icon to use |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item type |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The mime type of content. Can be either C C or C |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Not needed for C. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item web_content |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The actual web content. This just gets passed to the C method. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub new { |
|
114
|
|
|
|
|
|
|
my $class = shift; |
|
115
|
|
|
|
|
|
|
my %params = @_; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#my $self = XML::Atom::Link->new(Version => "1.0"); |
|
118
|
|
|
|
|
|
|
#$self = bless $self, $class; |
|
119
|
|
|
|
|
|
|
my $ns = XML::Atom::Namespace->new(gd => 'http://schemas.google.com/g/2005'); |
|
120
|
|
|
|
|
|
|
my $self = $class->SUPER::new(Version => "1.0", ); |
|
121
|
|
|
|
|
|
|
$self->{_gd_ns} = $ns; |
|
122
|
|
|
|
|
|
|
$self->rel('http://schemas.google.com/gCal/2005/webContent'); |
|
123
|
|
|
|
|
|
|
for my $field (qw(title href)) { |
|
124
|
|
|
|
|
|
|
die "You must pass in the field '$field' to a WebContent link\n" |
|
125
|
|
|
|
|
|
|
unless defined $params{$field}; |
|
126
|
|
|
|
|
|
|
$self->$field($params{$field}); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
my $type = $params{type}; |
|
129
|
|
|
|
|
|
|
#die "You must pass a type" unless defined $type; |
|
130
|
|
|
|
|
|
|
$self->_set_type($type) if defined $type; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
if ($params{web_content}) { |
|
133
|
|
|
|
|
|
|
$self->web_content(%{$params{web_content}}); |
|
134
|
|
|
|
|
|
|
} else { |
|
135
|
|
|
|
|
|
|
# h-h-hack |
|
136
|
|
|
|
|
|
|
$self->web_content(empty => 1); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
return $self; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _set_type { |
|
142
|
|
|
|
|
|
|
my $self = shift; |
|
143
|
|
|
|
|
|
|
my $type = shift; |
|
144
|
|
|
|
|
|
|
unless ($type eq 'text/html' or |
|
145
|
|
|
|
|
|
|
$type eq 'application/x-google-gadgets+xml' or |
|
146
|
|
|
|
|
|
|
$type =~ m!^image/!) { |
|
147
|
|
|
|
|
|
|
die "The type param must be text/html or application/x-google-gadgets+xml or image/*\n"; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
$self->type($type); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 web_content [param[s]] |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Takes a hash of parameters. Valid are |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 4 |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item url |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The url of the content. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item width |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The width of the content. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item height |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The height of the content. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item type |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The mime-type (see above) |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item prefs |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This takes a hash ref and all pairs are turned into C entries. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub web_content { |
|
184
|
|
|
|
|
|
|
my $self = shift; |
|
185
|
|
|
|
|
|
|
my $name = 'gCal:webContent'; |
|
186
|
|
|
|
|
|
|
if (@_) { |
|
187
|
|
|
|
|
|
|
my %params = @_; |
|
188
|
|
|
|
|
|
|
# h-h-hack |
|
189
|
|
|
|
|
|
|
%params = () if $params{empty}; |
|
190
|
|
|
|
|
|
|
if (my $type = delete $params{type}) { |
|
191
|
|
|
|
|
|
|
$self->_set_type($type); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
# egregious hack |
|
194
|
|
|
|
|
|
|
$params{'xmlns:gd'} = 'http://schemas.google.com/g/2005'; |
|
195
|
|
|
|
|
|
|
$params{'xmlns:gCal'} = 'http://schemas.google.com/gCal/2005'; |
|
196
|
|
|
|
|
|
|
my $prefs = delete $params{prefs}; |
|
197
|
|
|
|
|
|
|
XML::Atom::Base::set($self, '', $name, '', \%params); |
|
198
|
|
|
|
|
|
|
my $content = $self->_my_get('', $name); |
|
199
|
|
|
|
|
|
|
foreach my $key (keys %{$prefs}) { |
|
200
|
|
|
|
|
|
|
# TODO: this feels icky |
|
201
|
|
|
|
|
|
|
my $node; |
|
202
|
|
|
|
|
|
|
if (LIBXML) { |
|
203
|
|
|
|
|
|
|
$node = XML::LibXML::Element->new($name.'GadgetPref'); |
|
204
|
|
|
|
|
|
|
$node->setAttribute( name => $key ); |
|
205
|
|
|
|
|
|
|
$node->setAttribute( value => $prefs->{$key} ); |
|
206
|
|
|
|
|
|
|
} else { |
|
207
|
|
|
|
|
|
|
$node = XML::XPath::Node::Element->new($name.'GadgetPref'); |
|
208
|
|
|
|
|
|
|
$node->addAttribute(XML::XPath::Node::Attribute->new(name => $key)); |
|
209
|
|
|
|
|
|
|
$node->addAttribute(XML::XPath::Node::Attribute->new(value => $prefs->{key})); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
$content->appendChild($node); |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
return $self->_my_get('', $name); |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|