root/trunk/plagger/lib/Plagger/Plugin/Widget/Delicious.pm

Revision 11 (checked in by miyagawa, 15 years ago)

use image for del.icio.us link

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::Widget::Delicious;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Encode;
6 use HTML::Entities;
7 use URI;
8
9 sub register {
10     my($self, $context) = @_;
11     $context->register_hook(
12         $self,
13         'filter.content' => \&add,
14     );
15 }
16
17 sub add {
18     my($self, $context, $entry, $content) = @_;
19     $entry->add_widget($self);
20 }
21
22 sub html {
23     my($self, $entry) = @_;
24     my $uri = URI->new('http://del.icio.us/' . $self->conf->{username});
25     $uri->query_form(
26         v => 3,
27         url => $entry->link,
28         title => encode('utf-8', $entry->title),
29     );
30
31     my $url = HTML::Entities::encode($uri->as_string);
32     return qq(<a href="$url"><img src="http://del.icio.us/static/img/delicious.small.gif" alt="del.icio.us it!" style="border:0;vertical-align:middle" /></a>);
33 }
34
35 1;
Note: See TracBrowser for help on using the browser.