Plagger::Plugin::Publish::Deliciousä½ã£ã¦ã¿ã
lib/Plagger/Plugin/Publish/Delicious.pm
package Plagger::Plugin::Publish::Delicious; use strict; use base qw( Plagger::Plugin ); use Net::Delicious; use Encode; use URI::Escape qw(uri_escape uri_escape_utf8); our $VERSION = '0.01'; sub register { my($self, $context) = @_; $context->register_hook( $self, 'publish.entry.fixup' => \&add_entry, ); $self->initialize(); } sub initialize { my ($self) = @_; $self->{delicious} = Net::Delicious->new({ user => $self->conf->{username}, pswd => $self->conf->{password}, }); } sub add_entry { my ($self, $context, $args) = @_; my $cnv_ch = sub { my $string = shift; my $dst_charset = "UTF-8"; unless ( $self->conf->{src_charset} eq "UTF-8" ) { Encode::from_to( $string, $self->conf->{src_charset}, $dst_charset ); } return $string; }; my $tags = $args->{entry}->tags; if (scalar(@$tags)) { $tags = uri_escape_utf8( &$cnv_ch( my $tag_string = join ' ', @$tags)); } else { $tags = ""; } $self->{delicious}->add_post({ url => uri_escape( $args->{entry}->link ), description => uri_escape_utf8( &$cnv_ch($args->{entry}->title) ), extended => uri_escape_utf8( &$cnv_ch($args->{entry}->body) ), tags => $tags, }); sleep( $context->conf->{interval} || 2 ); } 1;
config.yaml
plugins: - module: Publish::Delicious config: username: your-username password: your-password src_charset: "UTF-8" interval: 2
src-feedã¨ãã¦b.hatenaã¨ãd.hatenaã®feedæå®ããã¨ä¾ã®è¤æ°dc:subjectåé¡ã§ã¿ã°ããã¾ãä»ãã¦ããã¾ããããã®ãããªå ´åã¯@{$args->{entry}->tags->[0]}ã§åãããã§ããupdate.entry.fixupãã§ã¼ãºã§é©å½ã«å¦çããã°ãããã¨æããã¾ãã