Changeset 198

Show
Ignore:
Timestamp:
02/28/06 13:43:43
Author:
miyagawa
Message:

Publish::Delicious: use utf-8 bytes rather than URI escape. Added post_body option which defaults to 0. Use $entry->body_text to use for extended field. Added more doc.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Delicious.pm

    r186 r198  
    33use base qw( Plagger::Plugin ); 
    44 
     5use Encode; 
    56use Net::Delicious; 
    6 use URI::Escape qw(uri_escape uri_escape_utf8); 
    77 
    88sub register { 
     
    2424 
    2525sub add_entry { 
    26     my ($self, $context, $args) = @_; 
     26    my($self, $context, $args) = @_; 
    2727 
    2828    my @tags = @{$args->{entry}->tags}; 
    2929    my $tag_string; 
    3030    if (scalar(@tags)) { 
    31         $tag_string = uri_escape_utf8( join ' ', @tags )
     31        $tag_string = join ' ', @tags
    3232    } else { 
    3333        $tag_string = ""; 
    3434    } 
    3535 
    36     $self->{delicious}->add_post({ 
    37         url         => uri_escape( $args->{entry}->link ), 
    38         description => uri_escape_utf8( $args->{entry}->title ), 
    39         extended    => uri_escape_utf8( $args->{entry}->body ), 
    40         tags        => $tag_string, 
    41     }); 
     36    my $params = { 
     37        url         => $args->{entry}->link, 
     38        description => encode('utf-8', $args->{entry}->title), 
     39        tags        => encode('utf-8', $tag_string), 
     40    }; 
    4241 
    43     my $sleeping_time = $context->conf->{interval} || 4; 
     42    if ($self->conf->{post_body}) { 
     43        $params->{extended} = encode('utf-8', $args->{entry}->body_text), 
     44    } 
     45 
     46    $self->{delicious}->add_post($params); 
     47 
     48    my $sleeping_time = $context->conf->{interval} || 3; 
    4449    $context->log(info => "Post entry success. sleep $sleeping_time."); 
    4550    sleep( $sleeping_time ); 
     
    6166      password: your-password 
    6267      interval: 2 
     68      post_body: 1 
    6369 
    6470=head1 DESCRIPTION 
    6571 
    6672This plugin posts feed updates to del.icio.us, using its REST API. 
     73 
     74=head1 CONFIGURATION 
     75 
     76=over 4 
     77 
     78=item username, password 
     79 
     80Your login and password for logging in del.icio.us. 
     81 
     82=item interval 
     83 
     84Interval (as seconds) to sleep after posting each bookmark. Defaults to 3. 
     85 
     86=item post_body 
     87 
     88A flag to post entry's body as extended field for del.icio.us. Defaults to 0. 
     89 
     90=cut 
    6791 
    6892=head1 AUTHOR