| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Posterous::Post; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2402
|
use base qw(Net::Posterous::Object); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
500
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use Class::Accessor "antlers"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
120
|
use Scalar::Util qw(blessed); |
|
|
1
|
|
|
|
|
34
|
|
|
|
1
|
|
|
|
|
221
|
|
|
6
|
1
|
|
|
1
|
|
2254
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
13763
|
|
|
|
1
|
|
|
|
|
76
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use MIME::Base64; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
53
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
636
|
use Net::Posterous::Media::Image; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
11
|
|
|
10
|
1
|
|
|
1
|
|
597
|
use Net::Posterous::Media::Video; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
11
|
1
|
|
|
1
|
|
597
|
use Net::Posterous::Media::Audio; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
12
|
1
|
|
|
1
|
|
547
|
use Net::Posterous::Media::Local; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
8
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Net::Posterous::Post - represent a post instance in Net::Posterous |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Create a new Post |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
34
|
0
|
|
|
|
|
|
my %opts = @_; |
|
35
|
0
|
|
|
|
|
|
my $media = delete $opts{media}; |
|
36
|
0
|
|
0
|
|
|
|
my $comments = delete $opts{comments} || delete $opts{comment}; |
|
37
|
0
|
|
|
|
|
|
my $self = bless \%opts, $class; |
|
38
|
0
|
0
|
|
|
|
|
$self->media('ARRAY' eq ref($media) ? @$media : $media) if $media; |
|
|
|
0
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
$self->comments('ARRAY' eq ref($comments) ? @$commend : $comments) if $comments; |
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 id |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Get or set the id of the post. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has id => ( is => "rw", isa => "Int" ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 title |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Get or set the title of the post. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has title => ( is => "rw", isa => "Str" ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 body |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Get or set the body of the post. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has body => ( is => "rw", isa => "Str" ); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 tags [tag[s]] |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Get or set the tags for a post as an array of tags. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub tags{ |
|
76
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
77
|
0
|
0
|
|
|
|
|
$self->tag(join(",", @_)) if @_; |
|
78
|
0
|
|
0
|
|
|
|
return split /\s*,\s*/, $self->tag || ""; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 tag [tag list] |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Get or set the tags for a post as an string of comma separated tags. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has tag => ( is =>"rw", isa => "Str" ); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 datetime |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Get or set the date of this post as a C object. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub datetime { |
|
96
|
0
|
|
|
0
|
1
|
|
shift->_handle_datetime(@_); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 date |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Get or set the date of this post as an RFC822 encoded date string. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
has date => ( is => "rw", isa => "Str" ); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 site_id |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Get the site id of this Post |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
has site_id => ( is => "rw", isa => "Int" ); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 media |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Get or set a list of C objects for this post. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
sub media { |
|
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
122
|
0
|
0
|
|
|
|
|
if (@_) { |
|
123
|
0
|
0
|
|
|
|
|
my @tmp = (blessed $_[0]) ? map { $_->_to_params } @_ : @_; |
|
|
0
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
$self->_media(\@tmp); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
0
|
0
|
|
|
|
|
return map { Net::Posterous::Media->new(%$_) } @{$self->_media || []}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
has _media => ( is => "rw", isa => "ArrayRef" ); |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 comments |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Get or set a list of C objects for this post. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
|
135
|
|
|
|
|
|
|
sub comments { |
|
136
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
137
|
0
|
0
|
|
|
|
|
if (@_) { |
|
138
|
0
|
0
|
|
|
|
|
my @tmp = (blessed $_[0]) ? map { $_->_to_params } @_ : @_; |
|
|
0
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->_comments(\@tmp); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
0
|
0
|
|
|
|
|
return map { Net::Posterous::Comment->new(%$_) } @{$self->_comments || []}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
has _comments => ( is => "rw", isa => "ArrayRef" ); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 autopost |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Get or set whether to autopost. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
has autopost => ( is => "rw", isa => "Bool" ); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 private |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get or set whether this is private. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
has private => ( is => "rw", isa => "Bool" ); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 source |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get or set what the source app for this post is. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# TODO should this be Net::Posterous- by default? |
|
170
|
|
|
|
|
|
|
has source => (is => "rw", isa => "Str" ); |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 source_link |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 sourceLink |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Get or set what the link to the source app for this post is. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
C is an alias due to Posterous having interestingly inconsistent naming schema. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
0
|
1
|
|
sub source_link { shift->sourceLink(@_) } |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
has sourceLink => (is => "rw", isa => "Str" ); |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 comments_enabled |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 commentsenabled. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Get or set whether comments are enabled for this post. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
C is an alias due to Posterous having interestingly inconsistent naming schema. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
|
|
0
|
1
|
|
sub comments_enabled { shift->commentsenabled(@_) } |
|
197
|
|
|
|
|
|
|
has commentsenabled => ( is => "rw", isa => "Bool" ); |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 url |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Get or set the http://post.ly url for this post. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
has url => ( is => "rw", isa => "Str" ); |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 short_code |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Get or set the short code for this post. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
|
213
|
|
|
|
|
|
|
sub short_code { |
|
214
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
215
|
0
|
0
|
|
|
|
|
if (@_) { |
|
216
|
0
|
|
|
|
|
|
my $id = shift; |
|
217
|
0
|
|
|
|
|
|
$id =~ s!^http://post\.ly/!!; |
|
218
|
0
|
|
|
|
|
|
$self->url("http://post.ly/$id"); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
0
|
|
|
|
|
|
my $id = $self->url; |
|
221
|
0
|
|
|
|
|
|
$id =~ s!^http://post\.ly/!!; |
|
222
|
0
|
|
|
|
|
|
return $id; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 longurl |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Get or set the long url for this Post. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
has longurl => ( is => "rw", isa => "Str" ); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 link |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Get or set the link for this Post. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |
|
240
|
|
|
|
|
|
|
# TODO is this the same as longurl |
|
241
|
|
|
|
|
|
|
has link => ( is => "rw", isa => "Str" ); |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 views |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Get or set the number of views for this Post. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
has views => ( is => "rw", isa => "Int" ); |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 author |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Get or set the author for this Post. |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
has author => ( is => "rw", isa => "Str" ); |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 author_pic |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Get or set the author picture for this Post. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
C is an alias due to Posterous having interestingly inconsistent naming schema. |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
|
|
0
|
1
|
|
sub author_pic { shift->authorpic(@_) } |
|
268
|
|
|
|
|
|
|
has authorpic => ( is => "rw", isa => "Str" ); |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head2 comments_count |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Get or set the count of the number of comments for this post. |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
C is an alias due to Posterous having interestingly inconsistent naming schema. |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
|
277
|
0
|
|
|
0
|
1
|
|
sub comments_count { shift->commentscount(@_) } |
|
278
|
|
|
|
|
|
|
has commentscount => ( is => "rw", isa => "Int" ); |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub _to_params { |
|
281
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
282
|
0
|
0
|
|
|
|
|
my @keys = $self->id ? qw(id title body) |
|
283
|
|
|
|
|
|
|
: qw(site_id title body autopost private date tags source sourceLink); |
|
284
|
|
|
|
|
|
|
# Pass different params depending on whether we're creating or updating ... why Posterous WHY? |
|
285
|
0
|
|
|
|
|
|
my %params = (); |
|
286
|
0
|
|
|
|
|
|
foreach my $key (@keys) { |
|
287
|
0
|
|
0
|
|
|
|
my $val = $self->$key || next; |
|
288
|
0
|
|
|
|
|
|
$params{$key} = $val; |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# Find local media to get ready to upload |
|
292
|
0
|
|
|
|
|
|
my @media = grep { $_->isa('Net::Posterous::Media::Local') } $self->media; |
|
|
0
|
|
|
|
|
|
|
|
293
|
0
|
0
|
|
|
|
|
$params{@media>1 ? 'media[]' : 'media'} = [ map { [ $_->file ] } @media ]; |
|
|
0
|
|
|
|
|
|
|
|
294
|
0
|
|
|
|
|
|
return %params; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
1; |