Changeset 208

Show
Ignore:
Timestamp:
02/28/06 19:57:42
Author:
miyagawa
Message:
  • Added 'fetch_folders' option in Subscription::Bloglines
  • Added Plagger::Thing base class to share *_tag methods
  • Added 'expression' config in Debug. to be Plagger::Action maybe
  • Fixed ResolveRelativeLink? so it works with entry without link (Bloglines News feed!)
Files:

Legend:

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

    r171 r208  
    22use strict; 
    33 
    4 use base qw( Class::Accessor::Fast ); 
     4use base qw( Plagger::Thing ); 
    55__PACKAGE__->mk_accessors(qw( title author tags date link id summary body rate  icon meta)); 
    66 
     
    4040} 
    4141 
    42 sub has_tag { 
    43     my($self, $want_tag) = @_; 
    44     for my $tag (@{$self->tags}) { 
    45         return 1 if $tag eq $want_tag; 
    46     } 
    47     return 0; 
    48 } 
    49  
    50 sub add_tag { 
    51     my($self, $tag) = @_; 
    52     push @{$self->tags}, $tag 
    53         unless $self->has_tag($tag); 
    54 } 
    55  
    5642sub permalink { 
    5743    my $self = shift; 
  • trunk/plagger/lib/Plagger/Feed.pm

    r177 r208  
    22use strict; 
    33 
    4 use base qw( Class::Accessor::Fast ); 
     4use base qw( Plagger::Thing ); 
    55__PACKAGE__->mk_accessors(qw( link url image description language author updated tags meta type source_xml )); 
    66 
  • trunk/plagger/lib/Plagger/Plugin/Filter/ResolveRelativeLink.pm

    r206 r208  
    1818    my $entry = $args->{entry}; 
    1919 
    20     my $resolver = HTML::ResolveLink->new(base => $entry->permalink); 
     20    my $base = $entry->permalink || $args->{feed}->link; 
     21    my $resolver = HTML::ResolveLink->new(base => $base); 
    2122    my $html = $resolver->resolve($entry->body); 
    2223 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Debug.pm

    r104 r208  
    1515sub feed { 
    1616    my($self, $context, $args) = @_; 
    17     $context->dumper($args->{feed}); 
     17 
     18    if ($self->conf->{expression}) { 
     19        eval $self->conf->{expression}; 
     20        $context->log(error => "Expression error: $@ with '" . $self->conf->{expression} . "'") if $@; 
     21    } else { 
     22        $context->dumper($args->{feed}); 
     23    } 
    1824} 
    1925 
  • trunk/plagger/lib/Plagger/Plugin/Subscription/Bloglines.pm

    r199 r208  
    3030 
    3131    for my $folder ($subscription->folders) { 
    32         $self->add_subscription($context, $subscription, $folder->{BloglinesSubId}, $folder->{title}); 
    33     } 
    34  
    35     $self->add_subscription($context, $subscription, 0); 
     32        $self->add_subscription($subscription, $folder->{BloglinesSubId}, $folder->{title}); 
     33    } 
     34 
     35    $self->add_subscription($subscription, 0); 
    3636} 
    3737 
     
    4646        $feed->url($source->{xmlUrl} ); 
    4747        $feed->tags([ $title ]) if $title; 
    48         $context->subscription->add($feed); 
     48        Plagger->context->subscription->add($feed); 
    4949    } 
    5050} 
     
    6767        $feed->type('bloglines'); 
    6868        $context->subscription->add($feed); 
     69 
     70        if ($self->conf->{fetch_folders}) { 
     71            # TODO: cache it! 
     72            $self->fetch_folders($context); 
     73        } 
     74    } 
     75} 
     76 
     77sub fetch_folders { 
     78    my($self, $context) = @_; 
     79 
     80    $self->{folders} = {}; 
     81    $context->log(info => "call Bloglines listsubs API to get folder structure"); 
     82 
     83    my $subscription = $self->{bloglines}->listsubs(); 
     84 
     85    for my $folder ($subscription->folders) { 
     86        my @feeds = $subscription->feeds_in_folder($folder->{BloglinesSubId}); 
     87        for my $feed (@feeds) { 
     88            # BloglinesSubId is different from bloglines:siteid. Don't use it 
     89            $self->{folders}->{$feed->{htmlUrl}} = $folder->{title}; 
     90            $context->log(debug => "$feed->{htmlUrl}: $folder->{title}"); 
     91        } 
    6992    } 
    7093} 
     
    91114        $feed->author($source->{webmaster}); 
    92115        $feed->meta->{bloglines_id} = $source->{bloglines}->{siteid}; 
     116 
     117        # under fetch_folders option, set folder as tags to feeds 
     118        if (my $folder = $self->{folders}->{$feed->link}) { 
     119            $feed->tags([ $folder ]); 
     120        } 
     121 
    93122        $feed->source_xml($update->{_xml}); 
    94123 
     
    144173=item mark_read 
    145174 
    146 C<mark_read> specifies whether this plugin "marks as read" the items 
     175C<mark_read> specifies whether this plugin I<marks as read> the items 
    147176you synchronize. With this option set to 0, you will get the 
    148177duplicated updates everytime you run Plagger, until you mark them 
     
    156185to 1, the default. 
    157186 
     187=item fetch_folders 
     188 
     189C<fetch_folders> specifies whether this plugin fetches I<folder> 
     190strucuture using listsubs API. With this option on, all feeds under 
     191I<Plagger> folder will have I<Plagger> as its tag. 
     192 
     193You can use this tags information using Rules in later phase. 
     194 
    158195=back 
    159196