Changeset 687
- Timestamp:
- 05/05/06 20:12:06
- Files:
-
- trunk/plagger/Makefile.PL (modified) (1 diff)
- trunk/plagger/lib/Plagger/Date.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Subscription/XOXO.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/Makefile.PL
r682 r687 208 208 'Subscription::XOXO' => [ 209 209 -default => 0, 210 recommends('HTML::TreeBuilder '),210 recommends('HTML::TreeBuilder::XPath'), 211 211 ], 212 212 ); trunk/plagger/lib/Plagger/Date.pm
r686 r687 7 7 use UNIVERSAL::require; 8 8 9 sub rebless { bless $_[1], $_[0] } 9 sub rebless { 10 my($class, $dt) = @_; 11 bless $dt, $class; 12 } 10 13 11 14 sub parse { … … 21 24 22 25 my $dt = $module->parse_datetime($date) or return; 23 24 # If parsed datetime is floating, don't set timezone here. It should be "fixed" in caller plugins 25 unless ($dt->time_zone->is_floating) { 26 $dt->set_time_zone( Plagger->context->conf->{timezone} || 'local' ); 27 } 28 29 bless $dt, $class; 26 $class->rebless($dt); 30 27 } 31 28 trunk/plagger/lib/Plagger/Plugin/Subscription/XOXO.pm
r683 r687 3 3 use base qw( Plagger::Plugin ); 4 4 5 use HTML::TreeBuilder ;5 use HTML::TreeBuilder::XPath; 6 6 use Plagger::Util; 7 7 use URI; … … 28 28 29 29 my $xhtml = Plagger::Util::load_uri($uri, $self); 30 my $tree = HTML::TreeBuilder ->new;30 my $tree = HTML::TreeBuilder::XPath->new; 31 31 $tree->parse($xhtml); 32 32 $tree->eof; … … 38 38 my($self, $tree) = @_; 39 39 40 for my $child ($tree->content_list) { 41 next unless ref $child; 42 if ($child->tag eq 'ul' || $child->tag eq 'ol') { 43 my $class = $child->attr('class') || ''; 44 if ($class eq 'xoxo' || $class eq 'subscriptionlist') { 45 $self->find_list($child); 46 } 47 } else { 48 $self->find_xoxo($child); 49 } 50 } 51 } 40 for my $child ($tree->findnodes('//ul[@class="xoxo" or @class="subscriptionlist"]//a')) { 41 my $href = $child->attr('href') or next; 42 my $title = $child->attr('title') || $child->as_text; 52 43 53 sub find_list { 54 my($self, $tree) = @_; 44 my $feed = Plagger::Feed->new; 45 $feed->url($href); 46 $feed->title($title); 55 47 56 for my $child ($tree->content_list) { 57 next unless ref $child; 58 if ($child->tag eq 'a') { 59 my $href = $child->attr('href') or next; 60 my $title = $child->attr('title') || $child->as_text; 61 62 my $feed = Plagger::Feed->new; 63 $feed->url($href); 64 $feed->title($title); 65 66 Plagger->context->subscription->add($feed); 67 } else { 68 $self->find_list($child); 69 } 48 Plagger->context->subscription->add($feed); 70 49 } 71 50 }
