Changeset 437

Show
Ignore:
Timestamp:
03/31/06 23:31:23
Author:
miyagawa
Message:

half-done support of Auto-Discovery in Xango. It doesn't work yet

Files:

Legend:

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

    r430 r437  
    2525        UseCache => exists $self->conf->{use_cache} ? 
    2626            $self->conf->{use_cache} : 1, 
     27        BrokerAlias => $xango_args{Alias}, 
    2728    ); 
    2829    Xango::Broker::Push->spawn(%xango_args); 
     
    4950package Plagger::Plugin::Aggregator::Xango::Crawler; 
    5051use strict; 
     52use Feed::Find; 
    5153use POE; 
    5254use Storable qw(freeze thaw); 
     
    5961 
    6062    POE::Session->create( 
    61         heap => { PLUGIN => $args{Plugin}, USE_CACHE => $args{UseCache} }, 
     63        heap => { 
     64            PLUGIN => $args{Plugin}, USE_CACHE => $args{UseCache}, 
     65            BROKER_ALIAS => $args{BrokerAlias}, 
     66        }, 
    6267        package_states => [ 
    6368            $class => [ qw(_start _stop apply_policy prep_request handle_response) ] 
     
    9297 
    9398    return unless $r->is_success; 
    94     $plugin->handle_feed($url, $r->content_ref); 
     99 
     100    my $ct = $r->content_type; 
     101    if ( $Feed::Find::IsFeed{$ct} ) { 
     102        $plugin->handle_feed($url, $r->content_ref); 
     103    } else { 
     104        my @feeds = Feed::Find->find_in_html($r->content_ref, $url); 
     105        if (@feeds) { 
     106            $url = $feeds[0]; 
     107            # xxx infinite loop 
     108            $_[KERNEL]->post($_[HEAP]->{BROKER_ALIAS}, 'enqueue_job', Xango::Job->new(uri => URI->new($url))); 
     109        } else { 
     110            return; 
     111        } 
     112    } 
     113 
    95114    if ($_[HEAP]->{USE_CACHE}) { 
    96115        $plugin->cache->set(