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

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

Merge from refactoring-planet. YAY!

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         },
47     });
48
49     my $rule = {
50         expression => q{ $args->{feed}->id eq 'smartfeed:all' },
51     };
52
53     $context->load_plugin({
54         module => 'Publish::Planet',
55         rule   => $rule,
56         config => {
57             dir  => $self->conf->{dir},
58             skin => $self->conf->{theme},
59             template => {
60                 style_url => $self->conf->{stylesheet},
61                 url => {
62                     base => $self->conf->{url},
63                     atom => $self->conf->{url} . "atom.xml",
64                     rss  => $self->conf->{url} . "rss.xml",
65                     opml => $self->conf->{url} . "subscriptions.opml",
66                     foaf => $self->conf->{url} . "foafroll.xml",
67                 },
68             },
69         },
70     });
71
72     $context->load_plugin({
73         module => 'Publish::Feed',
74         rule   => $rule,
75         config => {
76             dir => $self->conf->{dir},
77             filename => 'atom.xml',
78             format => 'Atom',
79         },
80     });
81
82     $context->load_plugin({
83         module => 'Publish::Feed',
84         rule   => $rule,
85         config => {
86             dir => $self->conf->{dir},
87             filename => 'rss.xml',
88             format => 'RSS',
89         },
90     });
91
92     $context->load_plugin({
93         module => 'Publish::OPML',
94         config => {
95             filename => File::Spec->catfile($self->conf->{dir}, 'subscriptions.opml'),
96             title => $self->conf->{title},
97         },
98     });
99
100     $context->load_plugin({
101         module => 'Publish::FOAFRoll',
102         config => {
103             filename => File::Spec->catfile($self->conf->{dir}, 'foafroll.xml'),
104             link => $self->conf->{url},
105             url  => $self->conf->{url} . "foafroll.xml",
106             title => $self->conf->{title},
107         },
108     });
109 }
110
111 1;
112
113 __END__
114
115 =head1 NAME
116
117 Plagger::Plugin::Bundle::Planet - Bundle package to create Planet site
118
119 =head1 SYNOPSIS
120
121   - module: Bundle::Planet
122     config:
123       title: Planet Foobar
124       dir: /path/to/planet
125       url: http://example.org/planet
126       theme: sixapart-std
127       stylesheet: foo.css
128       duration: 7 days
129
130 =head1 DESCRIPTION
131
132 This plugin is a I<Bundle> plugin to load bunch of required modules to
133 create Planet site with a single Plugin setup. Using this plugin will
134 load following plugins and automatically sets up necessary
135 configurations.
136
137 =over 4
138
139 =item Filter::StripTagsFromTitle
140
141 =item Filter::HTMLScrubber
142
143 =item SmartFeed::All
144
145 =item Publish::Planet
146
147 =item Publish::Feed
148
149 =item Publish::OPML
150
151 =item Publish::FOAFRoll
152
153 =back
154
155 =head1 CONFIGS
156
157 =over 4
158
159 =item title
160
161 Title of Planet site. Required.
162
163 =item dir
164
165 Directory to create HTML, Feed and CSS files in. Required.
166
167 =item url
168
169 Public URL to access the Planet site, which is used to construct Feed and CSS URLs with. Required.
170
171 =item theme
172
173 Name of I<theme> to use with Publish::Planet. Defaults to I<default>.
174
175 =item stylesheet
176
177 URL(s) of stylesheet (CSS) to use with I<sixapart-std> theme. Optional.
178
179 =item duration
180
181 Duration of feed entries to display. When you pass I<0> as a value, the Planet plugin displays
182 all the entries aggregated. Defaults to I<7 days>.
183
184 =item extra_rule
185
186 Additional rule to add to filter entris using SmartFeed::All. Optional and defaults to nothing.
187
188 =back
189
190 =head1 AUTHOR
191
192 Tatsuhiko Miyagawa
193
194 =head1 SEE ALSO
195
196 L<Plagger>, L<Plagger::Plugin::Publish::Feed>, L<Plagger::Plugin::Publish::Planet>
197
198 =cut
Note: See TracBrowser for help on using the browser.