« blib/lib/Net/Blogger/Engine/Userland/metaWeblog.pm
↑ Summary
blib/lib/Net/Blogger/Engine/Movabletype/mt.pm »
| 1 | { | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | =head1 NAME | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Net::Blogger::API::Extended - provides helper methods not defined in the Blogger API. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | It's very dark in here because this is a black box. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | This package is inherited by I<Net::Blogger::Engine::Base> and provides helper | ||||||||||||||||||||||||||||
| 14 | methods not defined in the Blogger API. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | package Net::Blogger::API::Extended; | ||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | $Net::Blogger::API::Extended::VERSION = '1.0'; | |||||||||||||||||||||||||||
| 22 | 1 | @Net::Blogger::API::Extended::ISA = qw ( Exporter ); | |||||||||||||||||||||||||||
| 23 | 1 | @Net::Blogger::API::Extended::EXPORT = qw (); | |||||||||||||||||||||||||||
| 24 | 1 | @Net::Blogger::API::Extended::EXPORT_OK = qw (); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use FileHandle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 OBJECT METHODS | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 $pkg->MaxPostLength | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | Abstract method for returning the max post length | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub MaxPostLength { | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return undef; | ||||||||||||||||||||||||||
|
Subroutine
MaxPostLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head2 $pkg->GetBlogId(\%args) | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Return the unique blogid for I<$args{'blogname'}>. | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | Valid arguments are | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =over | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =item * | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | B<blogname> => string. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =back | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 56 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Returns a string. If no blogname is specified, the current blogid for | ||||||||||||||||||||||||||||
| 59 | the object is returned. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub GetBlogId { | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
GetBlogId: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | my $blogid = undef; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (! $args->{'blogname'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | return $self->{'_blogid'}; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $blogs = $self->getUsersBlogs() | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->getUsersBlogs || (return undef)
MC/DC0%0/1
$self->getUsersBlogs || (return undef)
$self->getUsersBlogs
Truth table0%0/2
A
A= $self->getUsersBlogs
| |||||||||||||||||||||||||||||
| 74 | || return undef; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | foreach my $b (@$blogs) { | |||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($b->{'blogName'} eq $args->{'blogname'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | $blogid = $b->{'blogid'}; | |||||||||||||||||||||||||||
| 79 | 0 | last; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | return $blogid; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 $pkg->DeleteAllPosts(\%args) | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Delete all the posts on a weblog. Valid arguments are : | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =over 4 | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item * | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | B<publish> | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Boolean. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =back | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 101 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | Returns true or false. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | sub DeleteAllPosts { | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
DeleteAllPosts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 0 | my $args = { @_ }; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my ($ok,@pids) = $self->getRecentPosts(numposts=>20); | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | while (@pids) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | foreach my $p (@pids) { | |||||||||||||||||||||||||||
| 115 | 0 | $self->deletePost(postid=>$p->{'postid'},publish=>$args->{'publish'}); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ($ok,@pids) = $self->getRecentPosts(numposts=>20); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | return $ok; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head2 $pkg->PostFromFile(\%args) | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | Open a filehandle, and while true, post to Blogger. If the length of the amount | ||||||||||||||||||||||||||||
| 127 | read from the file exceeds the per-post limit assigned by the Blogger servers -- | ||||||||||||||||||||||||||||
| 128 | currently 65,536 characters -- the contents of the file will be posted in multiple | ||||||||||||||||||||||||||||
| 129 | "chunks". | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | Valid arguments are | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =over | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =item * | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | B<file> | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | /path/to/file I<required> | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item * | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | B<postid> | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | String. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =item * | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | B<publish> | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | Boolean. | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =item * | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | B<tail> | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | Boolean. | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | If true, the method will not attempt to post data whose length exceeds the limit | ||||||||||||||||||||||||||||
| 160 | set by the Blogger server in the order that the data is read. Translation : last | ||||||||||||||||||||||||||||
| 161 | in becomes last post becomes the first thing you see on your weblog. | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =back | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | If a I<postid> argument is present, the method will call the Blogger API I<editPost> | ||||||||||||||||||||||||||||
| 166 | method with postid. Otherwise the method will call the Blogger API I<newPost> method. | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 169 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | Returns true or false, followed by an array of zero, or more, postids. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub PostFromFile { | ||||||||||||||||||||||||||||
| 176 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
PostFromFile: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (! -f $args->{'file'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | $self->LastError("Not a file."); | |||||||||||||||||||||||||||
| 181 | 0 | return 0; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | my $fh = FileHandle->new(); | |||||||||||||||||||||||||||
| 185 | 0 | my $ok = $fh->open("<$args->{'file'}"); | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if (! $ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | $self->LastError("Failed to open file : $!"); | |||||||||||||||||||||||||||
| 189 | 0 | return 0; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $method = ($args->{'postid'}) ? "editPost" : "newPost"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if (! $args->{'tail'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | local $/; | |||||||||||||||||||||||||||
| 197 | 0 | undef $/; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | my $postbody = <$fh>; | |||||||||||||||||||||||||||
| 200 | 0 | $fh->close(); | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | return $self->$method(postbody=>\$postbody,%$args); | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | my $post = ""; | |||||||||||||||||||||||||||
| 206 | 0 | my @postids = (); | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | my $line = $_; | |||||||||||||||||||||||||||
| 210 | 0 | chomp $line; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | $post .= $line; | |||||||||||||||||||||||||||
| 213 | 0 | my $len = length($post); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if (($self->MaxPostLength()) && ($len > $self->MaxPostLegth())) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->MaxPostLength and $len > $self->MaxPostLegth
MC/DC0%0/2
$self->MaxPostLength and $len > $self->MaxPostLegth
$self->MaxPostLength
$len > $self->MaxPostLegth
Truth table0%0/3
A and B
A= $self->MaxPostLengthB= $len > $self->MaxPostLegth
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | my $postbody = substr($post,0,$self->MaxPostLength()); | |||||||||||||||||||||||||||
| 218 | 0 | my $remainder = $self->_TrimPostBody(\$postbody); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | my ($pid) = $self->$method( | ||||||||||||||||||||||||||||
| 221 | postbody => \$postbody, | ||||||||||||||||||||||||||||
| 222 | postid => $args->{'postid'}, | ||||||||||||||||||||||||||||
| 223 | 0 | publish => $args->{'publish'}, | |||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if (! $pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | $fh->close(); | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | $self->LastError("Encountered an error posting. Exiting prematurely."); | |||||||||||||||||||||||||||
| 230 | 0 | return (0,@postids); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | push(@postids,$pid); | |||||||||||||||||||||||||||
| 234 | 0 | $post = $remainder.substr($post,$self->MaxPostLength(),$len); | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | $fh->close(); | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if (! $post) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | $self->LastError("Failed to read any data from file."); | |||||||||||||||||||||||||||
| 242 | 0 | return 0; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | my ($pid) = $self->$method( | ||||||||||||||||||||||||||||
| 246 | postbody => \$post, | ||||||||||||||||||||||||||||
| 247 | postid => $args->{'postid'}, | ||||||||||||||||||||||||||||
| 248 | 0 | publish => $args->{'publish'}, | |||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if (! $pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | 0 | $self->LastError("Encountered an error posting last chunk : ".Error->prior()); | |||||||||||||||||||||||||||
| 253 | 0 | return (0, @postids); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | push (@postids,$pid); | |||||||||||||||||||||||||||
| 257 | 0 | return (1,@postids); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | =head2 $pkg->PostFromOutline(\%args) | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | Like I<PostFromFile>, only this time the file is an outliner document. | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | This method uses Simon Kittle's Text::Outline::asRenderedHTML method for | ||||||||||||||||||||||||||||
| 265 | posting. As of this writing, the Text::Outline package has not been uploaded | ||||||||||||||||||||||||||||
| 266 | to the CPAN. See below for a link to the homepage/source. | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | Valid outline formats are OPML, tabbed text outline, Emacs' outline-mode format, | ||||||||||||||||||||||||||||
| 269 | and the GNOME Think format. | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | Valid arguments are | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =over | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =item * | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | B<file> | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | /path/to/file I<required> | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =item * | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | B<postid> | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | String. | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | =item * | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | B<publish> | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | Boolean. | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =back | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | If a I<postid> argument is present, the method will call the Blogger API I<editPost> | ||||||||||||||||||||||||||||
| 296 | method with postid. Otherwise the method will call the Blogger API I<newPost> method. | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 299 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | Returns true or false, followed by an array of zero, or more, postids. | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | =cut | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | sub PostFromOutline { | ||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
PostFromOutline: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | my $class = "Text::Outline"; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | # We'll get rid of this when, and if, a proper | ||||||||||||||||||||||||||||
| 312 | # Makefile is ever written... | ||||||||||||||||||||||||||||
| 313 | eval "require $class" | ||||||||||||||||||||||||||||
| 314 | 0 | ▶ | || &{ $self->LastError($@); return 0; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | my $outline = $class->new(load=>$args->{'file'}) | ||||||||||||||||||||||||||||
| 317 | 0 | ▶ | || &{ $self->LastError($!); return 0; }; | ||||||||||||||||||||||||||
|
Condition0%0/3
$class->new('load', $args->{'file'}) || &{$self->LastError($!);
return 0;}
MC/DC0%0/2
$class->new('load', $args->{'file'}) || &{$self->LastError($!);
return 0;}
$class->new('load', $args->{'file'})
&{$self->LastError($!);
return 0;}
Truth table0%0/3
A || B
A= $class->new('load', $args->{'file'})B= &{$self->LastError($!);
return 0;}
| |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | my $postbody = $outline->asRenderedHTML(); | |||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my $method = ($args->{'postid'}) ? "editPost" : "newPost"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | return $self->$method(postbody=>\$postbody,%$args); | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | sub _PostInChunks { | ||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_PostInChunks: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 328 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | my $caller = (caller(1))[3]; | |||||||||||||||||||||||||||
| 331 | 0 | my @chunks = (); | |||||||||||||||||||||||||||
| 332 | 0 | my @postids = (); | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | ▶ | unless ($caller =~ /^(Net::Blogger::Base::API::)(editPost|newPost)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | 0 | $self->LastError("$caller is not a valid caller for this method."); | |||||||||||||||||||||||||||
| 336 | 0 | return 0; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | my $text = $args->{"postbody"}; | |||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 0 | ▶ | while ( $$text ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | my $chunk = substr($$text,0,$self->MaxPostLength()); | |||||||||||||||||||||||||||
| 343 | 0 | my $remainder = $self->_TrimPostBody(\$chunk); | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | $$text = $remainder.substr($$text,length($chunk),length($$text)); | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | # Since Blogger posts are chronological, we add chunks | ||||||||||||||||||||||||||||
| 348 | # to the top of the stack. That way, the 'end' pieces get | ||||||||||||||||||||||||||||
| 349 | # added first and, in the end, the text will be displayed | ||||||||||||||||||||||||||||
| 350 | # in the order it was written. | ||||||||||||||||||||||||||||
| 351 | # 20010813 (asc) | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | unshift (@chunks, \$chunk); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | map { | ||||||||||||||||||||||||||||
| 357 | 0 | $args->{"postbody"} = $_; | |||||||||||||||||||||||||||
| 358 | 0 | push(@postids, $self->$caller(%$args)); | |||||||||||||||||||||||||||
| 359 | } @chunks; | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | return @postids; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | sub _TrimPostBody { | ||||||||||||||||||||||||||||
| 365 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_TrimPostBody: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 366 | 0 | my $body = shift; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if (ref($body) ne "SCALAR") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | $self->LastError("Input must be a scalar ref."); | |||||||||||||||||||||||||||
| 370 | 0 | return undef; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =head1 VERSION | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 1.0 | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =head1 DATE | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | $Date: 2005/03/26 19:29:08 $ | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Aaron Straup Cope | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | L<Net::Blogger::Engine::Base> | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | L<Net::Blogger::API::Core> | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | Copyright (c) 2001-2005 Aaron Straup Cope. | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | This is free software, you may use it and distribute it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =cut | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 1 | return 1; | |||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||