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

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

Hooks adds / renames

  • entry.fixup -> publish.entry.fixup
  • Added update.entry.fixup and update.feed.fixup

Fixed UserAgent? timeout problem ad-hoc

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::Widget::HatenaBookmark;
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://b.hatena.ne.jp/append');
25     $uri->query($entry->permalink);
26
27     my $url = HTML::Entities::encode($uri->as_string);
28     return qq(<a href="$url"><img src="http://b.hatena.ne.jp/images/append.gif" alt="Post to Hatena Bookmark" style="border:0;vertical-align:middle" /></a>);
29 }
30
31 1;
Note: See TracBrowser for help on using the browser.