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

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

* BIG CHANGE: don't set timezone in Plagger::Date->parse anymore.
* Load GuessTimeZoneByDate? in Bundle::Planet
* GuessTimeZoneByDate? doesn't do anything if DateTime?::TimeZone? < 0.51

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