root/plagger/trunk/my-plugins/Filter-HatenaMobileGateway/HatenaMobileGateway.pm

Revision 1 (checked in by yohei, 2 years ago)

Add my Plagger plugins

Line 
1 package Plagger::Plugin::Filter::HatenaMobileGateway;
2 use warnings;
3 use strict;
4 use base qw( Plagger::Plugin );
5
6 use URI;
7
8 sub register {
9     my($self, $context) = @_;
10     $context->register_hook(
11         $self,
12         'update.entry.fixup' => \&filter,
13     );
14 }
15
16 sub filter {
17     my($self, $context, $args) = @_;
18     my $entry = $args->{entry};
19
20     my $u = URI->new("http://mgw.hatena.ne.jp/?" . $entry->link);
21     unless ($u) {
22         $context->log(warn => "Can't generate new URI");
23         return;
24     }
25
26     $entry->link($u);
27     $context->log(info => "Modification of link of Entry succeeded on $u");
28 }
29
30 1;
Note: See TracBrowser for help on using the browser.