Create Export Plugins

From EPrints Documentation
Revision as of 16:52, 9 February 2007 by Gobfrey (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Export plugins for anything but eprints are beyond the scope of this howto.

Imagine we want to create an export plugin that will take a group of eprints (or a single eprint) and output a csv file containing a list of who deposited the eprints, and the dates on which they were deposited.


The top of the plugin should look like this:

package EPrints::Plugin::Export::DepositorActivity;

use Unicode::String qw( utf8 );
use EPrints::Plugin::Export;
@ISA = ( "EPrints::Plugin::Export" );
use strict;

sub new
       my( $class, %params ) = @_;

       my $self = $class->SUPER::new( %params );

       $self->{name} = "Depositor Activity";
       $self->{accept} = [ 'list/eprint', 'dataobj/eprint' ];
       $self->{visible} = "staff";
       $self->{suffix} = ".csv";
       $self->{mimetype} = "text/csv";

       return $self;

This will create a filter object, and set a number of configuration constants:

  • name - The name of the filter
  • accept - A list detailing what the filter will take as inputs. In this case, a list of eprints or a single eprint. It is possible to write filters for dataobj types 'eprint', 'user', 'subject', 'history', 'access' and '*' (all).
  • visible - Who can see this filter. It's set to staff above so that only repository staff can use it. It could be set to 'All' to allow everyone to use it. If set to 'API' then the filter is not available through the web interface.
  • suffix - Appended to the url to create a filename extension.
  • mimetype - Should be set to the correct mime type for the output of the filter.

Note that 'name' and 'accept' are essential. These allow the filter to register itself with EPrints.

Converting the dataobj