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