Changeset 204
- Timestamp:
- 02/28/06 18:07:11
- Files:
-
- trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm
r202 r204 8 8 use XML::Feed; 9 9 use XML::Feed::Entry; 10 use XML::RSS::LibXML; 10 11 use File::Spec; 11 12 12 # Now XML::RSS::LibXML(0.15) has a bug when it process for RSS 2.0.13 # So this module uses XML::RSS temporarily. 14 $XML::Feed::RSS::PREFERRED_PARSER ="XML::RSS";13 # xxx ugh 14 $XML::Feed::RSS::PREFERRED_PARSER = 15 $XML::RSS::LibXML::VERSION >= 0.16 ? "XML::RSS::LibXML" : "XML::RSS"; 15 16 16 17 sub register { … … 41 42 42 43 # generate feed 43 $context->log(info => "generate feed: " . $f->type);44 44 my $feed = XML::Feed->new($feed_format); 45 $feed->title($f->title _text);45 $feed->title($f->title); 46 46 $feed->link($f->link); 47 $feed->modified(Plagger::Date->now (timezone => $context->conf->{timezone}));48 $feed->generator("Plagger -$Plagger::VERSION");47 $feed->modified(Plagger::Date->now); 48 $feed->generator("Plagger/$Plagger::VERSION"); 49 49 50 50 # add entry 51 51 for my $e ($f->entries) { 52 52 my $entry = XML::Feed::Entry->new($feed_format); 53 $entry->title($e->title _text);53 $entry->title($e->title); 54 54 $entry->link($e->link); 55 55 $entry->summary($e->body_text); … … 63 63 my $filepath = File::Spec->catfile($self->conf->{dir}, $self->gen_filename($f)); 64 64 65 $context->log(info => "save feed for " . $f->url . " to $filepath"); 65 66 66 # output feed67 67 my $xml = $feed->as_xml; 68 68 utf8::decode($xml) unless utf8::is_utf8($xml); … … 105 105 =head1 106 106 107 Plagger::Plugin::Publish::Feed 107 Plagger::Plugin::Publish::Feed - republish RSS/Atom feeds 108 108 109 109 =head1 SYNOPSYS 110 110 111 - module: Publish::Feed112 config:113 format: RSS114 dir: /home/yoshiki/plagger/feed115 filename: my_%t.rss111 - module: Publish::Feed 112 config: 113 format: RSS 114 dir: /home/yoshiki/plagger/feed 115 filename: my_%t.rss 116 116 117 117 =head1 CONFIG … … 119 119 =head2 format 120 120 121 Specify the format of feed. C<Plagger::Plugin::Publish::Feed> supports the following syndication feed formats: 121 Specify the format of feed. C<Plagger::Plugin::Publish::Feed> supports 122 the following syndication feed formats: 122 123 123 124 =over 4 … … 131 132 =head2 dir 132 133 133 Directory for saving feed files.134 Directory to save feed files in. 134 135 135 136 =head2 filename 136 137 137 File name for feed files. A default file name is used, if you do not specify it. It supports the following format like printf(): 138 Filename to be used to create feed files. It defaults to C<%i.rss> for 139 RSS and C<%i.atom> for Atom feed. It supports the following format 140 like printf(): 138 141 139 142 =over 4
