Changeset 1173
- Timestamp:
- 07/27/06 03:11:42
- Files:
-
- trunk/plagger (modified) (previous)
- trunk/plagger/Makefile.PL (modified) (8 diffs)
- trunk/plagger/assets/plugins/Publish-FOAFRoll (added)
- trunk/plagger/assets/plugins/Publish-FOAFRoll/foafroll.tt (added)
- trunk/plagger/assets/plugins/Publish-OPML/opml.tt (modified) (1 diff)
- trunk/plagger/assets/plugins/Publish-Planet/default/template/index.tt (modified) (2 diffs)
- trunk/plagger/assets/plugins/Publish-Planet/sixapart-std/template/index.tt (modified) (5 diffs)
- trunk/plagger/assets/plugins/Subscription-Planet (added)
- trunk/plagger/assets/plugins/Subscription-Planet/default.yaml (added)
- trunk/plagger/assets/plugins/Subscription-Planet/ja.yaml (added)
- trunk/plagger/examples/planet-old.yaml (added)
- trunk/plagger/examples/planet.yaml (modified) (2 diffs)
- trunk/plagger/lib/Plagger.pm (modified) (6 diffs)
- trunk/plagger/lib/Plagger/Entry.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Feed.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Aggregator/Null.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Bundle (added)
- trunk/plagger/lib/Plagger/Plugin/Bundle/Planet.pm (added)
- trunk/plagger/lib/Plagger/Plugin/Filter/HTMLScrubber.pm (added)
- trunk/plagger/lib/Plagger/Plugin/Filter/StripTagsFromTitle.pm (added)
- trunk/plagger/lib/Plagger/Plugin/Notify/IRC.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Notify/SSTP.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Notify/Tiarra.pm (modified) (4 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/CHTML.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/FOAFRoll.pm (added)
- trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm (modified) (5 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/IMAP.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/JavaScript.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/MT.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Publish/MTWidget.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/Maildir.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/OPML.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/PDF.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/PSP.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/PalmDoc.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Publish/Planet.pm (modified) (6 diffs)
- trunk/plagger/lib/Plagger/Plugin/Publish/Takahashi.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Search/Namazu.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Search/Spotlight.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/SmartFeed/All.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Subscription/OPML.pm (modified) (2 diffs)
- trunk/plagger/lib/Plagger/Plugin/Subscription/Planet.pm (modified) (3 diffs)
- trunk/plagger/lib/Plagger/Rule/Fresh.pm (modified) (4 diffs)
- trunk/plagger/lib/Plagger/UserAgent.pm (modified) (2 diffs)
- trunk/plagger/t/TestPlagger.pm (added)
- trunk/plagger/t/core/cookies.t (modified) (2 diffs)
- trunk/plagger/t/core/googlevideo.xml (deleted)
- trunk/plagger/t/core/hatenafotolife.rdf (deleted)
- trunk/plagger/t/core/hatenafotolife.t (modified) (2 diffs)
- trunk/plagger/t/core/monkey.rss (deleted)
- trunk/plagger/t/core/mrss.t (modified) (2 diffs)
- trunk/plagger/t/core/photocast.rss (deleted)
- trunk/plagger/t/core/photocast.t (modified) (2 diffs)
- trunk/plagger/t/core/primary_author.t (added)
- trunk/plagger/t/plugins/Bundle-Planet (added)
- trunk/plagger/t/plugins/Bundle-Planet/bundle.t (added)
- trunk/plagger/t/plugins/Bundle-Planet/duration.t (added)
- trunk/plagger/t/plugins/Bundle-Planet/rules.t (added)
- trunk/plagger/t/plugins/Bundle-Planet/scrubber.t (added)
- trunk/plagger/t/plugins/CustomFeed-GoogleNews/test.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Filter-FeedBurnerPermalink/feedburner.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Filter-FetchEnclosure/fetch.t (modified) (3 diffs)
- trunk/plagger/t/plugins/Filter-FindEnclosures/object.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Filter-StripTagsFromTitle (added)
- trunk/plagger/t/plugins/Filter-StripTagsFromTitle/filter.t (added)
- trunk/plagger/t/plugins/Notify-UpdatePing/ping.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Publish-FOAFRoll (added)
- trunk/plagger/t/plugins/Publish-FOAFRoll/foaf.t (added)
- trunk/plagger/t/plugins/Publish-Feed (added)
- trunk/plagger/t/plugins/Publish-Feed/atom1.t (added)
- trunk/plagger/t/plugins/Publish-Feed/fullcontent.t (added)
- trunk/plagger/t/plugins/Publish-Feed/rss2-content.t (added)
- trunk/plagger/t/plugins/Publish-JavaScript (added)
- trunk/plagger/t/plugins/Publish-JavaScript/base.t (added)
- trunk/plagger/t/plugins/Publish-Planet (added)
- trunk/plagger/t/plugins/Publish-Planet/base.t (added)
- trunk/plagger/t/plugins/Publish-Planet/non-http.t (added)
- trunk/plagger/t/plugins/Subscription-ConfigINI/subscription.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Subscription-FOAF/subscription.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Subscription-Feed/subscription.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Subscription-File/subscription.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Subscription-Planet (added)
- trunk/plagger/t/plugins/Subscription-Planet/planet.t (added)
- trunk/plagger/t/regression/atom-undeclaredns.t (added)
- trunk/plagger/t/regression/mime-lite-chop.t (modified) (3 diffs)
- trunk/plagger/t/samples (added)
- trunk/plagger/t/samples/delicious.xml (added)
- trunk/plagger/t/samples/googlevideo.xml (added)
- trunk/plagger/t/samples/hatenafotolife.rdf (added)
- trunk/plagger/t/samples/monkey.rss (added)
- trunk/plagger/t/samples/nasty.xml (added)
- trunk/plagger/t/samples/non-http-link.xml (added)
- trunk/plagger/t/samples/photocast.rss (added)
- trunk/plagger/t/samples/rss-full.xml (added)
- trunk/plagger/t/samples/tags-in-title.xml (added)
- trunk/plagger/t/samples/vox.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/Makefile.PL
r1120 r1173 1 use strict; 1 2 use inc::Module::Install; 2 3 … … 24 25 requires('Date::Parse'); 25 26 requires('MIME::Types', 1.16); 26 27 requires('XML::Feed', 0.08); 27 requires('Net::DNS'); 28 29 requires('XML::Feed', 0.09); 28 30 requires('XML::LibXML'); 29 31 requires('XML::Atom', 0.19); … … 32 34 requires('Term::Encoding'); 33 35 34 build_requires(Test::More => 0.42); 36 build_requires('Test::More', 0.42); 37 build_requires('Test::Base', 0.52); 35 38 36 39 features( … … 99 102 recommends('POE::Component::IKC::Client'), 100 103 ], 101 'Filter::URLBL' => [102 -default => 0,103 recommends('Net::DNS'),104 ],105 104 'Publish::JavaScript' => [ 106 105 -default => 0, … … 124 123 ], 125 124 'Publish::Planet' => [ 126 -default => 0, 127 recommends('HTML::Tidy'), 125 -default => 1, 128 126 recommends('HTML::Scrubber'), 129 127 recommends('File::Copy::Recursive'), … … 191 189 recommends('Text::Kakasi'), 192 190 ], 193 'Rule::URLBL' => [194 -default => 0,195 recommends('Net::DNS'),196 ],197 191 'Subscription::LivedoorReader' => [ 198 192 -default => 0, … … 227 221 -default => 0, 228 222 recommends('Audio::Beep'), 223 ], 224 'Bundle::Planet' => [ 225 -default => 1, 226 recommends('Time::Duration::Parse'), 229 227 ], 230 228 'Publish::SWF' => [ … … 295 293 296 294 tests 't/*.t t/*/*.t t/*/*/*.t'; 295 296 use_test_base; 297 297 298 298 auto_include; trunk/plagger/assets/plugins/Publish-OPML/opml.tt
r1092 r1173 1 <?xml version="1.0" encoding="utf-8"?> 1 2 <opml version="1.0"> 2 3 <head> 3 <title> Plagger Subscriptions</title>4 <title>[% (conf.title || 'Plagger Subscriptions') | html %]</title> 4 5 <dateCreated>[% now.format('Mail') %]</dateCreated> 5 6 <ownerName /> 6 7 </head> 7 8 <body> 8 <outline t itle="Subscriptions">9 <outline text="Subscriptions"> 9 10 [% FOREACH feed = feeds -%] 10 <outline title="[% feed.title | html %]" htmlUrl="[% feed.link | html %]" t ype="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 %]" /> 11 12 [% END -%] 12 13 </outline> trunk/plagger/assets/plugins/Publish-Planet/default/template/index.tt
r1092 r1173 6 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 7 7 <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 -%] 10 16 <link rel="stylesheet" type="text/css" href="css/screen.css" /> 11 17 <link rel="stylesheet" type="text/css" href="css/print.css" media="print" /> 12 18 <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" /> 16 20 <title>[% feed.title %]</title> 17 21 </head> … … 19 23 <div id="feed-title">[% feed.title %]</div> 20 24 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> 30 32 31 [% FOREACH entry = feed.entries %]33 [% FOREACH entry = entries %] 32 34 <div class="entry"> 33 35 <div class="entry-header"> trunk/plagger/assets/plugins/Publish-Planet/sixapart-std/template/index.tt
r1092 r1173 5 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 6 <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 %] 10 18 <title>[% feed.title | html %]</title> 11 19 </head> … … 24 32 <div id="alpha"> 25 33 <div id="alpha-inner" class="pkg"> 26 [% FOREACH entry = feed.entries %]34 [% FOREACH entry = entries %] 27 35 <a id="[% entry.id %]"></a> 28 36 <div class="entry" id="entry-[% entry.id %]"> … … 45 53 <span class="separator">|</span> 46 54 <a class="permalink" href="[% entry.permalink | html %]">Permalink</a> 47 [% FOREACH widget = entry.widge rts %]55 [% FOREACH widget = entry.widgets %] 48 56 | [% widget.html(entry) %] 49 57 [% END %] … … 57 65 <div id="beta"> 58 66 <div id="beta-inner" class="pkg"> 59 [% IF members_list %]60 67 <div class="module"> 61 68 <h2 class="module-header">Subscriptions</h2> … … 70 77 </div> 71 78 </div> 72 [% END %]73 79 <div class="module-powered module"> 74 80 <div class="module-content"> trunk/plagger/examples/planet.yaml
r1054 r1173 6 6 plugins: 7 7 # Subscribe to a couple of "My Feeds" on the web 8 # They could be either Feeds URL or Blog URL (with A Uto-Discovery support)8 # They could be either Feeds URL or Blog URL (with Auto-Discovery support) 9 9 - module: Subscription::Config 10 10 config: … … 16 16 - http://d.hatena.ne.jp/miyagawa/ 17 17 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 24 20 config: 21 duration: 7 days 25 22 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 26 27 27 # Generate Planet XHTML output out of the smartfeed28 # to the directory /tmp/planet with sixapart-std "skin"29 - module: Publish::Planet30 rule:31 expression: $args->{feed}->id eq 'smartfeed:all'32 config:33 dir: /tmp/planet34 skin: sixapart-std35 template:36 members_list: 137 style_url: http://bulknews.typepad.com/blog/styles.css38 39 # Output Atom feed for the smartfeed40 - module: Publish::Feed41 rule:42 expression: $args->{feed}->id eq 'smartfeed:all'43 config:44 dir: /tmp/planet45 46 # Output RSS feed for the smartfeed47 - module: Publish::Feed48 rule:49 expression: $args->{feed}->id eq 'smartfeed:all'50 config:51 dir: /tmp/planet52 format: RSS53 trunk/plagger/lib/Plagger.pm
r1145 r1173 9 9 use File::Copy; 10 10 use File::Basename; 11 use File::Find::Rule ;11 use File::Find::Rule (); # don't import rule()! 12 12 use YAML; 13 13 use Storable; … … 68 68 $self->rewrite_config if @{ $self->{rewrite_tasks} }; 69 69 $self->run(); 70 71 $self; 70 72 } 71 73 … … 361 363 my($self, $level, $msg, %opt) = @_; 362 364 365 return unless $self->should_log($level); 366 363 367 # hack to get the original caller as Plugin or Rule 364 368 my $caller = $opt{caller}; … … 372 376 } 373 377 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"; 382 384 } 383 385 … … 409 411 sub template { 410 412 my $self = shift; 413 $self->log(error => "\$context->template is DEPRECATED NOW. use \$plugin->templatize()"); 411 414 my $plugin = shift || (caller)[0]; 412 415 Plagger::Template->new($self, $plugin->class_id); … … 415 418 sub templatize { 416 419 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); 420 422 } 421 423 trunk/plagger/lib/Plagger/Entry.pm
r1024 r1173 68 68 sub body_text { 69 69 my $self = shift; 70 Plagger::Util::strip_html($self->body );70 Plagger::Util::strip_html($self->body || ''); 71 71 } 72 72 trunk/plagger/lib/Plagger/Feed.pm
r1024 r1173 95 95 } 96 96 97 sub 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 97 107 1; trunk/plagger/lib/Plagger/Plugin.pm
r807 r1173 11 11 12 12 use FindBin; 13 use File::Find::Rule (); 13 14 use File::Spec; 14 15 … … 126 127 } 127 128 129 sub 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 141 sub 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 128 154 1; trunk/plagger/lib/Plagger/Plugin/Aggregator/Null.pm
r921 r1173 14 14 my($self, $context, $args) = @_; 15 15 $context->update->add($args->{feed}); 16 return 1; 16 17 } 17 18 trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm
r1065 r1173 38 38 $self->handle_feed($url, \$content, $args->{feed}); 39 39 } else { 40 $content = Plagger::Util::decode_content($res); 40 41 my @feeds = Feed::Find->find_in_html(\$content, $url); 41 42 if (@feeds) { trunk/plagger/lib/Plagger/Plugin/Notify/IRC.pm
r1049 r1173 39 39 $context->log(info => "Notifying " . $args->{feed}->title . " to IRC"); 40 40 41 my $body = $self->templatize( $context, $args->{feed});41 my $body = $self->templatize('irc_notify.tt', { feed => $args->{feed} }); 42 42 Encode::_utf8_off($body) if Encode::is_utf8($body); 43 43 Encode::from_to($body, 'utf-8', $self->conf->{charset}) … … 46 46 $remote->post( 'notify_irc/update', $line ); 47 47 } 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;57 48 } 58 49 trunk/plagger/lib/Plagger/Plugin/Notify/SSTP.pm
r269 r1173 20 20 my @messages = $title; 21 21 for my $entry ($args->{feed}->entries) { 22 push @messages, $self->templatize( $context, $entry);22 push @messages, $self->templatize('sstp.tt', { entry => $entry }); 23 23 } 24 24 my $message = join '\x', @messages; … … 32 32 my $result = $sstp->send($message); 33 33 $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;43 34 } 44 35 trunk/plagger/lib/Plagger/Plugin/Notify/Tiarra.pm
r791 r1173 21 21 22 22 my $protocol = 'TIARRACONTROL/1.0'; 23 my $tt = $context->template(); 23 24 24 my $request_template = <<END; 25 25 NOTIFY System::SendMessage [% protocol %]\r … … 36 36 my $charset = $self->conf->{charset} || 'UTF-8'; 37 37 38 my $body = $self->templatize( $context, $args->{feed});38 my $body = $self->templatize('irc_notify.tt', $args); 39 39 40 40 for my $line (split("\n", $body)) { … … 49 49 } 50 50 51 $tt->process(\$request_template, {51 my $out = $self->templatize(\$request_template, { 52 52 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/)", 56 56 use_notice => ($self->conf->{use_notice} ? 'yes' : 'no'), 57 text => $line,58 } , \my $out) or $context->error($tt->error);57 text => $line, 58 }); 59 59 Encode::_utf8_off($out) if Encode::is_utf8($out); 60 Encode::from_to($out, 'utf-8', $charset) unless $charseteq 'UTF-8';60 Encode::from_to($out, 'utf-8', $charset) unless uc($charset) eq 'UTF-8'; 61 61 $remote->print($out); 62 62 … … 69 69 Time::HiRes::sleep( $self->conf->{send_interval} || 2 ); 70 70 } 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;80 71 } 81 72 trunk/plagger/lib/Plagger/Plugin/Publish/CHTML.pm
r943 r1173 55 55 my $entry_id = md5_hex($entry->permalink); 56 56 $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 58 70 $entry->{feed2entry_link} = $self->id . "/$entry_id.html"; 59 71 } 60 72 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 }), 63 79 "$feed_path/index.html"); 64 80 … … 76 92 return unless @{$self->feeds}; 77 93 $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 }), 79 99 $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;120 100 } 121 101 trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm
r1089 r1173 30 30 mkdir $dir, 0755 or $context->error("mkdir $dir: $!"); 31 31 } 32 33 unless (exists $self->conf->{full_content}) { 34 $self->conf->{full_content} = 1; 35 } 32 36 } 33 37 … … 38 42 my $f = $args->{feed}; 39 43 my $feed_format = $conf->{format} || 'Atom'; 44 45 local $XML::Atom::DefaultVersion = "1.0"; 40 46 41 47 # generate feed … … 51 57 $entry->title($e->title); 52 58 $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; 55 62 $entry->category(join(' ', @{$e->tags})); 56 63 $entry->issued($e->date) if $e->date; … … 151 158 =head1 CONFIG 152 159 153 =head2 format 160 =over 4 161 162 =item format 154 163 155 164 Specify the format of feed. C<Plagger::Plugin::Publish::Feed> supports 156 165 the following syndication feed formats: 157 166 158 =over 4159 160 =item *Atom (default)161 162 =item *RSS167 =over 8 168 169 =item Atom (default) 170 171 =item RSS 163 172 164 173 =back 165 174 166 = head2dir175 =item dir 167 176 168 177 Directory to save feed files in. 169 178 170 = head2filename179 =item filename 171 180 172 181 Filename to be used to create feed files. It defaults to C<%i.rss> for … … 174 183 like printf(): 175 184 176 =over 4177 178 =item *%u url179 180 =item *%l link181 182 =item *%t title183 184 =item *%i id185 =over 8 186 187 =item %u url 188 189 =item %l link 190 191 =item %t title 192 193 =item %i id 185 194 186 195 =back 187 196 197 =item full_content 198 199 Whether to publish full content feed. Defaults to 1. 200 201 =back 202 188 203 =head1 AUTHOR 189 204 trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm
r908 r1173 65 65 } 66 66 67 my $body = $self->templatize( $context, $feed);67 my $body = $self->templatize('gmail_notify.tt', { feed => $feed }); 68 68 69 69 my $cfg = $self->conf; … … 184 184 } 185 185 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 195 186 sub DESTORY { 196 187 my $self = shift; trunk/plagger/lib/Plagger/Plugin/Publish/IMAP.pm
r795 r1173 61 61 $feed_title =~ tr/,//d; 62 62 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} }); 64 64 my $now = Plagger::Date->now(timezone => $context->conf->{timezone}); 65 65 $msg = MIME::Lite->new( … … 82 82 store_maildir($self, $context,$msg->as_string()); 83 83 $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;94 84 } 95 85 trunk/plagger/lib/Plagger/Plugin/Publish/JavaScript.pm
r934 r1173 31 31 $context->log(info => "writing output to $path"); 32 32 33 my $body = $self->templatize( $context, $args->{feed});33 my $body = $self->templatize('javascript.tt', { feed => $args->{feed} }); 34 34 35 35 open my $out, ">:utf8", $path or $context->error("$path: $!"); … … 62 62 $path =~ s!\s+!_!g; 63 63 $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;73 64 } 74 65 trunk/plagger/lib/Plagger/Plugin/Publish/MT.pm
r792 r1173 31 31 sub feed { 32 32 my ($self, $context, $args) = @_; 33 my $body = $context->templatize( 34 $self, 33 my $body = $self->templatize( 35 34 $self->{conf}->{template} || 'mt.tt', 36 35 { feed => $args->{feed} } trunk/plagger/lib/Plagger/Plugin/Publish/MTWidget.pm
r387 r1173 39 39 my $blog_id = $self->conf->{blog_id} || 1; 40 40 my $title = $self->conf->{title} || $args->{feed}->title; 41 my $body = $self->templatize( $context, $args);41 my $body = $self->templatize('mt_widget.tt', $args); 42 42 43 43 my $trimed_title = substr($title, 0, 10); … … 59 59 $tmpl->text($body); 60 60 $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;71 61 } 72 62 trunk/plagger/lib/Plagger/Plugin/Publish/Maildir.pm
r1005 r1173 67 67 $feed_title =~ tr/,//d; 68 68 my $subject = $entry->title || '(no-title)'; 69 my $body = $self->templatize( $context, $args);69 my $body = $self->templatize('mail.tt', $args); 70 70 $body = encode("utf-8", $body); 71 71 my $from = $cfg->{mailfrom} || 'plagger@localhost'; … … 159 159 } 160 160 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 172 161 sub enclosure_id { 173 162 my($self, $enclosure) = @_; trunk/plagger/lib/Plagger/Plugin/Publish/OPML.pm
r316 r1173 17 17 $context->register_hook( 18 18 $self, 19 'publish.feed' => \&feed,20 19 'publish.finalize' => \&finalize, 21 20 ); 22 21 } 23 22 24 sub feed {25 my($self, $context, $args) = @_;26 unless ($args->{feed}->type =~ /^smartfeed:/) {27 push @{ $self->{_feeds} }, $args->{feed};28 }29 }30 31 23 sub finalize { 32 24 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 ], 35 28 now => Plagger::Date->now, 29 conf => $self->conf, 36 30 }); 37 31 … … 58 52 filename: /path/to/subscription.opml 59 53 54 =head1 DESCRIPTION 55 56 This plugin publishes OPML file using feeds fonnd in the subscription. 57 58 =head1 CONFIG 59 60 =over 4 61 62 =item filename 63 64 Filename to save the OPML file. Required. 65 66 =item title 67 68 Title to be used as OPML head. Optional and defaults to I<Plagger Subscriptions>. 69 70 =back 71 60 72 =head1 AUTHOR 61 73 trunk/plagger/lib/Plagger/Plugin/Publish/PDF.pm
r163 r1173 23 23 24 24 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); 26 26 utf8::encode($body); 27 27 … … 32 32 $pdf->convert(); 33 33 $pdf->write_file($file); 34 }35 36 sub templatize {37 my($self, $context, $args) = @_;38 39 # HACK: share the template with Gmail ... for now40 my $tt = $context->template();41 $tt->process('gmail_notify.tt', $args, \my $out)42 or $context->error($tt->error);43 44 $out;45 34 } 46 35 trunk/plagger/lib/Plagger/Plugin/Publish/PSP.pm
r316 r1173 23 23 my($self, $context) = @_; 24 24 25 my $body = $self->templatize( $context, $self->{__feeds});25 my $body = $self->templatize('psp.tt', { feeds => $self->{__feeds} }); 26 26 my $file = $self->conf->{output_file}; 27 27 … … 32 32 } 33 33 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 43 34 1; 44 35 trunk/plagger/lib/Plagger/Plugin/Publish/PalmDoc.pm
r800 r1173 51 51 my($self, $entry, $context) = @_; 52 52 53 my $entry_text = $ context->templatize($self,'palmdoc.tt', {53 my $entry_text = $self->templatize('palmdoc.tt', { 54 54 entry => $entry, 55 55 now => Plagger::Date->now, trunk/plagger/lib/Plagger/Plugin/Publish/Planet.pm
r987 r1173 5 5 use File::Copy::Recursive qw[rcopy]; 6 6 use File::Spec; 7 #use HTML::Tidy; 8 use HTML::Scrubber; 7 use URI; 9 8 10 our $VERSION = '0.0 1';9 our $VERSION = '0.02'; 11 10 12 11 sub register { … … 20 19 sub add_feed { 21 20 my($self, $context, $args) = @_; 21 22 22 my $feed = $args->{feed}; 23 23 if ($feed->id ne 'smartfeed:all') { … … 25 25 } 26 26 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 }; 40 38 41 39 $self->_write_index( 42 40 $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'), 45 43 ); 46 47 $self->_apply_ skin(44 45 $self->_apply_theme( 48 46 $context, 49 $ self->conf->{skin},47 $theme, 50 48 $self->conf->{dir}, 51 49 ); 52 50 } 53 51 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; 52 sub is_http { 53 my $uri = URI->new(shift); 54 my $scheme = $uri->scheme or return; 55 $scheme eq 'http' or $scheme eq 'https'; 67 56 } 68 57 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; 58 sub 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 ]; 75 72 } 73 74 $stash; 76 75 } 77 76 … … 79 78 my ($self, $context, $index, $file) = @_; 80 79 80 $context->log(info => "Save Planet HTML to $file"); 81 81 open my $out, ">:utf8", $file or $context->error("$file: $!"); 82 82 print $out $index; … … 84 84 } 85 85 86 sub _apply_ skin{87 my ($self, $context, $ skin_name, $output_dir) = @_;86 sub _apply_theme { 87 my ($self, $context, $theme_name, $output_dir) = @_; 88 88 $context->log(debug => "Assets Directory: " . $self->assets_dir); 89 89 90 my $static = File::Spec->catfile($self->assets_dir, $ skin_name, 'static');90 my $static = File::Spec->catfile($self->assets_dir, $theme_name, 'static'); 91 91 if (-e $static) { 92 92 rcopy($static, $output_dir) or $context->log(error => "rcopy: $!"); … … 96 96 1; 97 97 98 __END__ 99 100 =head1 NAME 101 102 Plagger::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 115 This plugin generates XHTML out of aggregated feeds suitable to put on 116 the web as "Blog aggregator" like Python Planet does. 117 118 =head1 CONFIG 119 120 =over 4 121 122 =item dir 123 124 Directory to save output XHTML and CSS files in. Required. 125 126 =item theme 127 128 Name of "theme" to use as an XHTML template. Available options are 129 I<default> and I<sixapart-std>. Optional and defaults to 'default'. 130 131 =item template 132 133 Stash 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 146 URL 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 153 URL to be used as a Planet base. This URL is used as a base URL for 154 RSS/Atom feeds and stylesheet if they're relative.. Optional. 155 156 =back 157 158 =back 159 160 =head1 EXAMPLES 161 162 You can see a couple of Publish::Planet powered sites. 163 164 L<http://plagger.org/planet/> 165 166 L<http://planet.yapcchicago.org/> 167 168 =head1 AUTHOR 169 170 Casey West 171 172 Tatsuhiko Miyagawa 173 174 =head1 SEE ALSO 175 176 L<Plagger>, L<http://plagger.org/planet/>, L<http://planetplanet.org/> trunk/plagger/lib/Plagger/Plugin/Publish/Takahashi.pm
r445 r1173 26 26 $context->log(info => "writing output to $path"); 27 27 28 my $body = $ context->templatize($self,'takahashi.tt', $args);28 my $body = $self->templatize('takahashi.tt', $args); 29 29 open my $out, ">:utf8", $path or $context->error("$path: $!"); 30 30 print $out $body; trunk/plagger/lib/Plagger/Plugin/Search/Namazu.pm
r126 r1173 27 27 $context->log(info => "writing output to $path"); 28 28 29 my $body = $self->templatize( $context, { entry => $entry, feed => $args->{feed} });29 my $body = $self->templatize('namazu.tt', { entry => $entry, feed => $args->{feed} }); 30 30 31 31 # save output as EUC-JP so Namazu can easily handle … … 40 40 utime $time, $time, $path; 41 41 } 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;52 42 } 53 43 trunk/plagger/lib/Plagger/Plugin/Search/Spotlight.pm
r669 r1173 36 36 $context->log(info => "writing output to $path"); 37 37 38 my $body = $self->templatize( $context, $entry);38 my $body = $self->templatize('spotlight.tt', { entry => $entry }); 39 39 40 40 open my $out, ">:utf8", $path or $context->error("$path: $!"); … … 66 66 ) == 0 or Plagger->context->error("$path: $!"); 67 67 } 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;77 68 } 78 69 trunk/plagger/lib/Plagger/Plugin/SmartFeed/All.pm
r367 r1173 10 10 $feed->id( $self->conf->{id} || ('smartfeed:all') ); 11 11 $feed->title( $self->conf->{title} || "All Entries " ); 12 $feed->link( $self->conf->{link} ); 12 13 13 14 $self->{feed} = $feed; trunk/plagger/lib/Plagger/Plugin/Subscription/OPML.pm
r681 r1173 51 51 52 52 if (delete $outline->{opmlvalue}) { 53 my $title = delete $outline->{title} ;53 my $title = delete $outline->{title} || delete $outline->{text}; 54 54 push @$containers, $title if $title ne 'Subscriptions'; 55 55 for my $channel (values %$outline) { … … 61 61 $feed->url($outline->{xmlUrl}); 62 62 $feed->link($outline->{htmlUrl}); 63 $feed->title($outline->{title} );63 $feed->title($outline->{title} || $outline->{text}); 64 64 $feed->tags($containers); 65 65 $context->subscription->add($feed); trunk/plagger/lib/Plagger/Plugin/Subscription/Planet.pm
r984 r1173 6 6 use URI::Escape; 7 7 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 23 8 sub load { 24 9 my($self, $context) = @_; … … 27 12 $keyword = [ $keyword ] unless ref $keyword; 28 13 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 29 26 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 }; 40 46 } 41 47 } … … 45 51 46 52 1; 53 54 __END__ 55 56 =head1 NAME 57 58 Plagger::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 69 This plugin gives a handy way to subscribe to dozens of feed / web 70 search engine results by just supplying keywords. 71 72 =head1 CONFIG 73 74 =over 4 75 76 =item keyword 77 78 The keyword to use as a query in web search engines. Required. 79 80 =item lang 81 82 Language code to either 1) specify list of search engines or 2) pass 83 to search query. Optional. 84 85 For example, technorati.jp will be added if you use I<ja>, while 86 technorati.com will be if you use I<en>. Default is to search 87 everything. 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 112 youpy 113 114 Tatsuhiko Miyagawa 115 116 =head1 SEE ALSO 117 118 L<Plagger> 119 120 =cut trunk/plagger/lib/Plagger/Rule/Fresh.pm
r444 r1173 24 24 $self->{timestamp} = $mtime || 0; 25 25 } 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 } 28 33 } 29 34 … … 31 36 } 32 37 38 sub 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 33 56 sub id { 34 57 my $self = shift; 35 return "fresh:$self->{duration} min";58 return "fresh:$self->{duration}sec"; 36 59 } 37 60 … … 49 72 my $self = shift; 50 73 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}); 53 76 } 54 77 … … 113 136 same C<duration> variable with the job interval. 114 137 115 It defaults to I<120>, which means 2 hours. 138 If the supplied value contains only digit, it's parsed as minutes. You 139 can write in a human readable format like: 140 141 duration: 4 hours 142 143 and this module DWIMs. It defaults to I<120>, which means 2 hours. 116 144 117 145 =item C<mtime> trunk/plagger/lib/Plagger/UserAgent.pm
r843 r1173 25 25 my($self, $url, $plugin, $opt) = @_; 26 26 27 URI::Fetch->fetch($url,27 my $res = URI::Fetch->fetch($url, 28 28 UserAgent => $self, 29 29 $plugin ? (Cache => $plugin->cache) : (), … … 31 31 ($opt ? %$opt : ()), 32 32 ); 33 34 if ($res && $url =~ m!^file://!) { 35 $res->content_type( Plagger::Util::mime_type_of(URI->new($url)) ); 36 } 37 38 $res; 33 39 } 34 40 trunk/plagger/t/core/cookies.t
r822 r1173 1 1 use strict; 2 use Test::More tests => 6;3 2 use FindBin; 4 3 5 use Plagger;4 use t::TestPlagger; 6 5 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 6 test_requires('HTTP::Cookies::Mozilla'); 17 7 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 8 plan tests => 6; 9 run_eval_expected; 30 10 31 11 package Plagger::Plugin::Test::Cookies; … … 56 36 } 57 37 38 __END__ 39 40 === cookies: filename 41 --- input config 42 global: 43 log: 44 level: error 45 user_agent: 46 cookies: $FindBin::Bin/cookies.txt 47 plugins: 48 - module: Test::Cookies 49 --- expected 50 1 51 52 === cookies: hash 53 --- input config 54 global: 55 log: 56 level: error 57 user_agent: 58 cookies: 59 type: Mozilla 60 file: $FindBin::Bin/cookies.txt 61 plugins: 62 - module: Test::Cookies 63 --- expected 64 1 trunk/plagger/t/core/hatenafotolife.t
r865 r1173 1 1 use strict; 2 use Test::More tests => 3;3 2 use FindBin; 4 3 5 use Plagger;4 use t::TestPlagger; 6 5 7 Plagger->bootstrap(config => \<<CONFIG); 6 plan tests => 3; 7 run_eval_expected; 8 9 __END__ 10 11 === Hatena Fotolife 12 --- input config 8 13 global: 9 14 log: … … 13 18 config: 14 19 feed: 15 - file://$FindBin::Bin/hatenafotolife.rdf 16 - module: Test::Hatena 17 CONFIG 20 - file://$FindBin::Bin/../samples/hatenafotolife.rdf 18 21 19 package Plagger::Plugin::Test::Hatena; 22 --- expected 23 my @feeds = $context->update->feeds; 24 is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228.gif' ); 25 is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/gif' ); 26 is( ($feeds[0]->entries)[0]->icon->{url}, 'http://f.hatena.ne.jp/images/fotolife/m/miyagawa/20060529/20060529191228_m.jpg' ); 20 27 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 1 1 use strict; 2 use Test::More tests => 6;3 2 use FindBin; 4 3 5 use Plagger;4 use t::TestPlagger; 6 5 7 # cookies: filename 8 Plagger->bootstrap(config => \<<CONFIG); 6 plan tests => 6; 7 run_eval_expected; 8 9 __END__ 10 11 === Media RSS 12 --- input config 9 13 global: 10 14 log: … … 14 18 config: 15 19 feed: 16 - file://$FindBin::Bin/ monkey.rss17 - file://$FindBin::Bin/ googlevideo.xml18 - module: Test::MediaRSS 19 CONFIG 20 - file://$FindBin::Bin/../samples/monkey.rss 21 - file://$FindBin::Bin/../samples/googlevideo.xml 22 --- expected 23 my @feeds = $context->update->feeds; 20 24 21 package Plagger::Plugin::Test::MediaRSS; 22 use base qw( Plagger::Plugin ); 25 is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf' ); 26 is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'application/x-shockwave-flash' ); 27 is( ($feeds[0]->entries)[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg' ); 28 is( ($feeds[1]->entries)[0]->enclosures->[0]->type, 'video/mp4' ); 29 is( ($feeds[1]->entries)[0]->enclosures->[1]->type, 'video/x-flv' ); 30 is( ($feeds[1]->entries)[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE' ); 23 31 24 sub register {25 my($self, $context) = @_;26 32 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 1 1 use strict; 2 use Test::More tests => 3;3 2 use FindBin; 3 use t::TestPlagger; 4 4 5 use Plagger;5 test_requires('Date::Parse'); 6 6 7 Plagger->bootstrap(config => \<<CONFIG); 7 plan tests => 3; 8 run_eval_expected; 9 10 __END__ 11 12 === Photocast 13 --- input config 8 14 global: 9 15 log: … … 13 19 config: 14 20 feed: 15 - file://$FindBin::Bin/ photocast.rss21 - file://$FindBin::Bin/../samples/photocast.rss 16 22 # OMG Apple Photocast has invalida pubDate formats ... fix it. 17 23 - module: Filter::RSSLiberalDateTime 18 - module: Test::Photocast 19 CONFIG 24 --- expected 25 my @feeds = $context->update->feeds; 26 is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg' ); 27 is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'image/jpeg' ); 28 is( ($feeds[0]->entries)[0]->icon->{url}, 'http://web.mac.com/mrakes/iPhoto/photocast_test/1C8C5C8D-651D-4990-B6DD-DF11D515213C.jpg?transform=medium' ); 20 29 21 package Plagger::Plugin::Test::Photocast;22 use base qw( Plagger::Plugin );23 30 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 1 1 use strict; 2 use Test::More tests => 2;2 use t::TestPlagger; 3 3 4 use Plagger;4 test_requires_network; 5 5 6 Plagger->bootstrap(config => \<<'CONFIG'); 6 plan 'no_plan'; 7 8 run_eval_expected; 9 10 __END__ 11 12 === Test Google News live 13 --- input config 7 14 global: 8 15 log: … … 16 23 17 24 - module: CustomFeed::GoogleNews 18 - module: Filter::Test 19 CONFIG 25 --- expected 26 is $context->update->feeds->[0]->link, 'http://news.google.com/news?ned=jp&rec=0&topic=s'; 27 ok $context->update->feeds->[0]->count; 20 28 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 1 1 use strict; 2 use Test::More tests => 1;2 use t::TestPlagger; 3 3 4 use Plagger; 4 test_requires_network; 5 plan 'no_plan'; 5 6 6 7 my $log; 7 { local $SIG{__WARN__} = sub { $log .= "@_" }; 8 Plagger->bootstrap(config => \<<'CONFIG'); 8 $SIG{__WARN__} = sub { $log .= "@_" }; 9 sub log { $log } 10 11 run_eval_expected; 12 13 __END__ 14 15 === sixapart.com feed 16 --- input config log 9 17 global: 10 18 log: … … 17 25 18 26 - module: Filter::FeedBurnerPermalink 19 CONFIG 20 } 21 27 --- expected 28 my $log = $block->input; 22 29 like $log, qr/Permalink rewritten to/; trunk/plagger/t/plugins/Filter-FetchEnclosure/fetch.t
r848 r1173 2 2 use FindBin; 3 3 use File::Path qw(rmtree); 4 use Test::More tests => 2;5 4 6 use Plagger; 7 use MIME::Parser; 8 use MIME::Lite; 5 use t::TestPlagger; 9 6 10 my $tmpdir = "$FindBin::Bin/tmp"; 7 BEGIN { 8 test_requires('MIME::Parser'); 9 test_requires('MIME::Lite'); 10 test_requires_network; 11 } 12 13 plan tests => 2; 14 15 our $tmpdir = "$FindBin::Bin/tmp"; 16 17 my $entity; 11 18 12 19 no warnings 'redefine'; … … 16 23 my $parser = MIME::Parser->new; 17 24 $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); 22 26 }; 23 27 24 Plagger->bootstrap(config => \<<"CONFIG"); 28 sub entity { $entity } 29 30 run_eval_expected; 31 32 END { rmtree $tmpdir if $tmpdir } 33 34 __END__ 35 36 === test via Gmail sender 37 --- input config entity 25 38 global: 26 39 assets_path: $FindBin::Bin/../../../assets … … 41 54 - module: Filter::FetchEnclosure 42 55 config: 43 dir: $ tmpdir56 dir: $main::tmpdir 44 57 45 58 - module: Publish::Gmail 46 59 config: 47 mailto: fooba \@localhost60 mailto: foobar@localhost 48 61 attach_enclosures: 1 49 CONFIG 50 51 END { rmtree $tmpdir } 62 --- expected 63 my $entity = $block->input; 64 ok $entity->parts(0)->bodyhandle->as_string =~ m!<img src="cid:(.*?)" />!; 65 is $entity->parts(1)->head->get('Content-Id'), "<$1>\n"; trunk/plagger/t/plugins/Filter-FindEnclosures/object.t
r850 r1173 1 1 use strict; 2 2 use FindBin; 3 use Test::More tests => 2;3 use t::TestPlagger; 4 4 5 use Plagger; 5 plan tests => 2; 6 run_eval_expected; 6 7 7 my $log; 8 { local $SIG{__WARN__} = sub { $log .= "@_" }; 9 Plagger->bootstrap(config => \<<"CONFIG"); 8 __END__ 9 10 === Test 1 11 --- input config 10 12 global: 11 13 assets_path: $FindBin::Bin/../../../assets 12 14 log: 13 level: debug15 level: error 14 16 plugins: 15 17 - module: CustomFeed::Debug … … 35 37 36 38 - 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 40 is $context->update->feeds->[0]->entries->[0]->enclosure->url, 'http://www.youtube.com/v/nqAWmQ8cdWw'; 41 is $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 2 2 use FindBin; 3 3 use File::Spec; 4 use Test::More tests => 3;4 use t::TestPlagger; 5 5 6 use Plagger; 6 test_requires('XMLRPC::Lite'); 7 test_requires_network; 7 8 8 no warnings 'redefine'; 9 my $rpc; 10 11 no warnings 'redefine', 'once'; 9 12 local *XMLRPC::Lite::call = sub { 10 13 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 }; 14 19 }; 15 20 16 Plagger->bootstrap(config => \<<CONFIG); 21 sub rpc { $rpc } 22 23 plan tests => 3; 24 run_eval_expected; 25 26 __END__ 27 28 === Test 1 29 --- input config rpc 17 30 global: 18 31 log: … … 26 39 config: 27 40 url: http://localhost/ping 28 CONFIG 41 --- expected 42 my $rpc = $block->input; 43 is $rpc->{method}, 'weblogUpdates.ping'; 44 is $rpc->{name}->value, 'blog.bulknews.net'; 45 is $rpc->{url}, 'http://blog.bulknews.net/mt/'; 29 46 47 trunk/plagger/t/plugins/Subscription-ConfigINI/subscription.t
r833 r1173 1 1 use strict; 2 use FindBin; 3 use File::Spec; 4 use Test::More tests => 1; 2 use t::TestPlagger; 5 3 6 use Plagger; 7 Plagger->bootstrap(config => \<<CONFIG); 4 test_requires('Config::INI::Simple'); 5 6 plan tests => 1; 7 run_eval_expected; 8 9 __END__ 10 === testing config.ini 11 --- input config 8 12 global: 9 13 log: … … 13 17 config: 14 18 path: $FindBin::Bin/config.ini 15 - module: Aggregator::Test 16 CONFIG 19 - module: Aggregator::Null 20 --- expected 21 my @feeds = map $_->url, $context->subscription->feeds; 22 is_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 ); 17 30 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 1 1 use strict; 2 2 use FindBin; 3 use File::Spec; 4 use Test::More tests => 1; 3 use t::TestPlagger; 5 4 6 use Plagger; 7 Plagger->bootstrap(config => \<<CONFIG); 5 test_requires('XML::FOAF'); 6 plan tests => 1; 7 run_eval_expected; 8 9 __END__ 10 === Test FOAF 11 --- input config 8 12 global: 9 13 log: … … 13 17 config: 14 18 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 21 my @feeds = map $_->url, $context->subscription->feeds; 22 is_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 1 1 use strict; 2 2 use FindBin; 3 use File::Spec; 4 use Test::More tests => 2; 3 use t::TestPlagger; 5 4 6 use Plagger; 7 Plagger->bootstrap(config => \<<CONFIG); 5 plan tests => 2; 6 run_eval_expected; 7 8 __END__ 9 10 === Test one 11 --- input config 8 12 global: 9 13 log: … … 13 17 config: 14 18 url: file:///$FindBin::Bin/feed.xml 15 - module: Aggregator::Test 16 CONFIG 19 - module: Aggregator::Null 20 --- expected 21 is $context->subscription->feeds->[0]->url, "http://d.hatena.ne.jp/agw/20060526/1148633449#c"; 22 is $context->subscription->feeds->[1]->url, "http://d.hatena.ne.jp/nirvash/20060517/1147836803#c"; 17 23 18 package Plagger::Plugin::Aggregator::Test;19 use base qw( Plagger::Plugin );20 24 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 1 1 use strict; 2 2 use FindBin; 3 use File::Spec; 4 use Test::More tests => 1; 3 use t::TestPlagger; 5 4 6 use Plagger; 7 Plagger->bootstrap(config => \<<CONFIG); 5 plan tests => 1; 6 run_eval_expected; 7 8 __END__ 9 10 === test file 11 --- input config 8 12 global: 9 13 log: … … 13 17 config: 14 18 file: $FindBin::Bin/feeds.txt 15 - module: Aggregator::Test 16 CONFIG 19 - module: Aggregator::Null 20 --- expected 21 my @feeds = map $_->url, $context->subscription->feeds; 22 is_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 ); 17 30 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 1 1 use strict; 2 2 use FindBin; 3 use File::Spec;4 use Test::More tests => 2;5 3 6 use Plagger; 7 use MIME::Lite; 8 use MIME::Parser; 4 use t::TestPlagger; 5 6 BEGIN { 7 test_requires('MIME::Lite'); 8 test_requires('MIME::Parser'); 9 } 10 11 plan tests => 2; 9 12 10 13 no warnings 'redefine'; … … 20 23 like $body, qr/\x{5bae}{500}/; 21 24 }; 22 23 Plagger->bootstrap(config => \<<CONFIG);24 global:25 log:26 level: error27 assets_path: $FindBin::Bin/../../assets28 plugins:29 - module: CustomFeed::LongBody30 - module: Publish::Gmail31 config:32 mailto: foobar\@localhost33 CONFIG34 25 35 26 package Plagger::Plugin::CustomFeed::LongBody; … … 67 58 $context->update->add($feed); 68 59 } 60 61 package main; 62 63 run_eval_expected; 64 65 __END__ 66 67 === Test 68 --- input config 69 global: 70 log: 71 level: error 72 assets_path: $FindBin::Bin/../../assets 73 plugins: 74 - module: CustomFeed::LongBody 75 - module: Publish::Gmail 76 config: 77 mailto: foobar\@localhost 78 --- expected 79 1
