Contents

What is a Plugin?

The plugin system for EPrints 3 has been developed to make it easy and share the most common extensions to the code without having to hack the core system (and causing yourself problems with upgrades etc.)

Plugins are a way to make functionality easy to maintain and transfer. If you make any customizations to your repository other than metadata and appearence changes then you will probably want to write a plugin.

You will need

A basic understanding of perl (don't be scared - its not hard and there's plenty of tutorials on the web)

An EPrints installation to play about on. A Virtual box with EPrints installed is ideal.

For some types of plugin you might also find some Javascript and CSS knowledge helpful.

Write a Plugin!

When the system loads, it automatically loads all modules in the archives/ARCHIVE_ID/cfg/plugins/EPrints/Plugin/ directory, so for simple plugins you just drop them in that directory and you're done!

When a plugin is loaded it has a registration method which is called which tells the core EPrints system what this plugin does. EPrints then makes it available as appropriate.

Clever plugins can detect features they need and adapt to use the tools available, or disable themselves if they are missing required tools (rather than crash the system). Some specialised plugins are disabled in their default state and must be enabled in the repository configuration.

Another cool thing is that plugins are Perl Objects, which means you can subclass them. Here's an real-world example: We have a research group which uses BibTeX but over the years standardised within the group on an extra field. This is not a valid bibtex field, but are essential to their working because they have ancient and essential scripts which depend on it. To handle this we can subclass the default BibTeX Export plugin and override a single method (the data mapping one). We then just call the original parent plugins mapping method to do all the heavy lifting, then just add our non-standard extra field. Total code required: less than one screen. Number of happy researchers: none (they are never satisfied), but number of researchers able to get their work done: lots. Don't believe me? look here!

Import Plugin

These are used to import data into a repository. They can take datafiles directly, or they can take an ID of a record that can be retrieved in a known way, or a URL of a file, or... whatever.

These are a bit trickier to write than export plugins as parsing data is harder than just "print"ing it, but they are still reasonably straight forward. To get you started a small selection of tutorials has been written:

Input Component Plugin

These handle how the workflow components are rendered. Built in components include the default (one field) component, the multiple fields component, the upload component, the subject component (which does pretty things to a field of type "subject") and the XHTML component. You can add your own or sub-class existing ones.

Convert Plugin

These are used for two things, currently.

Converting the full text of documents into utf-8 text for search indexing

Converting images and pdfs into thumbnails and previews

Some examples you could create:

RTF to utf-8 to allow rich text documents to be indexed.

Powerpoint to Thumbnail to allow thumbnail and previews of powerpoint slides

Go take a look at Extension Packages for a bit more about how you can make your plugins richer.

Its probably a good a idea to look at some tips. It will help you write better plugins.

Probably the best place you can go is your own perl_lib/EPrints/Plugin directory and have a look at some of similar cases. Or to http://files.eprints.org to take a look at other peoples plugins.

If you've written a plugin and you're happy with it the EPrints Team encourages you to share it with the EPrints community at http://files.eprints.org. If nothing else its a good place to store your code for future use. You might even get some valuable feed back.