Plagger::Plugin::Publish::FOAFRoll - Publish foafroll RDF file using subscriptions


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

Top

Plagger::Plugin::Publish::FOAFRoll - Publish foafroll RDF file using subscriptions

SYNOPSIS

Top

  - module: Publish::FOAFRoll
    config:
      filename: /path/to/foafroll.rdf
      link: http://example.org/

DESCRIPTION

Top

This plugin publishes foaf based blogroll (foafroll) using feeds found in the subscription.

CONFIG

Top

filename

File name to save foafroll files in. Recommended to name it foafroll.rdf or foafroll.xml. Required.

URL to use in foaf:homepage element. Optional.

url

URL to self reference the foafroll file. Optional.

title

Title of the foafroll. Optional and defaults to Plagger foafroll.

AUTHOR

Top

Tatsuhiko Miyagawa

SEE ALSO

Top

Plagger, http://usefulinc.com/edd/notes/RDFBlogRoll


Plagger documentation Contained in the Plagger distribution.

package Plagger::Plugin::Publish::FOAFRoll;
use strict;
use base qw( Plagger::Plugin );

use File::Spec;

sub init {
    my $self = shift;
    $self->SUPER::init(@_);
    my $output = $self->conf->{filename}
        or Plagger->context->error("filename is missing");
}

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'publish.finalize' => \&finalize,
    );
}

sub finalize {
    my($self, $context, $args) = @_;

    my $out = $self->templatize('foafroll.tt', {
        feeds => [ $context->subscription->feeds ],
        conf  => $self->conf,
    });

    my $path = $self->conf->{filename};
    $context->log(info => "Writing FOAFRoll to $path");

    open my $fh, ">:utf8", $path or $context->error("$path: $!");
    print $fh $out;
    close $fh;
}

1;

__END__