Changeset 1389

Show
Ignore:
Timestamp:
08/19/06 15:26:33
Author:
miyagawa
Message:

Added Publish::Serializer via http://naoya.g.hatena.ne.jp/naoya/20060315/1142433649

Files:

Legend:

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

    r1333 r1389  
    112112    $feed->author(_u($remote->author)); 
    113113    $feed->updated($remote->modified); 
     114 
     115    Encode::_utf8_on($$xml_ref); 
    114116    $feed->source_xml($$xml_ref); 
    115117 
  • trunk/plagger/lib/Plagger/Plugin/Publish/JSON.pm

    r1386 r1389  
    2323 
    2424    local $JSON::Syck::ImplicitUnicode = 1; 
    25     my $body = JSON::Syck::Dump(Plagger::Walker->serialize($args->{feed}->clone)); 
     25    my $body = JSON::Syck::Dump(Plagger::Walker->serialize($args->{feed})); 
    2626 
    2727    if (my $var = $self->conf->{varname}) { 
     
    3030        $body = "$jsonp($body)"; 
    3131    } 
     32 
     33    $context->log(info => "Serializing " . $args->{feed}->id . " to $path"); 
    3234 
    3335    open my $out, ">:utf8", $path or $context->error("$path: $!"); 
  • trunk/plagger/lib/Plagger/Util.pm

    r1382 r1389  
    22use strict; 
    33our @ISA = qw(Exporter); 
    4 our @EXPORT_OK = qw( strip_html dumbnail decode_content extract_title load_uri mime_type_of ); 
     4our @EXPORT_OK = qw( strip_html dumbnail decode_content extract_title load_uri mime_type_of filename_for ); 
    55 
    66use Encode (); 
     
    161161} 
    162162 
     163my %formats = ( 
     164    'u' => sub { my $s = $_[0]->url;  $s =~ s!^https?://!!; $s }, 
     165    'l' => sub { my $s = $_[0]->link; $s =~ s!^https?://!!; $s }, 
     166    't' => sub { $_[0]->title }, 
     167    'i' => sub { $_[0]->id }, 
     168); 
     169 
     170my $format_re = qr/%(u|l|t|i)/; 
     171 
     172sub filename_for { 
     173    my($feed, $file) = @_; 
     174    $file =~ s{$format_re}{ 
     175        safe_filename($formats{$1}->($feed)) 
     176    }egx; 
     177    $file; 
     178} 
     179 
     180sub safe_filename { 
     181    my($path) = @_; 
     182    $path =~ s![^\w\s]+!_!g; 
     183    $path =~ s!\s+!_!g; 
     184    $path; 
     185} 
     186 
    1631871; 
  • trunk/plagger/lib/Plagger/Walker.pm

    r1386 r1389  
    8484        return wantarray ? @retval : $retval[0]; 
    8585    }; 
    86     $curry->($stuff); 
     86    $curry->($stuff->clone); 
    8787} 
    8888 
  • trunk/plagger/t/plugins/Filter-DeliciousFeedTags/base.t

    r1384 r1389  
    22use t::TestPlagger; 
    33 
     4test_requires_network('del.icio.us:80'); 
    45test_plugin_deps; 
    56plan 'no_plan';