| 1 | { | ||||||||||
| 2 | |||||||||||
| 3 | 1 | =head1 NAME | |||||||||
| 4 | |||||||||||
| 5 | Net::Blogger::Engine::Userland - base class for UserLand Blogger API engines | ||||||||||
| 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 inherits I<Net::Blogger::Engine::Base> and implements shared methods | ||||||||||
| 14 | for the UserLand Manila and RadioUserland XML-RPC servers. | ||||||||||
| 15 | |||||||||||
| 16 | This package should not be called directly. It is a base class used by | ||||||||||
| 17 | I<Net::Blogger::Engine::Manila> and I<Net::Blogger::Engine::Radio> | ||||||||||
| 18 | |||||||||||
| 19 | =cut | ||||||||||
| 20 | |||||||||||
| 21 | package Net::Blogger::Engine::Userland; | ||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 1 | $Net::Blogger::Engine::Userland::VERSION = '1.0'; | |||||||||
| 25 | 1 | @Net::Blogger::Engine::Userland::ISA = qw ( Exporter Net::Blogger::Engine::Base ); | |||||||||
| 26 | 1 | @Net::Blogger::Engine::Userland::EXPORT = qw (); | |||||||||
| 27 | 1 | @Net::Blogger::Engine::Userland::EXPORT_OK = qw (); | |||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | use Net::Blogger::Engine::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | =head1 OBJECT METHODS | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | =pod | ||||||||||
| 39 | |||||||||||
| 40 | =head2 $pkg->init(\%args) | ||||||||||
| 41 | |||||||||||
| 42 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||
| 43 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | sub init { | ||||||||||
| 48 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 49 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : {@_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | my $child = caller(); | |||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | if (! $child =~ /^(Net::Blogger::Engine::(Manila|Radio))$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | return 0; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | if (exists $args->{'proxy'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 0 | $self->Proxy($args->{'proxy'}); | |||||||||
| 59 | 0 | delete $args->{'proxy'}; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 0 | return $self->SUPER::init($args); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | =head2 $pkg->Proxy($uri) | ||||||||||
| 66 | |||||||||||
| 67 | Get/set the URI of the Manila->Blogger proxy. | ||||||||||
| 68 | |||||||||||
| 69 | If no proxy is explicitly defined then the method determines the hostname | ||||||||||
| 70 | for the Manila server using the current blogid. | ||||||||||
| 71 | |||||||||||
| 72 | "Just to clarify, the URI is /RPC2, even if your blogid (homepage url) is | ||||||||||
| 73 | a sub-site url, like http://www.myserver.com/mysite/. It's never something | ||||||||||
| 74 | like /mysite/RPC2." | ||||||||||
| 75 | |||||||||||
| 76 | --Jake Savin (Userland) | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | sub Proxy { | ||||||||||
| 81 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
Proxy: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 82 | 0 | my $proxy = shift; | |||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | if ($proxy) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | $self->{"_proxy"} = $proxy; | |||||||||
| 86 | 0 | return $self->{"_proxy"}; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | if ($self->{"_proxy"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | return $self->{"_proxy"}; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | if (my $blog = $self->BlogId()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | my $uri = URI->new($blog); | |||||||||
| 95 | 0 | $self->{"_proxy"} = $uri->scheme()."://".$uri->host()."/RPC2"; | |||||||||
| 96 | |||||||||||
| 97 | 0 | $self->{"_client"} = undef; | |||||||||
| 98 | 0 | return $self->{"_proxy"}; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | 0 | $self->LastError("Unable to determine proxy explicitly or by parsing blogid."); | |||||||||
| 102 | 0 | return undef; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | =head2 $pkg->AppKey() | ||||||||||
| 106 | |||||||||||
| 107 | Returns true. Manila does not require a Blogger API key, but specifies | ||||||||||
| 108 | something (anything) all the same. | ||||||||||
| 109 | |||||||||||
| 110 | =cut | ||||||||||
| 111 | |||||||||||
| 112 | sub AppKey { | ||||||||||
| 113 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
AppKey: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 114 | 0 | return 1; | |||||||||
| 115 | } | ||||||||||
| 116 | |||||||||||
| 117 | =head2 $pkg->BlogId() | ||||||||||
| 118 | |||||||||||
| 119 | Get/Set the current blog id. | ||||||||||
| 120 | |||||||||||
| 121 | Ensures that the blogid contains a trailing slash, without which the Frontier | ||||||||||
| 122 | engine freaks out. | ||||||||||
| 123 | |||||||||||
| 124 | =cut | ||||||||||
| 125 | |||||||||||
| 126 | sub BlogId { | ||||||||||
| 127 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BlogId: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 128 | 0 | my $id = shift; | |||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | if ($id) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 131 | 0 | ▶ | unless ($id =~ /^(.*)\/$/) { $id .= "/"; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 132 | 0 | $self->{'_blogid'} = $id; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | 0 | return $self->{'_blogid'}; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | =head2 $pkg->MaxPostLength() | ||||||||||
| 139 | |||||||||||
| 140 | By default, returns undef. In other words, there is no max post length for Manila. | ||||||||||
| 141 | |||||||||||
| 142 | "As far as I know there is no max length for a post, certainly nothing you have | ||||||||||
| 143 | to enforce on your end." | ||||||||||
| 144 | |||||||||||
| 145 | --Dave Winer (Userland) | ||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||
| 148 | |||||||||||
| 149 | sub MaxPostLength { | ||||||||||
| 150 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
MaxPostLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 151 | 0 | return undef; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | |||||||||||
| 155 | =head1 metaWeblog API METHODS | ||||||||||
| 156 | |||||||||||
| 157 | =cut | ||||||||||
| 158 | |||||||||||
| 159 | =head2 $pkg->metaWeblog() | ||||||||||
| 160 | |||||||||||
| 161 | Returns an object. Woot! | ||||||||||
| 162 | |||||||||||
| 163 | =cut | ||||||||||
| 164 | |||||||||||
| 165 | sub metaWeblog { | ||||||||||
| 166 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
metaWeblog: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 167 | |||||||||||
| 168 | 0 | ▶ | if (! $self->{__meta}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 169 | |||||||||||
| 170 | 0 | require Net::Blogger::Engine::Userland::metaWeblog; | |||||||||
| 171 | 0 | my $meta = Net::Blogger::Engine::Userland::metaWeblog->new(debug=>$self->{debug}); | |||||||||
| 172 | |||||||||||
| 173 | 0 | map { $meta->$_($self->$_()); } qw (BlogId Proxy Username Password ); | |||||||||
| 174 | 0 | $self->{__meta} = $meta; | |||||||||
| 175 | } | ||||||||||
| 176 | |||||||||||
| 177 | 0 | return $self->{__meta}; | |||||||||
| 178 | } | ||||||||||
| 179 | |||||||||||
| 180 | 1 | return 1; | |||||||||
| 181 | |||||||||||
| 182 | =head1 VERSION | ||||||||||
| 183 | |||||||||||
| 184 | 1.0 | ||||||||||
| 185 | |||||||||||
| 186 | =head1 DATE | ||||||||||
| 187 | |||||||||||
| 188 | $Date: 2005/03/26 19:29:08 $ | ||||||||||
| 189 | |||||||||||
| 190 | =head1 AUTHOR | ||||||||||
| 191 | |||||||||||
| 192 | Aaron Straup Cope | ||||||||||
| 193 | |||||||||||
| 194 | =head1 SEE ALSO | ||||||||||
| 195 | |||||||||||
| 196 | L<Net::Blogger> | ||||||||||
| 197 | |||||||||||
| 198 | http://frontier.userland.com/emulatingBloggerInManila | ||||||||||
| 199 | |||||||||||
| 200 | =head1 LICENSE | ||||||||||
| 201 | |||||||||||
| 202 | Copyright (c) 2001-2005 Aaron Straup Cope. | ||||||||||
| 203 | |||||||||||
| 204 | This is free software, you may use it and distribute it under the | ||||||||||
| 205 | same terms as Perl itself. | ||||||||||
| 206 | |||||||||||
| 207 | =cut | ||||||||||
| 208 | |||||||||||
| 209 | } | ||||||||||