Changeset 1881

Show
Ignore:
Timestamp:
11/28/06 18:37:40
Author:
miyagawa
Message:

Filter::EntryFullText?: grab title from TITLE tag, if title is not there ... this is a HACK. I would like to make it a separate plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Filter/EntryFullText.pm

    r1859 r1881  
    125125 
    126126    # use Last-Modified to populate entry date, even if handler doesn't find one 
     127    # TODO: make this a separate plugin 
    127128    if ($res->last_modified && !$args->{entry}->date) { 
    128129        $args->{entry}->date( Plagger::Date->from_epoch($res->last_modified) ); 
     
    131132    my @plugins = $handler ? ($handler) : @{ $self->{plugins} }; 
    132133 
     134    my $upgraded; 
    133135    for my $plugin (@plugins) { 
    134136        if ( $handler || $plugin->handle($args) ) { 
     
    157159                } 
    158160 
    159                 return 1; 
     161                $upgraded++; 
     162                last; 
    160163            } 
    161164        } 
    162165    } 
     166 
     167    # extract TITLE tag if title is not set yet 
     168    # TODO: make this a separate plugin 
     169    if (!$args->{entry}->title 
     170        and $args->{content} =~ m!<title>\s*(.*?)\s*</title>!is ) { 
     171        $args->{entry}->title( HTML::Entities::decode($1) ); 
     172    } 
     173 
     174    return 1 if $upgraded; 
    163175 
    164176    # failed to extract: store whole HTML if the config is on