root/trunk/plagger/lib/Plagger/Plugin/Namespace/HatenaFotolife.pm

Revision 1769 (checked in by miyagawa, 3 years ago)
  • Moved Photocast/MediaRSS/Hatena specific parsing methods to Namespace::* plugins. w00t!
  • Added Bundle::Defaults plugin that loads bunch of "default" plugins
Line 
1 package Plagger::Plugin::Namespace::HatenaFotolife;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub register {
6     my($self, $context) = @_;
7     $context->register_hook(
8         $self,
9         'aggregator.entry.fixup' => \&handle,
10     );
11 }
12
13 sub handle {
14     my($self, $context, $args) = @_;
15
16     # Hatena Image extensions
17     my $hatena = $args->{orig_entry}->{entry}->{"http://www.hatena.ne.jp/info/xmlns#"} || {};
18     if ($hatena->{imageurl}) {
19         my $enclosure = Plagger::Enclosure->new;
20         $enclosure->url($hatena->{imageurl});
21         $enclosure->auto_set_type;
22         $args->{entry}->add_enclosure($enclosure);
23     }
24
25     if ($hatena->{imageurlsmall}) {
26         $args->{entry}->icon({ url   => $hatena->{imageurlsmall} });
27     }
28
29     1;
30 }
31
32 1;
33 __END__
34
35 =head1 NAME
36
37 Plagger::Plugin::Namespace::HatenaFotolife - Parses Hatena Fotolife module
38
39 =head1 SYNOPSIS
40
41   - module: Namespace::HatenaFotolife
42
43 =head1 DESCRIPTION
44
45 This plugin parses Hatena Fotolife namespace extension and set images
46 URL to entry enclosures. This plugin is loaded by default.
47
48 =head1 AUTHOR
49
50 Tatsuhiko Miyagawa
51
52 =head1 SEE ALSO
53
54 L<Plagger>, L<http://www.hatena.ne.jp/info/xmlns#>
55
56 =cut
Note: See TracBrowser for help on using the browser.