Changeset 1590

Show
Ignore:
Timestamp:
08/24/06 20:40:18
Author:
miyagawa
Message:

refactored Filter::TruePermalink? to use Plugin->load_assets. Store redirection result as cache to avoid too many requests to the same URL

Files:

Legend:

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

    r1583 r1590  
    1919    my $self = shift; 
    2020 
    21     my $dir = $self->assets_dir; 
    22     my $dh = DirHandle->new($dir) or Plagger->context->error("$dir: $!"); 
    23     for my $file (grep -f $_->[0] && $_->[1] =~ /\.yaml$/, 
    24                   map [ File::Spec->catfile($dir, $_), $_ ], sort $dh->read) { 
    25         $self->load_plugin(@$file); 
    26     } 
    27 
    28  
    29 sub load_plugin { 
    30     my($self, $file, $base) = @_; 
    31  
    32     Plagger->context->log(debug => "loading $file"); 
    33     my $data = YAML::LoadFile($file); 
    34     if (ref($data) eq 'ARRAY') { 
    35         # redirectors.yaml ... make it backward compatible to ignore 
    36     } else { 
    37         push @{$self->{plugins}}, $data; 
    38     } 
     21    $self->load_assets( 
     22        File::Find::Rule->name('*.yaml'), 
     23        sub { 
     24            my $file = shift; 
     25            Plagger->context->log(debug => "loading $file"); 
     26            my $data = YAML::LoadFile($file); 
     27            if (ref($data) eq 'ARRAY') { 
     28                # redirectors.yaml ... make it backward compatible to ignore 
     29            } else { 
     30                push @{$self->{plugins}}, $data; 
     31            } 
     32        }, 
     33    ); 
    3934} 
    4035 
     
    129124                return $res->header('Location'); 
    130125            } 
    131             return
     126            return ''
    132127        }, 
    133128        '1 day', 
  • trunk/plagger/t/plugins/Filter-TruePermalink/oreilly.t

    r1583 r1590  
    1010--- input config 
    1111plugins: 
    12   - module: Subscription::Confi
     12  - module: CustomFeed::Debu
    1313    config: 
    14       feed: 
    15         - http://www.makezine.com/ 
     14      title: Make 
     15      link: http://www.makezine.com/ 
     16      entry: 
     17        - title: Foo 
     18          link: http://www.makezine.com/blog/archive/2006/08/usb_bbq.html?CMP=OTC-0D6B48984890 
    1619  - module: Filter::TruePermalink 
    1720--- expected