Plagger/Plugin/Widget/Delicious.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 45 CC 3 SCAR 16.1
CC
3
Cov
0%
html
12.0
register
2.0
add
2.0
CRAP 5.0
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 'publish.entry.fixup' => \&add,
14 );
15 }
16  
17 sub add {
18 my($self, $context, $args) = @_;
19 $args->{entry}->add_widget($self);
20 }
21  
22 sub html {
23 my($self, $entry) = @_;
24 my $uri = URI->new('http://del.icio.us/post');
25  
26 my %query;
27 $query{url} = $entry->permalink;
28 $query{title} = encode('utf-8', $entry->title);
29 $query{tags} = $self->conf->{tags} if $self->conf->{tags};
30 $query{jump} = 'doclose' if $self->conf->{one_click_post};
31  
32 $uri->query_form(%query, v => 4);
33  
34 my $url = HTML::Entities::encode($uri->as_string);
35 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>);
36 }
37  
38 1;
39  
40 __END__