Changeset 966
- Timestamp:
- 08/19/08 14:27:23 (3 months ago)
- Files:
-
- trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Account.pm (modified) (2 diffs)
- trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/App/CMS.pm (modified) (2 diffs)
- trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/MovableType.pm (modified) (1 diff)
- trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/TypePad.pm (modified) (1 diff)
- trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/Vox.pm (modified) (1 diff)
- trunk/CrossPoster/plugins/CrossPoster/tmpl/list_account.tmpl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Account.pm
r964 r966 31 31 32 32 sub class_label { 33 return MT->translate(" CrosspostingAccount");33 return MT->translate("Account"); 34 34 } 35 35 36 36 sub class_label_plural { 37 return MT->translate(" CrosspostingAccounts");37 return MT->translate("Accounts"); 38 38 } 39 39 … … 45 45 } 46 46 47 sub save { 48 my $account = shift; 49 50 ## Getting the PostURI could be an expensive procedure so 51 # get it every time an account is saved and store it w/acct 52 my $connector_class = $account->connector->{class}; 53 eval "require $connector_class;"; 54 Carp::croak($@) if $@; 55 56 my $post_uri = $connector_class->post_uri($account); 57 $account->post_uri($post_uri); 58 59 unless ($account->SUPER::save(@_)) { 60 print STDERR "error during save: " . $account->errstr . "\n"; 61 die $account->errstr; 62 } 63 64 1; 65 } 66 47 67 1; trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/App/CMS.pm
r965 r966 42 42 43 43 my $hasher = sub { 44 my ($ obj, $row) = @_;45 46 my $connector = $ obj->connector;44 my ($account, $row) = @_; 45 46 my $connector = $account->connector; 47 47 next if !$connector; 48 48 … … 210 210 } 211 211 212 # Getting the PostURI could be an expensive procedure so213 # get it every time an account is saved and save it214 215 sub post_save_account {216 my ($cb, $account) = @_;217 my $app = MT->instance;218 my $plugin = MT->component('CrossPoster');219 220 my $connector_class = $account->connector->{class};221 eval "require $connector_class;";222 return _show_error($plugin, $app, $@, 0)223 if $@;224 225 my $post_uri = $connector_class->post_uri($app, $account);226 $account->post_uri($post_uri);227 $account->save or die $account->errstr;228 }229 230 212 sub CMSPostSave_entry { 231 213 my ($cb, $app, $entry) = @_; trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/MovableType.pm
r938 r966 19 19 sub post_uri { 20 20 my $self = shift; 21 my ($a pp, $account) = @_;21 my ($account) = @_; 22 22 23 23 my $url = $account->url; trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/TypePad.pm
r938 r966 21 21 sub post_uri { 22 22 my $self = shift; 23 my ($a pp, $account) = @_;23 my ($account) = @_; 24 24 25 25 my $blog_name = $account->url; trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/Vox.pm
r938 r966 7 7 use constant NS_DC => 'http://purl.org/dc/elements/1.1/'; 8 8 9 use constant ENDPOINT => 'http://www.vox.com/services/atom';10 11 9 sub edit_uri { return ''; } # Vox doesn't support editing entries via Atom API yet 12 10 13 11 sub post_uri { 14 12 my $self = shift; 15 my ($a pp, $account) = @_;13 my ($account) = @_; 16 14 17 require XML::Atom::Client; 18 19 my $api = XML::Atom::Client->new; 20 $api->username($account->username); 21 $api->password($account->passwd); 22 23 my $services = $api->getFeed(ENDPOINT); 24 25 my @links = $services->link; 26 for my $link (@links) { 27 if ( $link->rel eq 'service.post' ) { 28 return $link->href; 29 } 15 require XML::Atom::Feed; 16 my $feed = XML::Atom::Feed->new( URI->new($account->url) ); 17 18 if($feed) { 19 my @links = $feed->link; 20 for my $link (@links) { 21 if ( $link->rel eq 'service.post' ) { 22 return $link->href; 23 } 24 } 30 25 } 31 26 32 return undef;27 die MT->translate("Could not find PostURI from %s", $account->url); 33 28 } 34 29 trunk/CrossPoster/plugins/CrossPoster/tmpl/list_account.tmpl
r965 r966 78 78 </mt:setvarblock> 79 79 <mt:setvarblock name="action_buttons"> 80 <input type="button" onclick="doRemoveItems(this.form, '<__trans phrase="account">', '<__trans phrase="accounts">')" name="delete_accounts" value="<__trans phrase="Delete">" accesskey="x" title="<__trans phrase="Delete selected accounts (x)">" /> 80 <a href="javascript:void(0)" 81 onclick="doRemoveItems(getByID('<$mt:var name="object_type"$>-listing-form'), '<mt:var name="object_label" lower_case="1" escape="js">', '<mt:var name="object_label_plural" lower_case="1" escape="js">'); return false;" 82 accesskey="x" 83 title="<__trans phrase="Delete selected accounts (x)">" 84 ><__trans phrase="Delete"></a> 81 85 </mt:setvarblock> 82 86 <mt:setvarblock name="content_nav"> … … 84 88 </mt:setvarblock> 85 89 <mt:setvarblock name="content_header"> 86 <p id="create-new-link"><a href="#" onclick="return openDialog(this.form, 'edit_crossposting_account', 'blog_id=<mt:var name="blog_id">')" class="icon-left icon-create"><__trans phrase="New CrosspostingAccount"></a></p>90 <p id="create-new-link"><a href="#" onclick="return openDialog(this.form, 'edit_crossposting_account', 'blog_id=<mt:var name="blog_id">')" class="icon-left icon-create"><__trans phrase="New Account"></a></p> 87 91 </mt:setvarblock> 88 92 <mt:include name="include/header.tmpl"> … … 91 95 <mtapp:listing 92 96 hide_pager="1" 93 empty_message="<__trans phrase="No crosspostingaccounts could be found.">">97 empty_message="<__trans phrase="No accounts could be found.">"> 94 98 <mt:if __first__> 95 99 <thead> … … 114 118 </td> 115 119 <td> 116 <mt:if name="connector_username _required"><mt:var name="username"><br /></mt:if>117 <mt:if name="connector_password _required"><a href="#" onclick="revealPassword('<mt:var name="passwd">')"><__trans phrase="Reveal Password"></a></mt:if>120 <mt:if name="connector_username"><mt:var name="username"><br /></mt:if> 121 <mt:if name="connector_password"><a href="#" onclick="revealPassword('<mt:var name="passwd">')"><__trans phrase="Reveal Password"></a></mt:if> 118 122 </td> 119 123 <!-- <td class="si <mt:if name="excerpt_only">status-linked<mt:else>status-unlinked</mt:if>"><img src="<mt:var name="static_uri">images/spacer.gif" alt="<mt:if name="excerpt_only"><__trans phrase="Excerpt Only"><mt:else><__trans phrase="Full Post"></mt:if>" width="9" height="9" /></td> -->
