Changeset 721

Show
Ignore:
Timestamp:
05/13/06 04:03:12
Author:
miyagawa
Message:
  • FetchEnclosure? uses $feed->id_safe as a sub directory inside config:dir to avoid conflicts
  • Added $feed->id_safe method
  • Publish::2chdat now uses id_safe rather than its own
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Feed.pm

    r455 r721  
    5555} 
    5656 
     57sub id_safe { 
     58    my $self = shift; 
     59    my $id = $self->id; 
     60    $id =~ s![^\w\s]+!_!g; 
     61    $id =~ s!\s+!_!g; 
     62    $id; 
     63} 
     64 
    5765sub title_text { 
    5866    my $self = shift; 
  • trunk/plagger/lib/Plagger/Plugin/Filter/FetchEnclosure.pm

    r720 r721  
    3030    my $ua = Plagger::UserAgent->new; 
    3131    for my $enclosure ($args->{entry}->enclosures) { 
    32         my $path = File::Spec->catfile($self->conf->{dir}, $enclosure->filename); 
     32        my $feed_dir = File::Spec->catfile($self->conf->{dir}, $args->{feed}->id_safe); 
     33        unless (-e $feed_dir && -d _) { 
     34            $context->log(info => "mkdir $feed_dir"); 
     35            mkdir $feed_dir, 0777; 
     36        } 
     37 
     38        my $path = File::Spec->catfile($feed_dir, $enclosure->filename); 
    3339        $context->log(info => "fetch " . $enclosure->url . " to " . $path); 
    3440        $ua->mirror($enclosure->url, $path); 
  • trunk/plagger/lib/Plagger/Plugin/Publish/2chdat.pm

    r692 r721  
    3030 
    3131    my $feed = $args->{feed}; 
    32     my $out  = File::Spec->catfile($self->conf->{dir}, 'dat', $self->safe_id($feed->id) . ".dat"); 
     32    my $out  = File::Spec->catfile($self->conf->{dir}, 'dat', $feed->id_safe . ".dat"); 
    3333    $context->log(info => "Writing dat output to $out"); 
    3434 
     
    3939        ($feed->author || $feed->entries->[0]->author || $anonymous), 
    4040        $self->format_date( Plagger::Date->from_epoch(0) ), # Fix created date to handle bytes-range request 
    41         substr($self->safe_id($feed->id), 0, 8), 
     41        substr($feed->id_safe), 0, 8), 
    4242        $self->format_body($feed->description) . "<BR>" . $feed->link, 
    4343        $feed->title; 
     
    6565    open my $fh, ">:encoding(shift_jis)", $out or $context->erorr("$out: $!"); 
    6666    for my $feed ($context->update->feeds) { 
    67         printf $fh "%s.dat<>%s (%d)\n", $self->safe_id($feed->id), $feed->title, $feed->count; 
     67        printf $fh "%s.dat<>%s (%d)\n", $feed->id_safe, $feed->title, $feed->count; 
    6868    } 
    69 } 
    70  
    71 sub safe_id { 
    72     my($self, $id) = @_; 
    73     $id =~ s![^\w\s]+!_!g; 
    74     $id =~ s!\s+!_!g; 
    75     $id; 
    7669} 
    7770