Changeset 79

Show
Ignore:
Timestamp:
02/17/06 17:07:11
Author:
miyagawa
Message:
  • renamed stash into meta on Feed and Entry
  • Split Hatena Bookmark usersCount into Filter and Widget. Fixes #42
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger.pm

    r78 r79  
    1111 
    1212use base qw( Class::Accessor::Fast ); 
    13 __PACKAGE__->mk_accessors( qw(conf stash update subscription plugins_path) ); 
     13__PACKAGE__->mk_accessors( qw(conf update subscription plugins_path) ); 
    1414 
    1515use Plagger::Date; 
     
    3333    my $self = bless { 
    3434        conf  => {}, 
    35         stash => {}, 
    3635        update => Plagger::Update->new, 
    3736        subscription => Plagger::Subscription->new, 
  • trunk/plagger/lib/Plagger/Entry.pm

    r61 r79  
    33 
    44use base qw( Class::Accessor::Fast ); 
    5 __PACKAGE__->mk_accessors(qw( title author tags date link id summary body rate )); 
     5__PACKAGE__->mk_accessors(qw( title author tags date link id summary body rate meta)); 
    66 
    77use DateTime::Format::Mail; 
     
    1414        widgets => [], 
    1515        tags    => [], 
     16        meta    => {}, 
    1617    }, $class; 
    1718} 
  • trunk/plagger/lib/Plagger/Feed.pm

    r56 r79  
    33 
    44use base qw( Class::Accessor::Fast ); 
    5 __PACKAGE__->mk_accessors(qw( link url image description language author updated tags stash type )); 
     5__PACKAGE__->mk_accessors(qw( link url image description language author updated tags meta type )); 
    66 
    77use Digest::MD5 qw(md5_hex); 
     
    1010    my $class = shift; 
    1111    bless { 
    12         stash => {}, 
     12        meta => {}, 
    1313        tags  => [], 
    1414        entries => [], 
  • trunk/plagger/lib/Plagger/Plugin.pm

    r78 r79  
    1111        rule => $opt->{rule}, 
    1212        rule_op => $opt->{rule_op} || 'AND', 
    13         stash => {}, 
     13        meta => {}, 
    1414    }, $class; 
    1515    $self->init(); 
  • trunk/plagger/lib/Plagger/Plugin/Filter/FeedBurnerPermalink.pm

    r66 r79  
    77    $context->register_hook( 
    88        $self, 
    9         'update.fixup' => \&filter, 
     9        'update.entry.fixup' => \&filter, 
    1010    ); 
    1111} 
     
    1414    my($self, $context, $args) = @_; 
    1515 
    16     for my $feed ($context->update->feeds) { 
    17         for my $entry ($feed->entries) { 
    18             $self->feedburner_filter($context, $entry); 
    19         } 
    20     } 
    21 
    22  
    23 sub feedburner_filter { 
    24     my($self, $context, $entry) = @_; 
    25  
     16    my $entry = $args->{entry}; 
    2617    if ($entry->link =~ m!^http://feeds\.feedburner\.(com|jp)/!) { 
    27         $entry->permalink( $entry->id ); 
     18        $entry->permalink( $entry->id . "" ); # stringify guid 
    2819    } 
    2920} 
  • trunk/plagger/lib/Plagger/Plugin/Subscription/Bloglines.pm

    r68 r79  
    8787        $feed->language($source->{language}); 
    8888        $feed->author($source->{webmaster}); 
    89         $feed->stash->{bloglines_id} = $source->{bloglines}->{siteid}; 
     89        $feed->meta->{bloglines_id} = $source->{bloglines}->{siteid}; 
    9090 
    9191        for my $item ( $update->items ) { 
  • trunk/plagger/lib/Plagger/Plugin/Widget/HatenaBookmarkUsersCount.pm

    r76 r79  
    22use strict; 
    33use base qw( Plagger::Plugin Class::Accessor::Fast ); 
    4 __PACKAGE__->mk_accessors(qw( permalink map )); 
    5 use Plagger::Rule; 
    6 use XMLRPC::Lite; 
    74 
    85sub register { 
     
    107    $context->register_hook( 
    118        $self, 
    12         'update.entry.fixup' => \&vacuum, 
    13         'update.fixup' => \&update, 
    14         'publish.entry.fixup' => \&entry, 
     9        'publish.entry.fixup' => \&add, 
    1510    ); 
    16     $self->permalink({}); 
    1711} 
    1812 
    19 sub vacuum
     13sub add
    2014    my($self, $context, $args) = @_; 
    21     $self->permalink->{$args->{entry}->permalink} = 0; 
    22 
    23  
    24 sub update { 
    25     my($self, $context) = @_; 
    26     $self->map(XMLRPC::Lite-> 
    27                proxy('http://b.hatena.ne.jp/xmlrpc')-> 
    28                call('bookmark.getCount', keys %{$self->permalink})-> 
    29                result); 
    30 
    31  
    32 sub entry { 
    33     my($self, $context, $args) = @_; 
    34     return unless $self->map; 
    35     $args->{entry}->add_widget($self) if $self->map->{$args->{entry}->permalink}; 
     15    $args->{entry}->add_widget($self) 
     16        if defined($args->{entry}->meta->{hatenabookmark_users}); 
    3617} 
    3718 
    3819sub html { 
    3920    my($self, $entry) = @_; 
     21 
    4022    my $uri = URI->new('http://b.hatena.ne.jp/entry/' . $entry->permalink); 
    4123    my $url = HTML::Entities::encode($uri->as_string); 
    42     my $user = $self->map->{$entry->permalink}; 
    43     my $users = $user > 1 ? "$user users" : "$user user"; 
    44     $user > 9 ?  
     24 
     25    my $user = $entry->meta->{hatenabookmark_users}; 
     26    my $users = $user >= 2 ? "$user users" : "$user user"; 
     27 
     28    $user >= 10 ? 
    4529        qq(<strong style="background-color: #ffcccc; font-weight: bold; font-style: normal; display: inline;"><a href="$url" style="color: red;">$users</a></strong>) 
    46         : $user > 2 ? 
     30        : $user >= 2 ? 
    4731        qq(<em style="background-color: #fff0f0; font-weight: bold; display: inline; font-style: normal;"><a href="$url" style="color: #ff6666;">$users</a></em>) 
    4832        : qq(<a href="$url">$users</a>); 
    4933} 
     34 
    50351; 
     36