Changeset 1173

Show
Ignore:
Timestamp:
07/27/06 03:11:42
Author:
miyagawa
Message:

Merge from refactoring-planet. YAY!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/Makefile.PL

    r1120 r1173  
     1use strict; 
    12use inc::Module::Install; 
    23 
     
    2425requires('Date::Parse'); 
    2526requires('MIME::Types', 1.16); 
    26  
    27 requires('XML::Feed', 0.08); 
     27requires('Net::DNS'); 
     28 
     29requires('XML::Feed', 0.09); 
    2830requires('XML::LibXML'); 
    2931requires('XML::Atom', 0.19); 
     
    3234requires('Term::Encoding'); 
    3335 
    34 build_requires(Test::More => 0.42); 
     36build_requires('Test::More', 0.42); 
     37build_requires('Test::Base', 0.52); 
    3538 
    3639features( 
     
    99102        recommends('POE::Component::IKC::Client'), 
    100103    ], 
    101     'Filter::URLBL' => [ 
    102         -default => 0, 
    103         recommends('Net::DNS'), 
    104     ], 
    105104    'Publish::JavaScript' => [ 
    106105        -default => 0, 
     
    124123    ], 
    125124    'Publish::Planet' => [ 
    126         -default => 0, 
    127         recommends('HTML::Tidy'), 
     125        -default => 1, 
    128126        recommends('HTML::Scrubber'), 
    129127        recommends('File::Copy::Recursive'), 
     
    191189        recommends('Text::Kakasi'), 
    192190    ], 
    193     'Rule::URLBL' => [ 
    194         -default => 0, 
    195         recommends('Net::DNS'), 
    196     ], 
    197191    'Subscription::LivedoorReader' => [ 
    198192        -default => 0, 
     
    227221        -default => 0, 
    228222        recommends('Audio::Beep'), 
     223    ], 
     224    'Bundle::Planet' => [ 
     225        -default => 1, 
     226        recommends('Time::Duration::Parse'), 
    229227    ], 
    230228    'Publish::SWF' => [ 
     
    295293 
    296294tests 't/*.t t/*/*.t t/*/*/*.t'; 
     295 
     296use_test_base; 
    297297 
    298298auto_include; 
  • trunk/plagger/assets/plugins/Publish-OPML/opml.tt

    r1092 r1173  
     1<?xml version="1.0" encoding="utf-8"?>  
    12<opml version="1.0"> 
    23<head> 
    3 <title>Plagger Subscriptions</title> 
     4<title>[% (conf.title || 'Plagger Subscriptions') | html %]</title> 
    45<dateCreated>[% now.format('Mail') %]</dateCreated> 
    56<ownerName /> 
    67</head> 
    78<body> 
    8 <outline title="Subscriptions"> 
     9<outline text="Subscriptions"> 
    910[% FOREACH feed = feeds -%] 
    10 <outline title="[% feed.title | html %]" htmlUrl="[% feed.link | html %]" type="rss" xmlUrl="[% feed.url | html %]" /> 
     11<outline title="[% feed.title | html %]" htmlUrl="[% feed.link | html %]" text="[% (feed.primary_author || feed.title) | html %]" type="rss" xmlUrl="[% feed.url | html %]" /> 
    1112[% END -%] 
    1213</outline> 
  • trunk/plagger/assets/plugins/Publish-Planet/default/template/index.tt

    r1092 r1173  
    66    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    77    <meta name="generator" contnet="Plagger [% context.VERSION %]" /> 
    8     <link rel="alternate" type="application/atom+xml" title="Atom: [% feed.title %]" href="smartfeed_all.atom" /> 
    9     <link rel="alternate" type="application/rss+xml" title="RSS: [% feed.title %]" href="smartfeed_all.rss" /> 
     8    <link rel="alternate" type="application/atom+xml" title="Atom: [% feed.title | html %]" href="[% url.atom %]" /> 
     9    <link rel="alternate" type="application/rss+xml" title="RSS: [% feed.title | html %]" href="[% url.rss %]" /> 
     10[% IF url.opml -%] 
     11    <link rel="subscriptions" type="text/x-opml" title="Subscriptions" ref="[% url.opml %]" /> 
     12[% END -%] 
     13[% IF url.foaf -%] 
     14    <link rel="meta" type="application/rdf+xml" title="foafroll" href="[% url.foaf %]" /> 
     15[% END -%] 
    1016    <link rel="stylesheet" type="text/css" href="css/screen.css" /> 
    1117    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" /> 
    1218    <link rel="stylesheet" type="text/css" href="css/handheld.css" media="handheld" /> 
    13     [% IF members_list %] 
    14       <link rel="stylesheet" type="text/css" href="css/screen-members-list.css" /> 
    15     [% END %] 
     19    <link rel="stylesheet" type="text/css" href="css/screen-members-list.css" /> 
    1620    <title>[% feed.title %]</title> 
    1721  </head> 
     
    1923    <div id="feed-title">[% feed.title %]</div> 
    2024 
    21     [% IF members_list %] 
    22       <ul id="members-list"> 
    23         [% FOREACH member = members %] 
    24           <li class="member"> 
    25             <a class="member-link" href="[% member.link | html %]">[% member.title | html %]</a> 
    26           </li> 
    27         [% END %] 
    28       </ul> 
    29     [% END %] 
     25    <ul id="members-list"> 
     26      [% FOREACH member = members %] 
     27        <li class="member"> 
     28          <a class="member-link" href="[% member.link | html %]">[% member.title | html %]</a> 
     29        </li> 
     30      [% END %] 
     31    </ul> 
    3032 
    31     [% FOREACH entry = feed.entries %] 
     33    [% FOREACH entry = entries %] 
    3234      <div class="entry"> 
    3335        <div class="entry-header"> 
  • trunk/plagger/assets/plugins/Publish-Planet/sixapart-std/template/index.tt

    r1092 r1173  
    55  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    66  <meta name="generator" content="Plagger [% context.VERSION %]" /> 
    7   <link rel="alternate" type="application/atom+xml" title="Atom: [% feed.title %]" href="smartfeed_all.atom" /> 
    8   <link rel="alternate" type="application/rss+xml" title="RSS: [% feed.title %]" href="smartfeed_all.rss" /> 
    9   [% IF style_url %]<link rel="stylesheet" type="text/css" href="[% style_url %]" />[% END %] 
     7  <link rel="alternate" type="application/atom+xml" title="Atom: [% feed.title | html %]" href="[% url.atom %]" /> 
     8  <link rel="alternate" type="application/rss+xml" title="RSS: [% feed.title | html %]" href="[% url.rss %]" /> 
     9[% IF url.opml -%] 
     10  <link rel="subscriptions" type="text/x-opml" title="Subscriptions" href="[% url.opml %]" /> 
     11[% END -%] 
     12[% IF url.foaf -%] 
     13  <link rel="meta" type="application/rdf+xml" title="foafroll" href="[% url.foaf %]" /> 
     14[% END -%] 
     15[% FOREACH style = style_url.list -%] 
     16  <link rel="stylesheet" type="text/css" href="[% style | html %]" /> 
     17[% END %] 
    1018  <title>[% feed.title | html %]</title> 
    1119</head> 
     
    2432          <div id="alpha"> 
    2533            <div id="alpha-inner" class="pkg"> 
    26               [% FOREACH entry = feed.entries %] 
     34              [% FOREACH entry = entries %] 
    2735              <a id="[% entry.id %]"></a> 
    2836              <div class="entry" id="entry-[% entry.id %]"> 
     
    4553                    <span class="separator">|</span> 
    4654                    <a class="permalink" href="[% entry.permalink | html %]">Permalink</a> 
    47                     [% FOREACH widget = entry.widgerts %] 
     55                    [% FOREACH widget = entry.widgets %] 
    4856                    | [% widget.html(entry) %] 
    4957                    [% END %] 
     
    5765          <div id="beta"> 
    5866            <div id="beta-inner" class="pkg"> 
    59             [% IF members_list %] 
    6067              <div class="module"> 
    6168                <h2 class="module-header">Subscriptions</h2> 
     
    7077                </div> 
    7178              </div> 
    72             [% END %] 
    7379              <div class="module-powered module"> 
    7480                <div class="module-content"> 
  • trunk/plagger/examples/planet.yaml

    r1054 r1173  
    66plugins: 
    77  # Subscribe to a couple of "My Feeds" on the web 
    8   # They could be either Feeds URL or Blog URL (with AUto-Discovery support) 
     8  # They could be either Feeds URL or Blog URL (with Auto-Discovery support) 
    99  - module: Subscription::Config 
    1010    config: 
     
    1616        - http://d.hatena.ne.jp/miyagawa/ 
    1717 
    18   # Create "Smart Feed" with all entries across the feeds, fresher than 7 days old 
    19   # Add the title "Planet Plagger" to the smartfeed 
    20   - module: SmartFeed::All 
    21     rule: 
    22       module: Fresh 
    23       duration: 10080 # Seven Days 
     18  # Load 'Bundle' planet plugins 
     19  - module: Bundle::Planet 
    2420    config: 
     21      duration: 7 days 
    2522      title: Planet Plagger 
     23      dir: /tmp/planet 
     24      url: http://example.org/planet/ 
     25      theme: sixapart-std 
     26      stylesheet: http://bulknews.typepad.com/blog/styles.css 
    2627 
    27   # Generate Planet XHTML output out of the smartfeed 
    28   # to the directory /tmp/planet with sixapart-std "skin" 
    29   - module: Publish::Planet 
    30     rule: 
    31       expression: $args->{feed}->id eq 'smartfeed:all' 
    32     config: 
    33       dir: /tmp/planet 
    34       skin: sixapart-std 
    35       template: 
    36         members_list: 1 
    37         style_url: http://bulknews.typepad.com/blog/styles.css 
    38  
    39   # Output Atom feed for the smartfeed 
    40   - module: Publish::Feed 
    41     rule: 
    42       expression:  $args->{feed}->id eq 'smartfeed:all' 
    43     config: 
    44       dir: /tmp/planet 
    45  
    46   # Output RSS feed for the smartfeed 
    47   - module: Publish::Feed 
    48     rule: 
    49       expression:  $args->{feed}->id eq 'smartfeed:all' 
    50     config: 
    51       dir: /tmp/planet 
    52       format: RSS 
    53  
  • trunk/plagger/lib/Plagger.pm

    r1145 r1173  
    99use File::Copy; 
    1010use File::Basename; 
    11 use File::Find::Rule; 
     11use File::Find::Rule (); # don't import rule()! 
    1212use YAML; 
    1313use Storable; 
     
    6868    $self->rewrite_config if @{ $self->{rewrite_tasks} }; 
    6969    $self->run(); 
     70 
     71    $self; 
    7072} 
    7173 
     
    361363    my($self, $level, $msg, %opt) = @_; 
    362364 
     365    return unless $self->should_log($level); 
     366 
    363367    # hack to get the original caller as Plugin or Rule 
    364368    my $caller = $opt{caller}; 
     
    372376    } 
    373377 
    374     if ($self->should_log($level)) { 
    375         chomp($msg); 
    376         if ($self->{log}->{encoding}) { 
    377             $msg = Encode::decode_utf8($msg) unless utf8::is_utf8($msg); 
    378             $msg = Encode::encode($self->{log}->{encoding}, $msg); 
    379         } 
    380         warn "$caller [$level] $msg\n"; 
    381     } 
     378    chomp($msg); 
     379    if ($self->{log}->{encoding}) { 
     380        $msg = Encode::decode_utf8($msg) unless utf8::is_utf8($msg); 
     381        $msg = Encode::encode($self->{log}->{encoding}, $msg); 
     382    } 
     383    warn "$caller [$level] $msg\n"; 
    382384} 
    383385 
     
    409411sub template { 
    410412    my $self = shift; 
     413    $self->log(error => "\$context->template is DEPRECATED NOW. use \$plugin->templatize()"); 
    411414    my $plugin = shift || (caller)[0]; 
    412415    Plagger::Template->new($self, $plugin->class_id); 
     
    415418sub templatize { 
    416419    my($self, $plugin, $file, $vars) = @_; 
    417     my $tt = $self->template($plugin); 
    418     $tt->process($file, $vars, \my $out) or $self->error($tt->error); 
    419     $out; 
     420    $self->log(error => "\$context->templatize is DEPRECATED NOW. use \$plugin->templatize()"); 
     421    $plugin->templatize($file, $vars); 
    420422} 
    421423 
  • trunk/plagger/lib/Plagger/Entry.pm

    r1024 r1173  
    6868sub body_text { 
    6969    my $self = shift; 
    70     Plagger::Util::strip_html($self->body); 
     70    Plagger::Util::strip_html($self->body || ''); 
    7171} 
    7272 
  • trunk/plagger/lib/Plagger/Feed.pm

    r1024 r1173  
    9595} 
    9696 
     97sub primary_author { 
     98    my $self = shift; 
     99    $self->author || do { 
     100        # if all entries are authored by the same person, use him/her as primary 
     101        my %authors = map { defined $_->author ? ($_->author => 1) : () } $self->entries; 
     102        my @authors = keys %authors; 
     103        @authors == 1 ? $authors[0] : undef; 
     104    }; 
     105} 
     106 
    971071; 
  • trunk/plagger/lib/Plagger/Plugin.pm

    r807 r1173  
    1111 
    1212use FindBin; 
     13use File::Find::Rule (); 
    1314use File::Spec; 
    1415 
     
    126127} 
    127128 
     129sub templatize { 
     130    my($self, $file, $vars) = @_; 
     131 
     132    my $context = Plagger->context; 
     133    $vars->{context} ||= $context; 
     134 
     135    my $template = Plagger::Template->new($context, $self->class_id); 
     136    $template->process($file, $vars, \my $out) or $context->error($template->error); 
     137 
     138    $out; 
     139} 
     140 
     141sub load_assets { 
     142    my($self, $rule, $callback) = @_; 
     143 
     144    my $context = Plagger->context; 
     145 
     146    my $dir = $self->assets_dir; 
     147 
     148    # $rule isa File::Find::Rule 
     149    for my $file ($rule->in($dir)) { 
     150        $callback->($file); 
     151    } 
     152} 
     153 
    1281541; 
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Null.pm

    r921 r1173  
    1414    my($self, $context, $args) = @_; 
    1515    $context->update->add($args->{feed}); 
     16    return 1; 
    1617} 
    1718 
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm

    r1065 r1173  
    3838        $self->handle_feed($url, \$content, $args->{feed}); 
    3939    } else { 
     40        $content = Plagger::Util::decode_content($res); 
    4041        my @feeds = Feed::Find->find_in_html(\$content, $url); 
    4142        if (@feeds) { 
  • trunk/plagger/lib/Plagger/Plugin/Notify/IRC.pm

    r1049 r1173  
    3939    $context->log(info => "Notifying " . $args->{feed}->title . " to IRC"); 
    4040 
    41     my $body = $self->templatize($context, $args->{feed}); 
     41    my $body = $self->templatize('irc_notify.tt', { feed => $args->{feed} }); 
    4242    Encode::_utf8_off($body) if Encode::is_utf8($body); 
    4343    Encode::from_to($body, 'utf-8', $self->conf->{charset}) 
     
    4646        $remote->post( 'notify_irc/update', $line ); 
    4747    } 
    48 } 
    49  
    50 sub templatize { 
    51     my($self, $context, $feed) = @_; 
    52     my $tt = $context->template(); 
    53     $tt->process('irc_notify.tt', { 
    54         feed => $feed, 
    55     }, \my $out) or $context->error($tt->error); 
    56     $out; 
    5748} 
    5849 
  • trunk/plagger/lib/Plagger/Plugin/Notify/SSTP.pm

    r269 r1173  
    2020    my @messages = $title; 
    2121    for my $entry ($args->{feed}->entries) { 
    22         push @messages, $self->templatize($context, $entry); 
     22        push @messages, $self->templatize('sstp.tt', { entry => $entry }); 
    2323    } 
    2424    my $message = join '\x', @messages; 
     
    3232    my $result = $sstp->send($message); 
    3333    $context->log(debug => $result); 
    34 } 
    35  
    36 sub templatize { 
    37     my($self, $context, $entry) = @_; 
    38     my $tt = $context->template(); 
    39     $tt->process('sstp.tt', { 
    40         entry => $entry, 
    41     }, \my $out) or $context->error($tt->error); 
    42     $out; 
    4334} 
    4435 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Tiarra.pm

    r791 r1173  
    2121 
    2222    my $protocol = 'TIARRACONTROL/1.0'; 
    23     my $tt = $context->template(); 
     23 
    2424    my $request_template = <<END; 
    2525NOTIFY System::SendMessage [% protocol %]\r 
     
    3636    my $charset = $self->conf->{charset} || 'UTF-8'; 
    3737 
    38     my $body = $self->templatize($context, $args->{feed}); 
     38    my $body = $self->templatize('irc_notify.tt', $args); 
    3939 
    4040    for my $line (split("\n", $body)) { 
     
    4949        } 
    5050 
    51         $tt->process(\$request_template, { 
     51        my $out = $self->templatize(\$request_template, { 
    5252            protocol => $protocol, 
    53             charset => $charset, 
    54             channel => $self->conf->{channel}, 
    55             sender => $self->conf->{sender} || "Plagger/$Plagger::VERSION (http://plagger.bulknews.net/)", 
     53            charset => $charset, 
     54            channel => $self->conf->{channel}, 
     55            sender   => $self->conf->{sender} || "Plagger/$Plagger::VERSION (http://plagger.bulknews.net/)", 
    5656            use_notice => ($self->conf->{use_notice} ? 'yes' : 'no'), 
    57             text => $line, 
    58         }, \my $out) or $context->error($tt->error); 
     57            text     => $line, 
     58        }); 
    5959        Encode::_utf8_off($out) if Encode::is_utf8($out); 
    60         Encode::from_to($out, 'utf-8', $charset) unless $charset eq 'UTF-8'; 
     60        Encode::from_to($out, 'utf-8', $charset) unless uc($charset) eq 'UTF-8'; 
    6161        $remote->print($out); 
    6262 
     
    6969        Time::HiRes::sleep( $self->conf->{send_interval} || 2 ); 
    7070    } 
    71 } 
    72  
    73 sub templatize { 
    74     my($self, $context, $feed) = @_; 
    75     my $tt = $context->template(); 
    76     $tt->process('irc_notify.tt', { 
    77         feed => $feed, 
    78     }, \my $out) or $context->error($tt->error); 
    79     $out; 
    8071} 
    8172 
  • trunk/plagger/lib/Plagger/Plugin/Publish/CHTML.pm

    r943 r1173  
    5555        my $entry_id = md5_hex($entry->permalink); 
    5656        $self->write("$publish_path/$entry_id.html", 
    57                      $self->entry_templatize($feed, $entry)); 
     57                     $self->templatize('chtml_entry.tt', { 
     58                         conf => $self->conf, 
     59                         feed => $feed, 
     60                         entry => $entry, 
     61                         strip_html => sub { 
     62                             my $html = shift; 
     63                             $html =~ s|\s{2,}||og; 
     64                             $html =~ s|<[bh]r.*?>|\n|ogi; 
     65                             $html =~ s|<.*?>||og; 
     66                             $html; 
     67                         }, 
     68                     })); 
     69 
    5870        $entry->{feed2entry_link} = $self->id . "/$entry_id.html"; 
    5971    } 
    6072 
    61     $self->write("$publish_path.html",  
    62                  $self->feed_templatize($feed, $self->earlier($feed_path)), 
     73    $self->write("$publish_path.html", 
     74                 $self->templatize('chtml_feed.tt', { 
     75                     conf => $self->conf, 
     76                     feed => $feed, 
     77                     earlier => $self->earlier($feed_path), 
     78                 }), 
    6379                 "$feed_path/index.html"); 
    6480 
     
    7692    return unless @{$self->feeds}; 
    7793    $self->write($self->work . '/' . $self->id . '.html',  
    78                  $self->index_templatize($self->earlier($self->work)), 
     94                 $self->templatize('chtml_index.tt', { 
     95                     conf => $self->conf, 
     96                     feeds => [ $self->feeds ], 
     97                     earlier => $self->earlier($self->work), 
     98                 }), 
    7999                 $self->work . '/index.html'); 
    80 } 
    81  
    82 sub entry_templatize { 
    83     my($self, $feed, $entry) = @_; 
    84     $self->templatize('chtml_entry.tt', { 
    85         conf => $self->conf, 
    86         feed => $feed, 
    87         entry => $entry, 
    88         strip_html => sub { 
    89             my $html = shift; 
    90             $html =~ s|\s{2,}||og; 
    91             $html =~ s|<[bh]r.*?>|\n|ogi; 
    92             $html =~ s|<.*?>||og; 
    93             $html; 
    94         }}); 
    95 } 
    96  
    97 sub feed_templatize { 
    98     my($self, $feed, $earlier) = @_; 
    99     $self->templatize('chtml_feed.tt', { 
    100         conf => $self->conf, 
    101         feed => $feed, 
    102         earlier => $earlier, 
    103     }); 
    104 } 
    105  
    106 sub index_templatize { 
    107     my($self, $earlier) = @_; 
    108     $self->templatize('chtml_index.tt', { 
    109         conf => $self->conf, 
    110         feeds => [ $self->feeds ], 
    111         earlier => $earlier, 
    112     }); 
    113 } 
    114  
    115 sub templatize { 
    116     my $self = shift; 
    117     my $tt = $self->context->template(); 
    118     $tt->process(shift, shift, \my $out) or $self->context->error($tt->error); 
    119     $out; 
    120100} 
    121101 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm

    r1089 r1173  
    3030        mkdir $dir, 0755 or $context->error("mkdir $dir: $!"); 
    3131    } 
     32 
     33    unless (exists $self->conf->{full_content}) { 
     34        $self->conf->{full_content} = 1; 
     35    } 
    3236} 
    3337 
     
    3842    my $f = $args->{feed}; 
    3943    my $feed_format = $conf->{format} || 'Atom'; 
     44 
     45    local $XML::Atom::DefaultVersion = "1.0"; 
    4046 
    4147    # generate feed 
     
    5157        $entry->title($e->title); 
    5258        $entry->link($e->link); 
    53         $entry->summary($e->body_text); 
    54         $entry->content($e->body); 
     59        $entry->summary($e->body_text) if defined $e->body; 
     60        $entry->content($e->body) 
     61            if $self->conf->{full_content} && defined $e->body; 
    5562        $entry->category(join(' ', @{$e->tags})); 
    5663        $entry->issued($e->date) if $e->date; 
     
    151158=head1 CONFIG 
    152159 
    153 =head2 format 
     160=over 4 
     161 
     162=item format 
    154163 
    155164Specify the format of feed. C<Plagger::Plugin::Publish::Feed> supports 
    156165the following syndication feed formats: 
    157166 
    158 =over 4 
    159  
    160 =item * Atom (default) 
    161  
    162 =item * RSS 
     167=over 8 
     168 
     169=item Atom (default) 
     170 
     171=item RSS 
    163172 
    164173=back 
    165174 
    166 =head2 dir 
     175=item dir 
    167176 
    168177Directory to save feed files in. 
    169178 
    170 =head2 filename 
     179=item filename 
    171180 
    172181Filename to be used to create feed files. It defaults to C<%i.rss> for 
     
    174183like printf(): 
    175184 
    176 =over 4 
    177  
    178 =item * %u url 
    179  
    180 =item * %l link 
    181  
    182 =item * %t title 
    183  
    184 =item * %i id 
     185=over 8 
     186 
     187=item %u url 
     188 
     189=item %l link 
     190 
     191=item %t title 
     192 
     193=item %i id 
    185194 
    186195=back 
    187196 
     197=item full_content 
     198 
     199Whether to publish full content feed. Defaults to 1. 
     200 
     201=back 
     202 
    188203=head1 AUTHOR 
    189204 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm

    r908 r1173  
    6565    } 
    6666 
    67     my $body = $self->templatize($context, $feed); 
     67    my $body = $self->templatize('gmail_notify.tt', { feed => $feed }); 
    6868 
    6969    my $cfg = $self->conf; 
     
    184184} 
    185185 
    186 sub templatize { 
    187     my($self, $context, $feed) = @_; 
    188     my $tt = $context->template(); 
    189     $tt->process('gmail_notify.tt', { 
    190         feed => $feed, 
    191     }, \my $out) or $context->error($tt->error); 
    192     $out; 
    193 } 
    194  
    195186sub DESTORY { 
    196187    my $self = shift; 
  • trunk/plagger/lib/Plagger/Plugin/Publish/IMAP.pm

    r795 r1173  
    6161     $feed_title =~ tr/,//d; 
    6262  my $subject    = $entry->title || '(no-title)'; 
    63   my $body       = $self->templatize($context, $args); 
     63  my $body       = $self->templatize('mail.tt', { entry => $args->{entry}, feed => $args->{feed} }); 
    6464  my $now = Plagger::Date->now(timezone => $context->conf->{timezone}); 
    6565  $msg = MIME::Lite->new( 
     
    8282  store_maildir($self, $context,$msg->as_string()); 
    8383  $self->{msg} += 1; 
    84 } 
    85  
    86 sub templatize { 
    87   my ($self, $context, $args) = @_; 
    88   my $tt = $context->template(); 
    89   $tt->process( 'mail.tt', { 
    90     entry => $args->{entry}, 
    91     feed  => $args->{feed}, 
    92   }, \my $out ) or $context->error($tt->error); 
    93   $out; 
    9484} 
    9585 
  • trunk/plagger/lib/Plagger/Plugin/Publish/JavaScript.pm

    r934 r1173  
    3131    $context->log(info => "writing output to $path"); 
    3232 
    33     my $body = $self->templatize($context, $args->{feed}); 
     33    my $body = $self->templatize('javascript.tt', { feed => $args->{feed} }); 
    3434 
    3535    open my $out, ">:utf8", $path or $context->error("$path: $!"); 
     
    6262    $path =~ s!\s+!_!g; 
    6363    $path; 
    64 } 
    65  
    66 sub templatize { 
    67     my($self, $context, $feed) = @_; 
    68     my $tt = $context->template(); 
    69     $tt->process('javascript.tt', { 
    70         feed => $feed, 
    71     }, \my $out) or $context->error($tt->error); 
    72     $out; 
    7364} 
    7465 
  • trunk/plagger/lib/Plagger/Plugin/Publish/MT.pm

    r792 r1173  
    3131sub feed { 
    3232    my ($self, $context, $args) = @_; 
    33     my $body = $context->templatize( 
    34         $self, 
     33    my $body = $self->templatize( 
    3534        $self->{conf}->{template} || 'mt.tt', 
    3635        { feed => $args->{feed} } 
  • trunk/plagger/lib/Plagger/Plugin/Publish/MTWidget.pm

    r387 r1173  
    3939    my $blog_id = $self->conf->{blog_id} || 1; 
    4040    my $title = $self->conf->{title} || $args->{feed}->title; 
    41     my $body  = $self->templatize($context, $args); 
     41    my $body  = $self->templatize('mt_widget.tt', $args); 
    4242 
    4343    my $trimed_title = substr($title, 0, 10); 
     
    5959    $tmpl->text($body); 
    6060    $tmpl->save or $context->error($tmpl->errstr); 
    61 } 
    62  
    63 sub templatize { 
    64     my($self, $context, $args) = @_; 
    65  
    66     my $tt = $context->template(); 
    67     $tt->process('mt_widget.tt', $args, \my $out) 
    68         or $context->error($tt->error); 
    69  
    70     $out; 
    7161} 
    7262 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Maildir.pm

    r1005 r1173  
    6767     $feed_title =~ tr/,//d; 
    6868  my $subject    = $entry->title || '(no-title)'; 
    69   my $body       = $self->templatize($context, $args); 
     69  my $body       = $self->templatize('mail.tt', $args); 
    7070     $body       = encode("utf-8", $body); 
    7171  my $from       = $cfg->{mailfrom} || 'plagger@localhost'; 
     
    159159} 
    160160 
    161 sub templatize { 
    162   my ($self, $context, $args) = @_; 
    163   my $tt = $context->template(); 
    164 #  $tt->process( 'gmail_notify.tt', { 
    165   $tt->process( 'mail.tt', { 
    166     entry => $args->{entry}, 
    167     feed  => $args->{feed}, 
    168   }, \my $out ) or $context->error($tt->error); 
    169   $out; 
    170 } 
    171  
    172161sub enclosure_id { 
    173162  my($self, $enclosure) = @_; 
  • trunk/plagger/lib/Plagger/Plugin/Publish/OPML.pm

    r316 r1173  
    1717    $context->register_hook( 
    1818        $self, 
    19         'publish.feed' => \&feed, 
    2019        'publish.finalize' => \&finalize, 
    2120    ); 
    2221} 
    2322 
    24 sub feed { 
    25     my($self, $context, $args) = @_; 
    26     unless ($args->{feed}->type =~ /^smartfeed:/) { 
    27         push @{ $self->{_feeds} }, $args->{feed}; 
    28     } 
    29 } 
    30  
    3123sub finalize { 
    3224    my($self, $context, $args) = @_; 
    33     my $out = $context->templatize($self, 'opml.tt', { 
    34         feeds => $self->{_feeds}, 
     25 
     26    my $out = $self->templatize('opml.tt', { 
     27        feeds => [ $context->subscription->feeds ], 
    3528        now   => Plagger::Date->now, 
     29        conf  => $self->conf, 
    3630    }); 
    3731 
     
    5852      filename: /path/to/subscription.opml 
    5953 
     54=head1 DESCRIPTION 
     55 
     56This plugin publishes OPML file using feeds fonnd in the subscription. 
     57 
     58=head1 CONFIG 
     59 
     60=over 4 
     61 
     62=item filename 
     63 
     64Filename to save the OPML file. Required. 
     65 
     66=item title 
     67 
     68Title to be used as OPML head. Optional and defaults to I<Plagger Subscriptions>. 
     69 
     70=back 
     71 
    6072=head1 AUTHOR 
    6173 
  • trunk/plagger/lib/Plagger/Plugin/Publish/PDF.pm

    r163 r1173  
    2323 
    2424    my $file = File::Spec->catfile($dir, $args->{feed}->id . ".pdf"); 
    25     my $body = $self->templatize($context, $args); 
     25    my $body = $self->templatize('gmail_notify.tt', $args); 
    2626    utf8::encode($body); 
    2727 
     
    3232    $pdf->convert(); 
    3333    $pdf->write_file($file); 
    34 } 
    35  
    36 sub templatize { 
    37     my($self, $context, $args) = @_; 
    38  
    39     # HACK: share the template with Gmail ... for now 
    40     my $tt = $context->template(); 
    41     $tt->process('gmail_notify.tt', $args, \my $out) 
    42         or $context->error($tt->error); 
    43  
    44     $out; 
    4534} 
    4635 
  • trunk/plagger/lib/Plagger/Plugin/Publish/PSP.pm

    r316 r1173  
    2323    my($self, $context) = @_; 
    2424 
    25     my $body = $self->templatize($context, $self->{__feeds}); 
     25    my $body = $self->templatize('psp.tt', { feeds => $self->{__feeds} }); 
    2626    my $file = $self->conf->{output_file}; 
    2727 
     
    3232} 
    3333 
    34 sub templatize { 
    35     my($self, $context, $feeds) = @_; 
    36     my $tt = $context->template(); 
    37     $tt->process('psp.tt', { 
    38         feeds => $feeds, 
    39     }, \my $out) or $context->error($tt->error); 
    40     $out; 
    41 } 
    42  
    43341; 
    4435 
  • trunk/plagger/lib/Plagger/Plugin/Publish/PalmDoc.pm

    r800 r1173  
    5151    my($self, $entry, $context) = @_; 
    5252     
    53     my $entry_text = $context->templatize($self, 'palmdoc.tt', { 
     53    my $entry_text = $self->templatize('palmdoc.tt', { 
    5454        entry => $entry, 
    5555        now   => Plagger::Date->now, 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Planet.pm

    r987 r1173  
    55use File::Copy::Recursive qw[rcopy]; 
    66use File::Spec; 
    7 #use HTML::Tidy; 
    8 use HTML::Scrubber; 
     7use URI; 
    98 
    10 our $VERSION = '0.01'; 
     9our $VERSION = '0.02'; 
    1110 
    1211sub register { 
     
    2019sub add_feed { 
    2120    my($self, $context, $args) = @_; 
     21 
    2222    my $feed = $args->{feed}; 
    2323    if ($feed->id ne 'smartfeed:all') { 
     
    2525    } 
    2626 
    27     $self->_sanitize_entries( 
    28         $context, 
    29         $feed, 
    30 #        HTML::Tidy->new, 
    31         undef, 
    32         HTML::Scrubber->new( 
    33             rules => [ 
    34                 style => 0, 
    35                 script => 0, 
    36             ], 
    37             default => [ 1, { '*' => 1, style => 0 } ], 
    38         ), 
    39     ); 
     27    my $theme = $self->conf->{theme} || $self->conf->{skin} || 'default'; # 'skin' as backward compatible 
     28    my $file = File::Spec->catfile($theme, 'template', 'index.tt'); 
     29 
     30    my $stash = $self->build_stash; 
     31 
     32    my $vars = { 
     33        %$stash, 
     34        feed    => $feed, 
     35        entries => [ grep is_http($_->link), $feed->entries ], 
     36        members => [ $context->subscription->feeds ], 
     37    }; 
    4038 
    4139    $self->_write_index( 
    4240        $context, 
    43         $self->templatize($context, $feed), 
    44         $self->conf->{dir} . '/index.html'
     41        $self->templatize($file, $vars), 
     42        File::Spec->catfile($self->conf->{dir}, 'index.html')
    4543    ); 
    46      
    47     $self->_apply_skin
     44 
     45    $self->_apply_theme
    4846        $context, 
    49         $self->conf->{skin}
     47        $theme
    5048        $self->conf->{dir}, 
    5149    ); 
    5250} 
    5351 
    54  
    55 sub templatize { 
    56     my($self, $context, $feed) = @_; 
    57     my $tt   = $context->template(); 
    58     my $skin = $self->conf->{skin} || 'default'; 
    59  
    60     $tt->process("$skin/template/index.tt", { 
    61         %{ $self->conf->{template} }, 
    62         feed  => $feed, 
    63         members => [ $context->subscription->feeds ], 
    64         context => $context, 
    65     }, \my $out) or $context->error($tt->error); 
    66     $out; 
     52sub is_http { 
     53    my $uri = URI->new(shift); 
     54    my $scheme = $uri->scheme or return; 
     55    $scheme eq 'http' or $scheme eq 'https'; 
    6756} 
    6857 
    69 sub _sanitize_entries { 
    70     my ($self, $context, $feed, $tidy, $scrubber) = @_; 
    71      
    72     foreach my $entry ($feed->entries) { 
    73 #        $entry->{body} = $tidy->clean($entry->{body}); 
    74         $entry->{body} = $scrubber->scrub($entry->{body}) if $scrubber; 
     58sub build_stash { 
     59    my $self = shift; 
     60 
     61    my $stash = $self->conf->{template} || {}; 
     62 
     63    # backward compatible for non Bundle::Planet users 
     64    $stash->{url}->{base} ||= ''; 
     65    $stash->{url}->{atom} ||= "$stash->{url}->{base}/smartfeed_all.atom"; 
     66    $stash->{url}->{rss}  ||= "$stash->{url}->{base}/smartfeed_all.rss"; 
     67 
     68    # make style_url as absolute URIs 
     69    if (my $stylesheet = $stash->{style_url} and $stash->{url}->{base}) { 
     70        $stylesheet = [ $stylesheet ] unless ref $stylesheet; 
     71        $stash->{style_url} = [ map URI->new_abs($_, $stash->{url}->{base})->as_string, @$stylesheet ]; 
    7572    } 
     73 
     74    $stash; 
    7675} 
    7776 
     
    7978    my ($self, $context, $index, $file) = @_; 
    8079 
     80    $context->log(info => "Save Planet HTML to $file"); 
    8181    open my $out, ">:utf8", $file or $context->error("$file: $!"); 
    8282    print $out $index; 
     
    8484} 
    8585 
    86 sub _apply_skin
    87     my ($self, $context, $skin_name, $output_dir) = @_; 
     86sub _apply_theme
     87    my ($self, $context, $theme_name, $output_dir) = @_; 
    8888    $context->log(debug => "Assets Directory: " . $self->assets_dir); 
    8989 
    90     my $static = File::Spec->catfile($self->assets_dir, $skin_name, 'static'); 
     90    my $static = File::Spec->catfile($self->assets_dir, $theme_name, 'static'); 
    9191    if (-e $static) { 
    9292        rcopy($static, $output_dir) or $context->log(error => "rcopy: $!"); 
     
    96961; 
    9797 
     98__END__ 
     99 
     100=head1 NAME 
     101 
     102Plagger::Plugin::Publish::Planet - Planet XHTML publisher 
     103 
     104=head1 SYNOPSIS 
     105 
     106  - module: Publish::Planet 
     107    rule: 
     108      expression: $args->{feed}->id eq 'smartfeed:all' 
     109    config: 
     110      dir: /path/to/htdocs 
     111      theme: sixapart-std 
     112 
     113=head1 DESCRIPTION 
     114 
     115This plugin generates XHTML out of aggregated feeds suitable to put on 
     116the web as "Blog aggregator" like Python Planet does. 
     117 
     118=head1 CONFIG 
     119 
     120=over 4 
     121 
     122=item dir 
     123 
     124Directory to save output XHTML and CSS files in. Required. 
     125 
     126=item theme 
     127 
     128Name of "theme" to use as an XHTML template. Available options are 
     129I<default> and I<sixapart-std>. Optional and defaults to 'default'. 
     130 
     131=item template 
     132 
     133Stash variables to pass to template. Example: 
     134 
     135  template: 
     136    style_url: http://example.com/foo.css 
     137    url: 
     138      base: http://example.org/planet/ 
     139 
     140=over 8 
     141 
     142=item style_url 
     143 
     144  style_url: http://www.example.com/style.css 
     145 
     146URL of stylesheet to use in templates. You can pass multiple URLs by passing an array. Optional. 
     147 
     148=item url 
     149 
     150  url: 
     151    base: http://example.com/planet/ 
     152 
     153URL to be used as a Planet base. This URL is used as a base URL for 
     154RSS/Atom feeds and stylesheet if they're relative.. Optional. 
     155 
     156=back 
     157 
     158=back 
     159 
     160=head1 EXAMPLES 
     161 
     162You can see a couple of Publish::Planet powered sites. 
     163 
     164L<http://plagger.org/planet/> 
     165 
     166L<http://planet.yapcchicago.org/> 
     167 
     168=head1 AUTHOR 
     169 
     170Casey West 
     171 
     172Tatsuhiko Miyagawa 
     173 
     174=head1 SEE ALSO 
     175 
     176L<Plagger>, L<http://plagger.org/planet/>, L<http://planetplanet.org/> 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Takahashi.pm

    r445 r1173  
    2626    $context->log(info => "writing output to $path"); 
    2727 
    28     my $body = $context->templatize($self, 'takahashi.tt', $args); 
     28    my $body = $self->templatize('takahashi.tt', $args); 
    2929    open my $out, ">:utf8", $path or $context->error("$path: $!"); 
    3030    print $out $body; 
  • trunk/plagger/lib/Plagger/Plugin/Search/Namazu.pm

    r126 r1173  
    2727        $context->log(info => "writing output to $path"); 
    2828 
    29         my $body = $self->templatize($context, { entry => $entry, feed => $args->{feed} }); 
     29        my $body = $self->templatize('namazu.tt', { entry => $entry, feed => $args->{feed} }); 
    3030 
    3131        # save output as EUC-JP so Namazu can easily handle 
     
    4040        utime $time, $time, $path; 
    4141    } 
    42 } 
    43  
    44 sub templatize { 
    45     my($self, $context, $vars) = @_; 
    46  
    47     my $tt = $context->template(); 
    48     $tt->process('namazu.tt', $vars, \my $out) 
    49         or $context->error($tt->error); 
    50  
    51     $out; 
    5242} 
    5343 
  • trunk/plagger/lib/Plagger/Plugin/Search/Spotlight.pm

    r669 r1173  
    3636    $context->log(info => "writing output to $path"); 
    3737 
    38     my $body = $self->templatize($context, $entry); 
     38    my $body = $self->templatize('spotlight.tt', { entry => $entry }); 
    3939 
    4040    open my $out, ">:utf8", $path or $context->error("$path: $!"); 
     
    6666        ) == 0 or Plagger->context->error("$path: $!"); 
    6767    } 
    68 } 
    69  
    70 sub templatize { 
    71     my($self, $context, $entry) = @_; 
    72     my $tt = $context->template(); 
    73     $tt->process('spotlight.tt', { 
    74         entry => $entry, 
    75     }, \my $out) or $context->error($tt->error); 
    76     $out; 
    7768} 
    7869 
  • trunk/plagger/lib/Plagger/Plugin/SmartFeed/All.pm

    r367 r1173  
    1010    $feed->id( $self->conf->{id} || ('smartfeed:all') ); 
    1111    $feed->title( $self->conf->{title} || "All Entries " ); 
     12    $feed->link( $self->conf->{link} ); 
    1213 
    1314    $self->{feed} = $feed; 
  • trunk/plagger/lib/Plagger/Plugin/Subscription/OPML.pm

    r681 r1173  
    5151 
    5252    if (delete $outline->{opmlvalue}) { 
    53         my $title = delete $outline->{title}
     53        my $title = delete $outline->{title} || delete $outline->{text}
    5454        push @$containers, $title if $title ne 'Subscriptions'; 
    5555        for my $channel (values %$outline) { 
     
    6161        $feed->url($outline->{xmlUrl}); 
    6262        $feed->link($outline->{htmlUrl}); 
    63         $feed->title($outline->{title}); 
     63        $feed->title($outline->{title} || $outline->{text}); 
    6464        $feed->tags($containers); 
    6565        $context->subscription->add($feed); 
  • trunk/plagger/lib/Plagger/Plugin/Subscription/Planet.pm

    r984 r1173  
    66use URI::Escape; 
    77 
    8 my @sites = ( 
    9     'http://www.blogpulse.com/rss?query=%s&sort=date&operator=and', 
    10     'http://www.feedster.jp/search/lang/all/%s', 
    11     'http://blogsearch.google.com/blogsearch_feeds?hl=en&q=%s&scoring=d&ie=utf-8&num=100&output=rss', 
    12     'http://blog-search.yahoo.co.jp/rss?p=%s:euc-jp', 
    13     'http://blog.goo.ne.jp/search/search.php?status=select&tg=all&st=time&dc=10&dp=all&bu=&ts=all&MT=%s:euc-jp&da=all&rss=1', 
    14     'http://www.namaan.net/rss?namaan=NAMA&ty=5&query=%s', 
    15     'http://bulkfeeds.net/app/search2.rdf?q=%s', 
    16     'http://rss.sf.livedoor.com/search?q=%s&sf=update_date&start=0', 
    17     'http://b.hatena.ne.jp/t/%s?mode=rss&sort=eid&threshold=1', 
    18     'http://d.hatena.ne.jp/keyworddiary/%s?mode=rss', 
    19     'http://feeds.technorati.com/feed/posts/tag/%s', 
    20     'http://bloglines.com/search?q=%s&ql=any&s=f&pop=l&news=m&n=100&format=rss', 
    21 ); 
    22  
    238sub load { 
    249    my($self, $context) = @_; 
     
    2712       $keyword = [ $keyword ] unless ref $keyword; 
    2813 
     14    my $lang = $self->conf->{lang} || 'default'; 
     15    $lang = [ $lang ] unless ref $lang; 
     16 
     17    $self->load_assets( 
     18        File::Find::Rule->file->name([ map "$_.yaml", @$lang ]), 
     19        sub { 
     20            my($file) = @_; 
     21            my $data = YAML::LoadFile($file); 
     22            push @{ $self->{engines} }, @{ $data->{engines} }; 
     23        }, 
     24    ); 
     25 
    2926    for my $kw (@$keyword) { 
    30         for my $site (@sites) { 
    31             my $site_url = $site; 
    32             $site_url =~ s{%s(?::([\w\-]+))?}{ 
    33                 my $query = $kw; 
    34                 if ($1) { 
    35                     Encode::from_to($query, "utf-8" => $1); 
    36                 } 
    37                 URI::Escape::uri_escape($query); 
    38             }eg; 
    39             push @{$self->conf->{feed}}, { url => $site_url } 
     27        for my $site (@{ $self->{engines} }) { 
     28            my $site_url = $site; # copy 
     29 
     30            # use eval ... die to skip if there's no url/keyword 
     31            eval { 
     32                $site_url =~ s{{([\w\-\:]+)}}{ 
     33                    my($key, $encoding) = split /:/, $1; 
     34 
     35                    my $data = $self->conf->{$key} or die "$key is not there"; 
     36                    if ($encoding && $encoding ne 'utf-8') { 
     37                        Encode::from_to($data, "utf-8" => $encoding); 
     38                    } 
     39 
     40                    my $chunk = URI::Escape::uri_escape($data); 
     41                    $chunk =~ s/%20/+/g; # hack 
     42                    $chunk; 
     43                }eg; 
     44                push @{$self->conf->{feed}}, { url => $site_url } 
     45            }; 
    4046        } 
    4147    } 
     
    4551 
    46521; 
     53 
     54__END__ 
     55 
     56=head1 NAME 
     57 
     58Plagger::Plugin::Subscription::Planet - Ego search subscription 
     59 
     60=head1 SYNOPSIS 
     61 
     62  - module: Subscription::Planet 
     63    config: 
     64      keyword: Plagger 
     65      lang: en 
     66 
     67=head1 DESCRIPTION 
     68 
     69This plugin gives a handy way to subscribe to dozens of feed / web 
     70search engine results by just supplying keywords. 
     71 
     72=head1 CONFIG 
     73 
     74=over 4 
     75 
     76=item keyword 
     77 
     78The keyword to use as a query in web search engines. Required. 
     79 
     80=item lang 
     81 
     82Language code to either 1) specify list of search engines or 2) pass 
     83to search query.  Optional. 
     84 
     85For example, technorati.jp will be added if you use I<ja>, while 
     86technorati.com will be if you use I<en>. Default is to search 
     87everything. 
     88 
     89=back 
     90 
     91=head1 EXAMPLES 
     92 
     93  # search "Plagger" on default engines 
     94  - module: Subscription::Planet 
     95    config: 
     96      keyword: Plagger 
     97 
     98  # search "Pokemon" on Japanese search engines 
     99  - module: Subscription::Planet 
     100    config: 
     101      keyword: Pokemon 
     102      lang: ja 
     103 
     104  # search "Plagger" and pages linking to "http://plagger.org/" 
     105  - module: Subscription::Planet 
     106    config: 
     107      keyword: Plagger 
     108      url: http://plagger.org/ 
     109 
     110=head1 AUTHOR 
     111 
     112youpy 
     113 
     114Tatsuhiko Miyagawa 
     115 
     116=head1 SEE ALSO 
     117 
     118L<Plagger> 
     119 
     120=cut 
  • trunk/plagger/lib/Plagger/Rule/Fresh.pm

    r444 r1173  
    2424        $self->{timestamp} = $mtime || 0; 
    2525    } else { 
    26         $self->{duration} ||= 120; 
    27         $self->{timestamp}  = time - ($self->{duration}) * 60; 
     26        eval { 
     27            $self->{duration}   = $self->init_duration(); 
     28            $self->{timestamp}  = time - $self->{duration}; 
     29        }; 
     30        if ($@) { 
     31            Plagger->context->error("Parse duration error: $@"); 
     32        } 
    2833    } 
    2934 
     
    3136} 
    3237 
     38sub init_duration { 
     39    my $self = shift; 
     40 
     41    my $duration = $self->{duration} || 120; # minutes 
     42 
     43    if ($duration =~ /^\d+$/) { 
     44        # if it's all digit, the unit is minutes 
     45        return $duration * 60; 
     46    } 
     47 
     48    eval { require Time::Duration::Parse }; 
     49    if ($@) { 
     50        Plagger->context->error("You need to install Time::Duration::Parse to use human readable timespec"); 
     51    } 
     52 
     53    Time::Duration::Parse::parse_duration($self->{duration}); 
     54} 
     55 
    3356sub id { 
    3457    my $self = shift; 
    35     return "fresh:$self->{duration}min"; 
     58    return "fresh:$self->{duration}sec"; 
    3659} 
    3760 
     
    4972    my $self = shift; 
    5073    eval { require Time::Duration }; 
    51     return $@ ? "$self->{duration} minutes" 
    52               : Time::Duration::duration(60 * $self->{duration}); 
     74    return $@ ? "$self->{duration} seconds" 
     75              : Time::Duration::duration($self->{duration}); 
    5376} 
    5477 
     
    113136same C<duration> variable with the job interval. 
    114137 
    115 It defaults to I<120>, which means 2 hours. 
     138If the supplied value contains only digit, it's parsed as minutes. You 
     139can write in a human readable format like: 
     140 
     141  duration: 4 hours 
     142 
     143and this module DWIMs. It defaults to I<120>, which means 2 hours. 
    116144 
    117145=item C<mtime> 
  • trunk/plagger/lib/Plagger/UserAgent.pm

    r843 r1173  
    2525    my($self, $url, $plugin, $opt) = @_; 
    2626 
    27     URI::Fetch->fetch($url, 
     27    my $res = URI::Fetch->fetch($url, 
    2828        UserAgent => $self, 
    2929        $plugin ? (Cache => $plugin->cache) : (), 
     
    3131        ($opt ? %$opt : ()), 
    3232    ); 
     33 
     34    if ($res && $url =~ m!^file://!) { 
     35        $res->content_type( Plagger::Util::mime_type_of(URI->new($url)) ); 
     36    } 
     37 
     38    $res; 
    3339} 
    3440 
  • trunk/plagger/t/core/cookies.t

    r822 r1173  
    11use strict; 
    2 use Test::More tests => 6; 
    32use FindBin; 
    43 
    5 use Plagger; 
     4use t::TestPlagger; 
    65 
    7 # cookies: filename 
    8 Plagger->bootstrap(config => \<<CONFIG); 
    9 global: 
    10   log: 
    11     level: error 
    12   user_agent: 
    13     cookies: $FindBin::Bin/cookies.txt 
    14 plugins: 
    15   - module: Test::Cookies 
    16 CONFIG 
     6test_requires('HTTP::Cookies::Mozilla'); 
    177 
    18 # cookies: hash 
    19 Plagger->bootstrap(config => \<<CONFIG); 
    20 global: 
    21   log: 
    22     level: error 
    23   user_agent: 
    24     cookies: 
    25       type: Mozilla 
    26       file: $FindBin::Bin/cookies.txt 
    27 plugins: 
    28   - module: Test::Cookies 
    29 CONFIG 
     8plan tests => 6; 
     9run_eval_expected; 
    3010 
    3111package Plagger::Plugin::Test::Cookies; 
     
    5636} 
    5737 
     38__END__ 
     39 
     40=== cookies: filename 
     41--- input config 
     42global: 
     43  log: 
     44    level: error 
     45  user_agent: 
     46    cookies: $FindBin::Bin/cookies.txt 
     47plugins: 
     48  - module: Test::Cookies 
     49--- expected 
     501 
     51 
     52=== cookies: hash 
     53--- input config 
     54global: 
     55  log: 
     56    level: error 
     57  user_agent: 
     58    cookies: 
     59      type: Mozilla 
     60      file: $FindBin::Bin/cookies.txt 
     61plugins: 
     62  - module: Test::Cookies 
     63--- expected 
     641 
  • trunk/plagger/t/core/hatenafotolife.t

    r865 r1173  
    11use strict; 
    2 use Test::More tests => 3; 
    32use FindBin; 
    43 
    5 use Plagger; 
     4use t::TestPlagger; 
    65 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     6plan tests => 3; 
     7run_eval_expected; 
     8 
     9__END__ 
     10 
     11=== Hatena Fotolife 
     12--- input config 
    813global: 
    914  log: 
     
    1318    config: 
    1419      feed: 
    15         - file://$FindBin::Bin/hatenafotolife.rdf 
    16   - module: Test::Hatena 
    17 CONFIG 
     20        - file://$FindBin::Bin/../samples/hatenafotolife.rdf 
    1821 
    19 package Plagger::Plugin::Test::Hatena; 
     22--- expected 
     23my @feeds = $context->update->feeds; 
     24is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228.gif' ); 
     25is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/gif' ); 
     26is( ($feeds[0]->entries)[0]->icon->{url}, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228_m.jpg' ); 
    2027 
    21 use base qw( Plagger::Plugin ); 
    22  
    23 sub register { 
    24     my($self, $context) = @_; 
    25  
    26     $context->register_hook( 
    27         $self, 
    28         'aggregator.finalize' => \&test, 
    29     ); 
    30 } 
    31  
    32 sub test { 
    33     my($self, $context, $args) = @_; 
    34  
    35     my @feeds = $context->update->feeds; 
    36  
    37     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228.gif' ); 
    38     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/gif' ); 
    39     ::is( ($feeds[0]->entries)[0]->icon->{url}, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228_m.jpg' ); 
    40 } 
    41  
  • trunk/plagger/t/core/mrss.t

    r849 r1173  
    11use strict; 
    2 use Test::More tests => 6; 
    32use FindBin; 
    43 
    5 use Plagger; 
     4use t::TestPlagger; 
    65 
    7 # cookies: filename 
    8 Plagger->bootstrap(config => \<<CONFIG); 
     6plan tests => 6; 
     7run_eval_expected; 
     8 
     9__END__ 
     10 
     11=== Media RSS 
     12--- input config  
    913global: 
    1014  log: 
     
    1418    config: 
    1519      feed: 
    16         - file://$FindBin::Bin/monkey.rss 
    17         - file://$FindBin::Bin/googlevideo.xml 
    18   - module: Test::MediaRSS 
    19 CONFIG 
     20        - file://$FindBin::Bin/../samples/monkey.rss 
     21        - file://$FindBin::Bin/../samples/googlevideo.xml 
     22--- expected 
     23my @feeds = $context->update->feeds; 
    2024 
    21 package Plagger::Plugin::Test::MediaRSS; 
    22 use base qw( Plagger::Plugin ); 
     25is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf' ); 
     26is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'application/x-shockwave-flash' ); 
     27is( ($feeds[0]->entries)[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg' ); 
     28is( ($feeds[1]->entries)[0]->enclosures->[0]->type, 'video/mp4' ); 
     29is( ($feeds[1]->entries)[0]->enclosures->[1]->type, 'video/x-flv' ); 
     30is( ($feeds[1]->entries)[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE' ); 
    2331 
    24 sub register { 
    25     my($self, $context) = @_; 
    2632 
    27     $context->register_hook( 
    28         $self, 
    29         'aggregator.finalize' => \&test, 
    30     ); 
    31 } 
    32  
    33 sub test { 
    34     my($self, $context, $args) = @_; 
    35  
    36     my @feeds = $context->update->feeds; 
    37  
    38     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf' ); 
    39     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'application/x-shockwave-flash' ); 
    40     ::is( ($feeds[0]->entries)[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg' ); 
    41  
    42     ::is( ($feeds[1]->entries)[0]->enclosures->[0]->type, 'video/mp4' ); 
    43     ::is( ($feeds[1]->entries)[0]->enclosures->[1]->type, 'video/x-flv' ); 
    44  
    45     ::is( ($feeds[1]->entries)[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE' ); 
    46 } 
    47  
  • trunk/plagger/t/core/photocast.t

    r866 r1173  
    11use strict; 
    2 use Test::More tests => 3; 
    32use FindBin; 
     3use t::TestPlagger; 
    44 
    5 use Plagger
     5test_requires('Date::Parse')
    66 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     7plan tests => 3; 
     8run_eval_expected; 
     9 
     10__END__ 
     11 
     12=== Photocast 
     13--- input config 
    814global: 
    915  log: 
     
    1319    config: 
    1420      feed: 
    15         - file://$FindBin::Bin/photocast.rss 
     21        - file://$FindBin::Bin/../samples/photocast.rss 
    1622  # OMG Apple Photocast has invalida pubDate formats ... fix it. 
    1723  - module: Filter::RSSLiberalDateTime 
    18   - module: Test::Photocast 
    19 CONFIG 
     24--- expected 
     25my @feeds = $context->update->feeds; 
     26is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg' ); 
     27is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/jpeg' ); 
     28is( ($feeds[0]->entries)[0]->icon->{url}, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg?transform=medium' ); 
    2029 
    21 package Plagger::Plugin::Test::Photocast; 
    22 use base qw( Plagger::Plugin ); 
    2330 
    24 sub register { 
    25     my($self, $context) = @_; 
    26  
    27     $context->register_hook( 
    28         $self, 
    29         'aggregator.finalize' => \&test, 
    30     ); 
    31 } 
    32  
    33 sub test { 
    34     my($self, $context, $args) = @_; 
    35  
    36     my @feeds = $context->update->feeds; 
    37  
    38     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg' ); 
    39     ::is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/jpeg' ); 
    40     ::is( ($feeds[0]->entries)[0]->icon->{url}, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg?transform=medium' ); 
    41 } 
    42  
  • trunk/plagger/t/plugins/CustomFeed-GoogleNews/test.t

    r804 r1173  
    11use strict; 
    2 use Test::More tests => 2
     2use t::TestPlagger
    33 
    4 use Plagger
     4test_requires_network
    55 
    6 Plagger->bootstrap(config => \<<'CONFIG'); 
     6plan 'no_plan'; 
     7 
     8run_eval_expected; 
     9 
     10__END__ 
     11 
     12=== Test Google News live 
     13--- input config 
    714global: 
    815  log: 
     
    1623 
    1724  - module: CustomFeed::GoogleNews 
    18   - module: Filter::Test 
    19 CONFIG 
     25--- expected 
     26is $context->update->feeds->[0]->link, 'http://news.google.com/news?ned=jp&rec=0&topic=s'; 
     27ok $context->update->feeds->[0]->count; 
    2028 
    21 package Plagger::Plugin::Filter::Test; 
    22 use base qw( Plagger::Plugin ); 
    23  
    24 sub register { 
    25     my($self, $context) = @_; 
    26     $context->register_hook( 
    27         $self, 
    28         'update.feed.fixup' => \&feed, 
    29     ); 
    30 } 
    31  
    32 sub feed { 
    33     my($self, $context, $args) = @_; 
    34     ::ok $args->{feed}->count; 
    35 } 
  • trunk/plagger/t/plugins/Filter-FeedBurnerPermalink/feedburner.t

    r830 r1173  
    11use strict; 
    2 use Test::More tests => 1
     2use t::TestPlagger
    33 
    4 use Plagger; 
     4test_requires_network; 
     5plan 'no_plan'; 
    56 
    67my $log; 
    7 { local $SIG{__WARN__} = sub { $log .= "@_" }; 
    8   Plagger->bootstrap(config => \<<'CONFIG'); 
     8$SIG{__WARN__} = sub { $log .= "@_" }; 
     9sub log { $log } 
     10 
     11run_eval_expected; 
     12 
     13__END__ 
     14 
     15=== sixapart.com feed 
     16--- input config log 
    917global: 
    1018  log: 
     
    1725 
    1826  - module: Filter::FeedBurnerPermalink 
    19 CONFIG 
    20 
    21  
     27--- expected 
     28my $log = $block->input; 
    2229like $log, qr/Permalink rewritten to/; 
  • trunk/plagger/t/plugins/Filter-FetchEnclosure/fetch.t

    r848 r1173  
    22use FindBin; 
    33use File::Path qw(rmtree); 
    4 use Test::More tests => 2; 
    54 
    6 use Plagger; 
    7 use MIME::Parser; 
    8 use MIME::Lite; 
     5use t::TestPlagger; 
    96 
    10 my $tmpdir = "$FindBin::Bin/tmp"; 
     7BEGIN { 
     8    test_requires('MIME::Parser'); 
     9    test_requires('MIME::Lite'); 
     10    test_requires_network; 
     11
     12 
     13plan tests => 2; 
     14 
     15our $tmpdir = "$FindBin::Bin/tmp"; 
     16 
     17my $entity; 
    1118 
    1219no warnings 'redefine'; 
     
    1623    my $parser = MIME::Parser->new; 
    1724    $parser->output_to_core(1); 
    18     my $entity = $parser->parse_data($mime->as_string); 
    19  
    20     ok $entity->parts(0)->bodyhandle->as_string =~ m!<img src="cid:(.*?)" />!; 
    21     is $entity->parts(1)->head->get('Content-Id'), "<$1>\n"; 
     25    $entity = $parser->parse_data($mime->as_string); 
    2226}; 
    2327 
    24 Plagger->bootstrap(config => \<<"CONFIG"); 
     28sub entity { $entity } 
     29 
     30run_eval_expected; 
     31 
     32END { rmtree $tmpdir if $tmpdir } 
     33 
     34__END__ 
     35 
     36=== test via Gmail sender 
     37--- input config entity 
    2538global: 
    2639  assets_path: $FindBin::Bin/../../../assets 
     
    4154  - module: Filter::FetchEnclosure 
    4255    config: 
    43       dir: $tmpdir 
     56      dir: $main::tmpdir 
    4457 
    4558  - module: Publish::Gmail 
    4659    config: 
    47       mailto: fooba\@localhost 
     60      mailto: foobar@localhost 
    4861      attach_enclosures: 1 
    49 CONFIG 
    50  
    51 END { rmtree $tmpdir } 
     62--- expected 
     63my $entity = $block->input; 
     64ok $entity->parts(0)->bodyhandle->as_string =~ m!<img src="cid:(.*?)" />!; 
     65is $entity->parts(1)->head->get('Content-Id'), "<$1>\n"; 
  • trunk/plagger/t/plugins/Filter-FindEnclosures/object.t

    r850 r1173  
    11use strict; 
    22use FindBin; 
    3 use Test::More tests => 2
     3use t::TestPlagger
    44 
    5 use Plagger; 
     5plan tests => 2; 
     6run_eval_expected; 
    67 
    7 my $log; 
    8 { local $SIG{__WARN__} = sub { $log .=  "@_" }; 
    9   Plagger->bootstrap(config => \<<"CONFIG"); 
     8__END__ 
     9 
     10=== Test 1 
     11--- input config 
    1012global: 
    1113  assets_path: $FindBin::Bin/../../../assets 
    1214  log: 
    13     level: debug 
     15    level: error 
    1416plugins: 
    1517  - module: CustomFeed::Debug 
     
    3537 
    3638  - module: Filter::FindEnclosures 
    37 CONFIG 
    38 
    39  
    40 like $log, qr!Found enclosure http://www\.youtube\.com/v/nqAWmQ8cdWw!; 
    41 like $log, qr!Found enclosure https://hatena\.g\.hatena\.ne\.jp/files/hatena/b9f904875fcd5333\.flv!; 
     39--- expected 
     40is $context->update->feeds->[0]->entries->[0]->enclosure->url, 'http://www.youtube.com/v/nqAWmQ8cdWw'; 
     41is $context->update->feeds->[0]->entries->[1]->enclosure->url, 'https://hatena.g.hatena.ne.jp/files/hatena/b9f904875fcd5333.flv'; 
  • trunk/plagger/t/plugins/Notify-UpdatePing/ping.t

    r797 r1173  
    22use FindBin; 
    33use File::Spec; 
    4 use Test::More tests => 3
     4use t::TestPlagger
    55 
    6 use Plagger; 
     6test_requires('XMLRPC::Lite'); 
     7test_requires_network; 
    78 
    8 no warnings 'redefine'; 
     9my $rpc; 
     10 
     11no warnings 'redefine', 'once'; 
    912local *XMLRPC::Lite::call = sub { 
    1013    my($self, $method, $name, $url) = @_; 
    11     is $method, 'weblogUpdates.ping'; 
    12     is $name->value, 'blog.bulknews.net'; 
    13     is $url, 'http://blog.bulknews.net/mt/'; 
     14    $rpc = { 
     15        method => $method, 
     16        name   => $name, 
     17        url    => $url, 
     18    }; 
    1419}; 
    1520 
    16 Plagger->bootstrap(config => \<<CONFIG); 
     21sub rpc { $rpc } 
     22 
     23plan tests => 3; 
     24run_eval_expected; 
     25 
     26__END__ 
     27 
     28=== Test 1 
     29--- input config rpc 
    1730global: 
    1831  log: 
     
    2639    config: 
    2740      url: http://localhost/ping 
    28 CONFIG 
     41--- expected 
     42my $rpc = $block->input; 
     43is $rpc->{method}, 'weblogUpdates.ping'; 
     44is $rpc->{name}->value, 'blog.bulknews.net'; 
     45is $rpc->{url}, 'http://blog.bulknews.net/mt/'; 
    2946 
     47 
  • trunk/plagger/t/plugins/Subscription-ConfigINI/subscription.t

    r833 r1173  
    11use strict; 
    2 use FindBin; 
    3 use File::Spec; 
    4 use Test::More tests => 1; 
     2use t::TestPlagger; 
    53 
    6 use Plagger; 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     4test_requires('Config::INI::Simple'); 
     5 
     6plan tests => 1; 
     7run_eval_expected; 
     8 
     9__END__ 
     10=== testing config.ini 
     11--- input config 
    812global: 
    913  log: 
     
    1317    config: 
    1418      path: $FindBin::Bin/config.ini 
    15   - module: Aggregator::Test 
    16 CONFIG 
     19  - module: Aggregator::Null 
     20--- expected 
     21my @feeds = map $_->url, $context->subscription->feeds; 
     22is_deeply( 
     23    \@feeds, 
     24    [ 'http://usefulinc.com/edd/blog/rss91', 
     25      'http://www.netsplit.com/blog/index.rss', 
     26      'http://www.gnome.org/~jdub/blog/?flav=rss', 
     27      'http://blog.clearairturbulence.org/?flav=rss', 
     28      'http://www.hadess.net/diary.rss' ], 
     29); 
    1730 
    18 package Plagger::Plugin::Aggregator::Test; 
    19 use base qw( Plagger::Plugin ); 
    20  
    21 sub register { 
    22     my($self, $context) = @_; 
    23     $context->register_hook( 
    24         $self, 
    25         'customfeed.handle' => \&load, 
    26         'aggregator.finalize' => \&test, 
    27     ); 
    28 } 
    29  
    30 sub load { 
    31     my($self, $context, $args) = @_; 
    32     push @{$self->{feeds}}, $args->{feed}->url; 
    33     return 1; 
    34 } 
    35  
    36 sub test { 
    37     my $self = shift; 
    38     ::is_deeply( 
    39         $self->{feeds}, 
    40         [ 'http://usefulinc.com/edd/blog/rss91', 
    41           'http://www.netsplit.com/blog/index.rss', 
    42           'http://www.gnome.org/~jdub/blog/?flav=rss', 
    43           'http://blog.clearairturbulence.org/?flav=rss', 
    44           'http://www.hadess.net/diary.rss' ], 
    45     ); 
    46 } 
  • trunk/plagger/t/plugins/Subscription-FOAF/subscription.t

    r852 r1173  
    11use strict; 
    22use FindBin; 
    3 use File::Spec; 
    4 use Test::More tests => 1; 
     3use t::TestPlagger; 
    54 
    6 use Plagger; 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     5test_requires('XML::FOAF'); 
     6plan tests => 1; 
     7run_eval_expected; 
     8 
     9__END__ 
     10=== Test FOAF 
     11--- input config 
    812global: 
    913  log: 
     
    1317    config: 
    1418      url: file:///$FindBin::Bin/sample.foaf 
    15   - module: Aggregator::Test 
    16 CONFIG 
    17  
    18 package Plagger::Plugin::Aggregator::Test; 
    19 use base qw( Plagger::Plugin ); 
    20  
    21 sub register { 
    22     my($self, $context) = @_; 
    23     $context->register_hook( 
    24         $self, 
    25         'customfeed.handle' => \&load, 
    26         'aggregator.finalize' => \&test, 
    27     ); 
    28 
    29  
    30 sub load { 
    31     my($self, $context, $args) = @_; 
    32     push @{$self->{feeds}}, $args->{feed}->url; 
    33     return 1; 
    34 
    35  
    36 sub test { 
    37     my $self = shift; 
    38     ::is_deeply( 
    39         $self->{feeds}, 
    40         [ 'http://usefulinc.com/edd/blog/rss91', 
    41           'http://www.netsplit.com/blog/index.rss', 
    42           'http://www.gnome.org/~jdub/blog/?flav=rss', 
    43           'http://blog.clearairturbulence.org/?flav=rss', 
    44           'http://www.hadess.net/diary.rss' ], 
    45     ); 
    46 
     19  - module: Aggregator::Null 
     20--- expected 
     21my @feeds = map $_->url, $context->subscription->feeds; 
     22is_deeply( 
     23    \@feeds, 
     24    [ 'http://usefulinc.com/edd/blog/rss91', 
     25      'http://www.netsplit.com/blog/index.rss', 
     26      'http://www.gnome.org/~jdub/blog/?flav=rss', 
     27      'http://blog.clearairturbulence.org/?flav=rss', 
     28      'http://www.hadess.net/diary.rss' ], 
     29); 
  • trunk/plagger/t/plugins/Subscription-Feed/subscription.t

    r861 r1173  
    11use strict; 
    22use FindBin; 
    3 use File::Spec; 
    4 use Test::More tests => 2; 
     3use t::TestPlagger; 
    54 
    6 use Plagger; 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     5plan tests => 2; 
     6run_eval_expected; 
     7 
     8__END__ 
     9 
     10=== Test one 
     11--- input config 
    812global: 
    913  log: 
     
    1317    config: 
    1418      url: file:///$FindBin::Bin/feed.xml 
    15   - module: Aggregator::Test 
    16 CONFIG 
     19  - module: Aggregator::Null 
     20--- expected 
     21is $context->subscription->feeds->[0]->url, "http://d.hatena.ne.jp/agw/20060526/1148633449#c"; 
     22is $context->subscription->feeds->[1]->url, "http://d.hatena.ne.jp/nirvash/20060517/1147836803#c"; 
    1723 
    18 package Plagger::Plugin::Aggregator::Test; 
    19 use base qw( Plagger::Plugin ); 
    2024 
    21 sub register { 
    22     my($self, $context) = @_; 
    23     $context->register_hook( 
    24         $self, 
    25         'customfeed.handle' => \&load, 
    26         'aggregator.finalize' => \&test, 
    27     ); 
    28 } 
    29  
    30 sub load { 
    31     my($self, $context, $args) = @_; 
    32     push @{$self->{feeds}}, $args->{feed}->url; 
    33     return 1; 
    34 } 
    35  
    36 sub test { 
    37     my($self, $context) = @_; 
    38     ::is $self->{feeds}->[0], "http://d.hatena.ne.jp/agw/20060526/1148633449#c"; 
    39     ::is $self->{feeds}->[1], "http://d.hatena.ne.jp/nirvash/20060517/1147836803#c"; 
    40 } 
    41  
  • trunk/plagger/t/plugins/Subscription-File/subscription.t

    r851 r1173  
    11use strict; 
    22use FindBin; 
    3 use File::Spec; 
    4 use Test::More tests => 1; 
     3use t::TestPlagger; 
    54 
    6 use Plagger; 
    7 Plagger->bootstrap(config => \<<CONFIG); 
     5plan tests => 1; 
     6run_eval_expected; 
     7 
     8__END__ 
     9 
     10=== test file 
     11--- input config  
    812global: 
    913  log: 
     
    1317    config: 
    1418      file: $FindBin::Bin/feeds.txt 
    15   - module: Aggregator::Test 
    16 CONFIG 
     19  - module: Aggregator::Null 
     20--- expected 
     21my @feeds = map $_->url, $context->subscription->feeds; 
     22is_deeply( 
     23    \@feeds, 
     24    [ 'http://usefulinc.com/edd/blog/rss91', 
     25      'http://www.netsplit.com/blog/index.rss', 
     26      'http://www.gnome.org/~jdub/blog/?flav=rss', 
     27      'http://blog.clearairturbulence.org/?flav=rss', 
     28      'http://www.hadess.net/diary.rss' ], 
     29); 
    1730 
    18 package Plagger::Plugin::Aggregator::Test; 
    19 use base qw( Plagger::Plugin ); 
    20  
    21 sub register { 
    22     my($self, $context) = @_; 
    23     $context->register_hook( 
    24         $self, 
    25         'customfeed.handle' => \&load, 
    26         'aggregator.finalize' => \&test, 
    27     ); 
    28 } 
    29  
    30 sub load { 
    31     my($self, $context, $args) = @_; 
    32     push @{$self->{feeds}}, $args->{feed}->url; 
    33     return 1; 
    34 } 
    35  
    36 sub test { 
    37     my $self = shift; 
    38     ::is_deeply( 
    39         $self->{feeds}, 
    40         [ 'http://usefulinc.com/edd/blog/rss91', 
    41           'http://www.netsplit.com/blog/index.rss', 
    42           'http://www.gnome.org/~jdub/blog/?flav=rss', 
    43           'http://blog.clearairturbulence.org/?flav=rss', 
    44           'http://www.hadess.net/diary.rss' ], 
    45     ); 
    46 } 
  • trunk/plagger/t/regression/mime-lite-chop.t

    r796 r1173  
    11use strict; 
    22use FindBin; 
    3 use File::Spec; 
    4 use Test::More tests => 2; 
    53 
    6 use Plagger; 
    7 use MIME::Lite; 
    8 use MIME::Parser; 
     4use t::TestPlagger; 
     5 
     6BEGIN { 
     7    test_requires('MIME::Lite'); 
     8    test_requires('MIME::Parser'); 
     9
     10 
     11plan tests => 2; 
    912 
    1013no warnings 'redefine'; 
     
    2023    like $body, qr/\x{5bae}{500}/; 
    2124}; 
    22  
    23 Plagger->bootstrap(config => \<<CONFIG); 
    24 global: 
    25   log: 
    26     level: error 
    27   assets_path: $FindBin::Bin/../../assets 
    28 plugins: 
    29   - module: CustomFeed::LongBody 
    30   - module: Publish::Gmail 
    31     config: 
    32       mailto: foobar\@localhost 
    33 CONFIG 
    3425 
    3526package Plagger::Plugin::CustomFeed::LongBody; 
     
    6758    $context->update->add($feed); 
    6859} 
     60 
     61package main; 
     62 
     63run_eval_expected; 
     64 
     65__END__ 
     66 
     67=== Test 
     68--- input config 
     69global: 
     70  log: 
     71    level: error 
     72  assets_path: $FindBin::Bin/../../assets 
     73plugins: 
     74  - module: CustomFeed::LongBody 
     75  - module: Publish::Gmail 
     76    config: 
     77      mailto: foobar\@localhost 
     78--- expected 
     791