root/trunk/plagger/lib/Plagger/Plugin/Bundle/Planet.pm

Revision 1213 (checked in by miyagawa, 14 years ago)

Publish::Feed: use author <nobody@example.com> in RSS feed to make it a valid feed.

Line 
1 package Plagger::Plugin::Bundle::Planet;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use File::Spec;
6
7 sub register {
8     my($self, $context) = @_;
9
10     # check required configs
11     for my $directive (qw( title dir url )) {
12         unless ($self->conf->{$directive}) {
13             $context->error("Bundle::Planet: config '$directive' is missing");
14         }
15     }
16
17     $context->load_plugin({
18         module => 'Filter::StripTagsFromTitle',
19     });
20
21     $context->load_plugin({
22         module => 'Filter::HTMLScrubber',
23         config => $self->conf->{scrubber} || {},
24     });
25
26     my @rules;
27     my $duration = defined $self->conf->{duration}
28         ? $self->conf->{duration} : "7 days";
29     if ($duration ne '0') {
30         push @rules, {
31             module   => 'Fresh',
32             duration => $duration,
33         };
34     }
35
36     if (my $rule = $self->conf->{extra_rule}) {
37         push @rules, (ref $rule eq 'ARRAY' ? @{$rule} : ($rule));
38     }
39
40     $context->load_plugin({
41         module => 'SmartFeed::All',
42         rule => \@rules,
43         config => {
44             title => $self->conf->{title},
45             link  => $self->conf->{url},
46             description => $self->conf->{description},
47         },
48     });
49
50     my $rule = {
51         expression => q{ $args->{feed}->id eq 'smartfeed:all' },
52     };
53
54     $context->load_plugin({
55         module => 'Publish::Planet',
56         rule   => $rule,
57         config => {
58             dir  => $self->conf->{dir},
59             skin => $self->conf->{theme},
60             template => {
61                 style_url => $self->conf->{stylesheet},
62                 url => {
63                     base => $self->conf->{url},
64                     atom => $self->conf->{url} . "atom.xml",
65                     rss  => $self->conf->{url} . "rss.xml",
66                     opml => $self->conf->{url} . "subscriptions.opml",
67                     foaf => $self->conf->{url} . "foafroll.xml",
68                 },
69             },
70         },
71     });
72
73     $context->load_plugin({
74         module => 'Publish::Feed',
75         rule   => $rule,
76         config => {
77             dir => $self->conf->{dir},
78             filename => 'atom.xml',
79             format => 'Atom',
80         },
81     });
82
83     $context->load_plugin({
84         module => 'Publish::Feed',
85         rule   => $rule,
86         config => {
87             dir => $self->conf->{dir},
88             filename => 'rss.xml',
89             format => 'RSS',
90         },
91     });
92
93     $context->load_plugin({
94         module => 'Publish::OPML',
95         config => {
96             filename => File::Spec->catfile($self->conf->{dir}, 'subscriptions.opml'),
97             title => $self->conf->{title},
98         },
99     });
100
101     $context->load_plugin({
102         module => 'Publish::FOAFRoll',
103         config => {
104             filename => File::Spec->catfile($self->conf->{dir}, 'foafroll.xml'),
105             link => $self->conf->{url},
106             url  => $self->conf->{url} . "foafroll.xml",
107             title => $self->conf->{title},
108         },
109     });
110 }
111
112 1;
113
114 __END__
115
116 =head1 NAME
117
118 Plagger::Plugin::Bundle::Planet - Bundle package to create Planet site
119
120 =head1 SYNOPSIS
121
122   - module: Bundle::Planet
123     config:
124       title: Planet Foobar
125       dir: /path/to/planet
126       url: http://example.org/planet
127       theme: sixapart-std
128       stylesheet: foo.css
129       duration: 7 days
130       description: Everything about Foobar from the Web
131
132 =head1 DESCRIPTION
133
134 This plugin is a I<Bundle> plugin to load bunch of required modules to
135 create Planet site with a single Plugin setup. Using this plugin will
136 load following plugins and automatically sets up necessary
137 configurations.
138
139 =over 4
140
141 =item Filter::StripTagsFromTitle
142
143 =item Filter::HTMLScrubber
144
145 =item SmartFeed::All
146
147 =item Publish::Planet
148
149 =item Publish::Feed
150
151 =item Publish::OPML
152
153 =item Publish::FOAFRoll
154
155 =back
156
157 =head1 CONFIGS
158
159 =over 4
160
161 =item title
162
163 Title of Planet site. Required.
164
165 =item dir
166
167 Directory to create HTML, Feed and CSS files in. Required.
168
169 =item url
170
171 Public URL to access the Planet site, which is used to construct Feed and CSS URLs with. Required.
172
173 =item theme
174
175 Name of I<theme> to use with Publish::Planet. Defaults to I<default>.
176
177 =item stylesheet
178
179 URL(s) of stylesheet (CSS) to use with I<sixapart-std> theme. Optional.
180
181 =item duration
182
183 Duration of feed entries to display. When you pass I<0> as a value, the Planet plugin displays
184 all the entries aggregated. Defaults to I<7 days>.
185
186 =item extra_rule
187
188 Additional rule to add to filter entris using SmartFeed::All. Optional and defaults to nothing.
189
190 =item description
191
192 Description to use in XHTML tagline and Atom/RSS feeds. Optional.
193
194 =back
195
196 =head1 AUTHOR
197
198 Tatsuhiko Miyagawa
199
200 =head1 SEE ALSO
201
202 L<Plagger>, L<Plagger::Plugin::Publish::Feed>, L<Plagger::Plugin::Publish::Planet>
203
204 =cut
Note: See TracBrowser for help on using the browser.