Changeset 966

Show
Ignore:
Timestamp:
08/19/08 14:27:23 (3 months ago)
Author:
arvind
Message:

* Update account listing UI to be more tight and fit with 4.2
* Moved finding PostURI to CrossPoster::Account::save rather than a post_save callback
* Updated CrossPoster::Connector::Vox::post_uri to actually work!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Account.pm

    r964 r966  
    3131 
    3232sub class_label { 
    33     return MT->translate("Crossposting Account"); 
     33    return MT->translate("Account"); 
    3434} 
    3535 
    3636sub class_label_plural { 
    37     return MT->translate("Crossposting Accounts"); 
     37    return MT->translate("Accounts"); 
    3838} 
    3939 
     
    4545} 
    4646 
     47sub 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 
    47671; 
  • trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/App/CMS.pm

    r965 r966  
    4242     
    4343    my $hasher = sub { 
    44         my ($obj, $row) = @_; 
    45          
    46         my $connector = $obj->connector; 
     44        my ($account, $row) = @_; 
     45         
     46        my $connector = $account->connector; 
    4747        next if !$connector; 
    4848         
     
    210210} 
    211211 
    212 # Getting the PostURI could be an expensive procedure so 
    213 # get it every time an account is saved and save it 
    214  
    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  
    230212sub CMSPostSave_entry { 
    231213    my ($cb, $app, $entry) = @_; 
  • trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/MovableType.pm

    r938 r966  
    1919sub post_uri { 
    2020        my $self = shift; 
    21         my ($app, $account) = @_; 
     21        my ($account) = @_; 
    2222         
    2323        my $url = $account->url; 
  • trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/TypePad.pm

    r938 r966  
    2121sub post_uri { 
    2222        my $self = shift; 
    23         my ($app, $account) = @_; 
     23        my ($account) = @_; 
    2424         
    2525        my $blog_name = $account->url; 
  • trunk/CrossPoster/plugins/CrossPoster/lib/CrossPoster/Connector/Vox.pm

    r938 r966  
    77use constant NS_DC => 'http://purl.org/dc/elements/1.1/'; 
    88 
    9 use constant ENDPOINT => 'http://www.vox.com/services/atom'; 
    10  
    119sub edit_uri { return ''; } # Vox doesn't support editing entries via Atom API yet 
    1210 
    1311sub post_uri { 
    1412        my $self = shift; 
    15         my ($app, $account) = @_; 
     13        my ($account) = @_; 
    1614         
    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        }         
    3025    } 
    3126 
    32         return undef
     27        die MT->translate("Could not find PostURI from %s", $account->url)
    3328} 
    3429 
  • trunk/CrossPoster/plugins/CrossPoster/tmpl/list_account.tmpl

    r965 r966  
    7878</mt:setvarblock> 
    7979<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> 
    8185</mt:setvarblock> 
    8286<mt:setvarblock name="content_nav"> 
     
    8488</mt:setvarblock> 
    8589<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 Crossposting Account"></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> 
    8791</mt:setvarblock> 
    8892<mt:include name="include/header.tmpl"> 
     
    9195<mtapp:listing 
    9296        hide_pager="1" 
    93     empty_message="<__trans phrase="No crossposting accounts could be found.">"> 
     97    empty_message="<__trans phrase="No accounts could be found.">"> 
    9498    <mt:if __first__> 
    9599            <thead> 
     
    114118                                        </td> 
    115119                                        <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> 
    118122                                        </td> 
    119123                                        <!-- <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> -->