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);
