Changeset 177

Show
Ignore:
Timestamp:
02/27/06 01:43:19
Author:
miyagawa
Message:
  • Fixed tDiaryComment to strictly match with tDiary's feed, and strips comment entry rather than rating it
  • Added $feed->source_xml to get the raw XML
Files:

Legend:

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

    r171 r177  
    33 
    44use base qw( Class::Accessor::Fast ); 
    5 __PACKAGE__->mk_accessors(qw( link url image description language author updated tags meta type )); 
     5__PACKAGE__->mk_accessors(qw( link url image description language author updated tags meta type source_xml )); 
    66 
    77use Digest::MD5 qw(md5_hex); 
     
    2121    my($self, $entry) = @_; 
    2222    push @{ $self->{entries} }, $entry; 
     23} 
     24 
     25sub delete_entry { 
     26    my($self, $entry) = @_; 
     27    my @entries = grep { $_ ne $entry } $self->entries; 
     28    $self->{entries} = \@entries; 
    2329} 
    2430 
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm

    r169 r177  
    5454    $feed->author($remote->author); 
    5555    $feed->updated($remote->modified); 
     56    $feed->source_xml($$xml_ref); 
    5657 
    5758    if ($remote->format eq 'Atom') { 
  • trunk/plagger/lib/Plagger/Plugin/Filter/tDiaryComment.pm

    r174 r177  
    99    $context->register_hook( 
    1010        $self, 
    11         'update.fixup' => \&filter, 
     11        'update.feed.fixup' => \&filter, 
    1212    ); 
    1313} 
     
    1616    my($self, $context, $args) = @_; 
    1717 
    18     for my $feed ($context->update->feeds) { 
    19         for my $entry ($feed->entries) { 
    20             $entry->add_rate($self->conf->{rate} || -1) if $entry->link =~ /#c\d+$/; 
     18    return unless $self->tdiary_magic($args->{feed}); 
     19 
     20    $context->log(debug => "Found tDiary feed " . $args->{feed}->url); 
     21 
     22    for my $entry ($args->{feed}->entries) { 
     23        if ($entry->link =~ /\.html#c\d+$/) { 
     24            # TODO: make it work with Plagger::Action framework 
     25            $context->log(info => "Strip comment " . $entry->link); 
     26            $args->{feed}->delete_entry($entry); 
    2127        } 
    2228    } 
     29} 
     30 
     31# http://cvs.sourceforge.net/viewcvs.py/tdiary/plugin/makerss.rb?rev=1.37 
     32our $FeedMagic = <<'MAGIC'; 
     33^<\?xml version="1.0" encoding=".*?"\?> 
     34<\?xml-stylesheet href="rss\.css" type="text/css"\?> 
     35<rdf:RDF xmlns="http://purl\.org/rss/1\.0/" xmlns:rdf="http://www\.w3\.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl\.org/dc/elements/1\.1/" xmlns:content="http://purl\.org/rss/1\.0/modules/content/" xml:lang=".*?"> 
     36MAGIC 
     37 
     38sub tdiary_magic { 
     39    my($self, $feed) = @_; 
     40 
     41    my $xml = $feed->source_xml or return; 
     42    $xml =~ /$FeedMagic/o; 
    2343} 
    2444 
     
    2949=head1 NAME 
    3050 
    31 Plagger::Plugin::Filter::StripRSSAd - Rating comment of tDiary. 
     51Plagger::Plugin::Filter::tDiaryComment - Rate tDiary comment 
    3252 
    3353=head1 SYNOPSIS 
    3454 
    3555    - module: Filter::tDiaryComment 
    36       config: 
    37             rate: -100 
    3856 
    3957=head1 DESCRIPTION 
    4058 
    41 This plugin rating comment of tDiary. 
     59tDiary (L<http://www.tdiary.org/>) RSS feed by default contains 
     60comments to the blog as well. They're useful to keep track of the 
     61discussion, but sometimes are annoying to read. 
     62 
     63This plugin strips the comment entries from tDiary RSS feeds. 
    4264 
    4365=head1 AUTHOR 
    4466 
    4567MATSUNO Tokuhiro E<lt>tokuhiro at mobilefactory.jpE<gt> 
     68 
     69Tatsuhiko Miyagawa 
    4670 
    4771=head1 SEE ALSO 
  • trunk/plagger/lib/Plagger/Plugin/Subscription/Bloglines.pm

    r167 r177  
    9191        $feed->author($source->{webmaster}); 
    9292        $feed->meta->{bloglines_id} = $source->{bloglines}->{siteid}; 
     93        $feed->source_xml($update->{_xml}); 
    9394 
    9495        for my $item ( $update->items ) {