Changeset 156

Show
Ignore:
Timestamp:
02/26/06 14:06:46
Author:
youpy
Message:

Changed hook to publish.entry

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Spotlight.pm

    r153 r156  
    1010    $context->register_hook( 
    1111        $self, 
    12         'publish.feed' => \&feed
     12        'publish.entry' => \&entry
    1313    ); 
    1414} 
    1515 
    16 sub feed
     16sub entry
    1717    my($self, $context, $args) = @_; 
    1818 
     
    2222    } 
    2323 
    24     for my $entry ($args->{feed}->entries) { 
    25        my $file = $entry->id_safe . '.webbookmark'; 
    26        my $path = File::Spec->catfile($dir, $file); 
    27        $context->log(info => "writing output to $path"); 
     24    my $entry = $args->{entry}; 
     25    my $file = $entry->id_safe . '.webbookmark'; 
     26    my $path = File::Spec->catfile($dir, $file); 
     27    $context->log(info => "writing output to $path"); 
    2828 
    29         my $body = $self->templatize($context, $entry); 
     29    my $body = $self->templatize($context, $entry); 
     30     
     31    open my $out, ">:utf8", $path or $context->error("$path: $!"); 
     32    print $out $body; 
     33    close $out; 
    3034 
    31         open my $out, ">:utf8", $path or $context->error("$path: $!"); 
    32         print $out $body; 
    33         close $out; 
    34  
    35         # Add $entry->body as spotlight comment using AppleScript (OSX only) 
    36         if ($self->{conf}->{add_comment}) { 
    37             eval { require Mac::Glue }; 
    38             my $comment = $entry->body; 
    39             utf8::decode($comment) unless utf8::is_utf8($comment); 
    40             $comment =~ s/<[^>]*>//g; 
    41             $comment =~ s/\n//g; 
    42             $comment = encode("shift_jis", $comment); # xxx 
    43              
    44             my $finder = Mac::Glue->new("Finder"); 
    45             my $file = $finder->obj(file => $path); 
    46             $file->prop('comment')->set(to => $comment); 
    47         } 
     35    # Add $entry->body as spotlight comment using AppleScript (OSX only) 
     36    if ($self->{conf}->{add_comment}) { 
     37        eval { require Mac::Glue }; 
     38        my $comment = $entry->body; 
     39        utf8::decode($comment) unless utf8::is_utf8($comment); 
     40        $comment =~ s/<[^>]*>//g; 
     41        $comment =~ s/\n//g; 
     42        $comment = encode("shift_jis", $comment); # xxx 
     43         
     44        my $finder = Mac::Glue->new("Finder"); 
     45        my $file = $finder->obj(file => $path); 
     46        $file->prop('comment')->set(to => $comment); 
    4847    } 
    4948}