Changeset 98
- Timestamp:
- 02/18/06 10:45:53
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/CustomFeed/Mailman.pm
r49 r98 3 3 use base qw( Plagger::Plugin ); 4 4 5 use List::Util qw(min); 6 use DateTime::Locale; 5 7 use Encode; 6 8 use Plagger::UserAgent; … … 60 62 61 63 my $year = $now->year; 62 my $title = ($content =~ /<title>(.*?) $year/)[0]; # xxx hack 64 65 # TODO: only tested with ja and en localization 66 my $month = join '|', @{ DateTime::Locale->load('en_us')->month_names }; 67 my $title = ($content =~ /<title>(?:The )?(.*?) (?:(?:$month) )?$year/)[0]; 63 68 64 69 my $feed = Plagger::Feed->new; … … 67 72 $feed->link($self->conf->{url}); # base 68 73 69 my $i = 0; 70 my $items = $self->conf->{fetch_items} || 20; 74 my @matches; 71 75 while ($content =~ m!<LI><A HREF="(\d+\.html)">(.*?)\n</A><A NAME="(\d+)"> </A>\n<I>(.*?)\n</I>!g) { 72 last if $i++ >= $items; 76 push @matches, { 77 link => $1, 78 subject => $2, 79 id => $3, 80 from => $4, 81 }; 82 } 73 83 74 my($link, $subject, $id, $from) = ($1, $2, $3, $4); 84 my $items = min( $self->conf->{fetch_items} || 20, scalar(@matches)); 85 @matches = reverse @matches[-$items .. -1]; 86 87 for my $match (@matches) { 75 88 if ($self->conf->{trim_prefix}) { 76 89 # don't use $id here. Some Re: messages contain original ID 77 $ subject=~ s/\[$title \d+\]\s+//;90 $match->{subject} =~ s/\[$title \d+\]\s+//; 78 91 } 79 92 80 93 my $entry = Plagger::Entry->new; 81 $entry->title($ subject);82 $entry->link($base_url . $ link);83 $entry->author($ from);94 $entry->title($match->{subject}); 95 $entry->link($base_url . $match->{link}); 96 $entry->author($match->{from}); 84 97 85 98 $feed->add_entry($entry);
