| 1 |
package Plagger::Plugin::Publish::FOAFRoll; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use base qw( Plagger::Plugin ); |
|---|
| 4 |
|
|---|
| 5 |
use File::Spec; |
|---|
| 6 |
|
|---|
| 7 |
sub init { |
|---|
| 8 |
my $self = shift; |
|---|
| 9 |
$self->SUPER::init(@_); |
|---|
| 10 |
my $output = $self->conf->{filename} |
|---|
| 11 |
or Plagger->context->error("filename is missing"); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
sub register { |
|---|
| 15 |
my($self, $context) = @_; |
|---|
| 16 |
$context->register_hook( |
|---|
| 17 |
$self, |
|---|
| 18 |
'publish.finalize' => \&finalize, |
|---|
| 19 |
); |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
sub finalize { |
|---|
| 23 |
my($self, $context, $args) = @_; |
|---|
| 24 |
|
|---|
| 25 |
my $out = $self->templatize('foafroll.tt', { |
|---|
| 26 |
feeds => [ $context->subscription->feeds ], |
|---|
| 27 |
conf => $self->conf, |
|---|
| 28 |
}); |
|---|
| 29 |
|
|---|
| 30 |
my $path = $self->conf->{filename}; |
|---|
| 31 |
$context->log(info => "Writing FOAFRoll to $path"); |
|---|
| 32 |
|
|---|
| 33 |
open my $fh, ">:utf8", $path or $context->error("$path: $!"); |
|---|
| 34 |
print $fh $out; |
|---|
| 35 |
close $fh; |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
1; |
|---|
| 39 |
|
|---|
| 40 |
__END__ |
|---|
| 41 |
|
|---|
| 42 |
=head1 |
|---|
| 43 |
|
|---|
| 44 |
Plagger::Plugin::Publish::FOAFRoll - Publish foafroll RDF file using subscriptions |
|---|
| 45 |
|
|---|
| 46 |
=head1 SYNOPSIS |
|---|
| 47 |
|
|---|
| 48 |
- module: Publish::FOAFRoll |
|---|
| 49 |
config: |
|---|
| 50 |
filename: /path/to/foafroll.rdf |
|---|
| 51 |
link: http://example.org/ |
|---|
| 52 |
|
|---|
| 53 |
=head1 DESCRIPTION |
|---|
| 54 |
|
|---|
| 55 |
This plugin publishes foaf based blogroll (foafroll) using feeds found |
|---|
| 56 |
in the subscription. |
|---|
| 57 |
|
|---|
| 58 |
=head1 CONFIG |
|---|
| 59 |
|
|---|
| 60 |
=over 4 |
|---|
| 61 |
|
|---|
| 62 |
=item filename |
|---|
| 63 |
|
|---|
| 64 |
File name to save foafroll files in. Recommended to name it |
|---|
| 65 |
I<foafroll.rdf> or I<foafroll.xml>. Required. |
|---|
| 66 |
|
|---|
| 67 |
=item link |
|---|
| 68 |
|
|---|
| 69 |
URL to use in I<foaf:homepage> element. Optional. |
|---|
| 70 |
|
|---|
| 71 |
=item url |
|---|
| 72 |
|
|---|
| 73 |
URL to self reference the foafroll file. Optional. |
|---|
| 74 |
|
|---|
| 75 |
=item title |
|---|
| 76 |
|
|---|
| 77 |
Title of the foafroll. Optional and defaults to I<Plagger foafroll>. |
|---|
| 78 |
|
|---|
| 79 |
=back |
|---|
| 80 |
|
|---|
| 81 |
=head1 AUTHOR |
|---|
| 82 |
|
|---|
| 83 |
Tatsuhiko Miyagawa |
|---|
| 84 |
|
|---|
| 85 |
=head1 SEE ALSO |
|---|
| 86 |
|
|---|
| 87 |
L<Plagger>, L<http://usefulinc.com/edd/notes/RDFBlogRoll> |
|---|
| 88 |
|
|---|
| 89 |
=cut |
|---|