« Movable Typeのサンプルコードが万物の謎を解く | Home | Widget-Simpleでtumblr.yaml »

April 5, 2007

Plagger::Plugin::Widget::Tumblr

とりあえず作ってみました。
javascriptを起動するリンクが含まれているとGmailでリンクが削除されてしまうようなので、とりあえずjavascript無しです。
結果として、現状は範囲選択などは無視した動作となります。

package Plagger::Plugin::Widget::Tumblr;
use strict;
use base qw( Plagger::Plugin );
 
use HTML::Entities;
use URI;
use Encode;
 
sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'publish.entry.fixup' => \&add,
    );
}
 
sub add {
    my($self, $context, $args) = @_;
    $args->{entry}->add_widget($self);
}
 
sub html {
    my($self, $entry) = @_;
    my $uri = URI->new('http://www.tumblr.net/share');
 
    $uri->query_form({
        v => '2',
        u => $entry->permalink,
        t => Encode::encode('utf-8', $entry->title),
    });
    my $url = HTML::Entities::encode($uri->as_string);
    return qq(<a href="$url">Tumblr</a>);
}
 
1;

No TrackBacks

TrackBack URL: http://aklaswad.com/cgi-bin/mt/mt-tb.cgi/95

Leave a comment

OpenID accepted here Learn more about OpenID

About this Entry

This page contains a single entry by aklaswad published on April 5, 2007 12:34 AM.

Movable Typeのサンプルコードが万物の謎を解く was the previous entry in this blog.

Widget-Simpleでtumblr.yaml is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.