Easy Extensions for EPrints
description
Transcript of Easy Extensions for EPrints
![Page 1: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/1.jpg)
Easy Extensions for EPrints
EPrints Training & Support Session 1Open Repositories 2008
![Page 2: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/2.jpg)
Session 1 Overview
Extending EPrints using plugins Introduction to plugins API essentials Walkthrough: ZIP export Walkthrough: Formats report Plugin exercises & EPrints Surgery
![Page 3: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/3.jpg)
Introduction to Plugins
![Page 4: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/4.jpg)
EPrints 3: All Change
3.0 marked new approach for developers
Completely restructured code base Separated into 2 parts:
core facilities framework user capabilities provided by plugins
![Page 5: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/5.jpg)
EPrints 3: All Change (2)
Generic plugin framework “Installed” plugin suite
implements repository functions search, deposit workflow, import/export,
editorial review, user profile, saved searches, admin tools...
“Installed” suite continues to evolve 3.1 introduces QA, bulk editing,
configuration editing...
![Page 6: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/6.jpg)
What This Means
Create new repository behaviour alter, remove or extend plugin suite
Easily share results with community independent of core
![Page 7: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/7.jpg)
Key Benefits
Lightweight buy in for development focus on features not integration not huge learning curve easy to code
Increases scope for community engagement
many more focused development opportunities
small, high value contributions to fit the community profile
![Page 8: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/8.jpg)
Developing Plugins
Core provides API easy access to your repository data
Plugin framework provides simple registration of extensions simple interface for plugins to
implement (the plugin itself does not have be
simple!)
![Page 9: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/9.jpg)
Developing Plugins (2)
Several types of plugin interface provided
Import and export get data in and out
Interface screens user tools and reports
Input components ways for users to enter data
Conversion Issue (3.1 QA)
![Page 10: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/10.jpg)
API Essentials
![Page 11: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/11.jpg)
Accessing Data
Easy access to your repository data Data model contains 3 core objects:
EPrint Document User
Access existing objects or create new ones
Get and set metadata values
![Page 12: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/12.jpg)
Accessing Data: Example
Get title and pub date of an eprint
$eprint = EPrints::DataObj::EPrint
->new( $session, 142 );
![Page 13: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/13.jpg)
Accessing Data: Example
Get title and pub date of an eprint
$eprint = EPrints::DataObj::EPrint
->new( $session, 142 );
print $eprint->get_value( “title” );
![Page 14: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/14.jpg)
Accessing Data: Example
Get title and pub date of an eprint
$eprint = EPrints::DataObj::EPrint
->new( $session, 142 );
print $eprint->get_value( “title” );
if( $eprint->is_set( “date” ) )
{
print $eprint->get_value( “date” );
}
![Page 15: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/15.jpg)
Accessing Data: Example (2)
Change the license of a document
$doc = EPrints::DataObj::Document
->new( $session, 73 );
![Page 16: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/16.jpg)
Accessing Data: Example (2)
Change the license of a document
$doc = EPrints::DataObj::Document
->new( $session, 73 );
$doc->set_value( “license”,
“cc_public_domain” );
![Page 17: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/17.jpg)
Accessing Data: Example (2)
Change the license of a document
$doc = EPrints::DataObj::Document
->new( $session, 73 );
$doc->set_value( “license”,
“cc_public_domain” );
$doc->commit;
![Page 18: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/18.jpg)
Data Collections
Easily manipulate collections of objects
Built-in datasets all data objects of same type or in same state
Searching the repository all data objects matching criteria
![Page 19: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/19.jpg)
Data Collections: Datasets
Corresponding dataset for each data object
eprint document user
Also datasets of eprints in same state
archive inbox buffer deletion
![Page 20: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/20.jpg)
Data Collections: Datasets Example
Get title of every eprint in live archive
$ds = $repository->get_dataset( “archive” );
![Page 21: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/21.jpg)
Data Collections: Datasets Example
Get title of every eprint in live archive
$ds = $repository->get_dataset( “archive” );
$ds->map( $session, \&get_title );
![Page 22: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/22.jpg)
Data Collections: Datasets Example
Get title of every eprint in live archive
$ds = $repository->get_dataset( “archive” );
$ds->map( \&get_title );
sub get_title{my( $session, $ds, $eprint ) = @_;print $eprint->get_value( “title” );
}
![Page 23: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/23.jpg)
Data Collections: Search Example
Find eprints in live archive published after 2000
$search = new Search( dataset=>$ds );
![Page 24: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/24.jpg)
Data Collections: Search Example
Find eprints in live archive published after 2000
$search = new Search( dataset=>$ds );
$search->add_field(
$ds->get_field( “date” ),
“2000-” );
![Page 25: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/25.jpg)
Data Collections: Search Example
Find eprints in live archive published after 2000
$search = new Search( dataset=>$ds );
$search->add_field(
$ds->get_field( “date” ),
“2000-” );
$results = $search->perform_search;
![Page 26: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/26.jpg)
Data Collections: Search Example
Find eprints in live archive published after 2000
$search = new Search( dataset=>$ds );
$search->add_field(
$ds->get_field( “date” ),
“2000-” );
$results = $search->perform_search;
$results->map( ... );
![Page 27: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/27.jpg)
API Essentials: Further Reading
http://software.eprints.org/training
![Page 28: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/28.jpg)
Walkthrough: ZIP Plugin
![Page 29: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/29.jpg)
Writing Export Plugins
Typically a standalone Perl module in perl_lib/EPrints/Plugin/Export/
2 stage process1. Register export capabilities2. Define conversion
from data object to output format
![Page 30: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/30.jpg)
Export Plugin: Registration
Name of plugin What the plugin can convert
type of object (eprint, user) single or object or list of objects (or
both)
Who can use it File extension and MIME type of
output format
![Page 31: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/31.jpg)
Registration Example: BibTeX
$self->{name} = "BibTeX";
$self->{accept} = [ 'list/eprint', 'dataobj/eprint' ];
$self->{visible} = "all";
$self->{suffix} = ".bib";
$self->{mimetype} = "text/plain";
Converts lists or single EPrint objects Available to all users Produces plain text file with .bib extension
![Page 32: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/32.jpg)
Registration Example: FOAF
$self->{name} = "FOAF Export";
$self->{accept} = [ 'dataobj/user' ];
$self->{visible} = "all";
$self->{suffix} = ".rdf";
$self->{mimetype} = "text/xml";
Converts single User objects Available to all users Produces XML file with .rdf extension
![Page 33: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/33.jpg)
Registration Example: XML
$self->{name} = "EP3 XML";
$self->{accept} = [ 'list/*', 'dataobj/*' ];
$self->{visible} = "all";
$self->{suffix} = ".xml";
$self->{mimetype} = "text/xml";
Converts any data object Available to all users Produces XML file with .xml extension
![Page 34: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/34.jpg)
Export Plugin: Conversion
1. map data object(s) to output format2. serialise the output format Mapping example: EndNote
$data->{K} = $dataobj->get_value( "keywords" );
$data->{T} = $dataobj->get_value( "title" );
$data->{U} = $dataobj->get_url;
![Page 35: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/35.jpg)
Export Plugin: Template
1. Register Subclass
EPrints::Plugin::Export tells EPrints this is an export plugin inherits all export plugin mechanics could subclass existing plugin e.g.
XML, Feed
Define name, accept, visible etc. in constructor of plugin module
![Page 36: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/36.jpg)
Export Plugin: Template (2)
2. Conversion If plugin can process lists
(optionally) define output_list function
otherwise output_dataobj called for every data object in the list
If plugin can process single data objects define output_dataobj function convert a single data object
![Page 37: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/37.jpg)
Export Plugin: Walkthrough
Zip export Bundle all documents into single zip
e.g for downloading search results to desktop
Use 3rd party library to create zip file Archive::Zip by Adam Kennedy several other Perl modules for zip easy to download and install from CPAN
![Page 38: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/38.jpg)
Zip Export: Getting Started
Create a file for plugin perl_lib/EPrints/Plugin/Export/Zip.pm
Tell EPrints this is an export plugin
package EPrints::Plugin::Export::Zip;
@ISA = ('EPrints::Plugin::Export');
use Archive::Zip;
![Page 39: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/39.jpg)
Zip Export: Registration
Register plugin capabilities in constructor
sub new{my ($class, %opts) = @_;my $self = $class->SUPER::new(%opts);$self->{name} = 'Zip';$self->{accept} = [ 'list/eprint' ];$self->{visible} = 'all';$self->{suffix} = '.zip';$self->{mimetype} = 'application/zip‘return $self;
}
![Page 40: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/40.jpg)
Zip Export: Conversion
Define output_list function Passed list of eprints to convert Create new zip archive and iterate over list
sub output_list{my ( $plugin, %opts ) = @_;my $list = $opts{list};
![Page 41: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/41.jpg)
Zip Export: Conversion
Define output_list function Passed list of eprints to convert Create new zip archive and iterate over list
sub output_list{my ( $plugin, %opts ) = @_;my $list = $opts{list};my $zip = Archive::Zip->new;
![Page 42: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/42.jpg)
Zip Export: Conversion
Define output_list function Passed list of eprints to convert Create new zip archive and iterate over list
sub output_list{my ( $plugin, %opts ) = @_;my $list = $opts{list};my $zip = Archive::Zip->new;foreach my $eprint ($list->get_records){
...}
![Page 43: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/43.jpg)
Zip Export: Conversion (2)
For each document, add all files to zip Top level directory keeps things tidy when
unzipped Organise files inside zip using directories
my $eprintid = $eprint->get_id;foreach my $doc ($eprint->get_all_documents){
}
![Page 44: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/44.jpg)
Zip Export: Conversion (2)
For each document, add all files to zip Top level directory keeps things tidy when
unzipped Organise files inside zip using directories
my $eprintid = $eprint->get_id;foreach my $doc ($eprint->get_all_documents){my $path = $doc->local_path;
}
![Page 45: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/45.jpg)
Zip Export: Conversion (2)
For each document, add all files to zip Top level directory keeps things tidy when
unzipped Organise files inside zip using directories
my $eprintid = $eprint->get_id;foreach my $doc ($eprint->get_all_documents){my $path = $doc->local_path;my $docpos = $doc->get_value( "pos" );$zip->addTree(
$path,"export/$eprintid/$docpos");
}
![Page 46: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/46.jpg)
Zip Export: Conversion (3)
Serialise to filehandle or string
if( defined $opts{fh} ){$zip->writeToFileHandle($opts{fh},'zip' );return undef;
}
![Page 47: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/47.jpg)
Zip Export: Conversion (3)
Serialise to filehandle or string
if( defined $opts{fh} ){$zip->writeToFileHandle($opts{fh},'zip' );return undef;
}
my $archive = '';open( my $FH, '>', \$archive );$zip->writeToFileHandle( $FH, 'zip' );return $archive;
![Page 48: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/48.jpg)
Zip Export: Testing
Appears on search results screen
Downloads zip file to desktop
![Page 49: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/49.jpg)
Zip Export: Testing
top level folder
![Page 50: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/50.jpg)
Zip Export: Testing
folder for each eprint
![Page 51: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/51.jpg)
Zip Export: Testing
folder for each document
![Page 52: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/52.jpg)
Zip Export: Testing
document files
![Page 53: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/53.jpg)
Zip Export: Simple Improvements
Include HTML index file lists citations, link to documents see Tom Healy’s walkthrough
Better directory names include date in top level directory
name use eprint title rather than ID?
![Page 54: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/54.jpg)
Zip Export: Simple Improvements (2)
Scalability get_records loads all eprints at once map is more efficient
Better “housekeeping” check Archive::Zip available hide plugin if not see Tom Healy’s walkthrough
![Page 55: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/55.jpg)
Zip Export: Sharing
Share Zip.pm with community via http://files.eprints.org/
Drop-in install for other repositories
![Page 56: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/56.jpg)
Walkthrough: Formats Screen
![Page 57: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/57.jpg)
Writing Screen Plugins
One or more Perl modules in perl_lib/EPrints/Plugin/Screen/ often bundled with phrases,
configuration files, stylesheets etc.
2 stage process1. Register2. Define functionality
![Page 58: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/58.jpg)
Screen Plugin: Registration
Actions plugin can carry out (if any) Where plugin and/or actions will
appear named placeholder (list) position in list will be displayed as link, button, icon or
tab
Who can use plugin
![Page 59: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/59.jpg)
Registration Example: Manage Deposits
$self->{appears} = [ { place => "key_tools", position => 100, }];
key_tools list
![Page 60: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/60.jpg)
Registration Example: EPrint Details
eprint_view_tabs list (each tab is a single
screen plugin)
$self->{appears} = [ { place => "eprint_view_tabs", position => 100, },];
![Page 61: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/61.jpg)
Registration Example: New Item
item_tools list (create action will be invoked when button
pressed)
$self->{appears} = [ { place => “item_tools", position => 100, action => “create”, },];
![Page 62: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/62.jpg)
Screen Plugin: Define Functionality
3 types of screen plugin1. Render only
define how to produce output page
2. Action only no output page define how to carry out action(s)
![Page 63: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/63.jpg)
Screen Plugin: Define Functionality
3. Combined (interactive) define how to produce output page define how to carry out action(s)
![Page 64: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/64.jpg)
Screen Plugin Template: Render Only
1. Register Subclass EPrints::Plugin::Screen
tells EPrints this is a screen plugin inherits all screen plugin mechanics could subclass existing plugin e.g. EPrint,
User Define where plugin appears Define who can view plugin (if
required) can_be_viewed function
![Page 65: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/65.jpg)
Screen Plugin Template: Render Only (2)
2. Define functionality Define render function Produces output page
![Page 66: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/66.jpg)
Screen Plugin Template: Action Only
1. Register Define actions supported Define where actions appear Define who can use actions
allow_ACTION function for each action
![Page 67: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/67.jpg)
Screen Plugin Template: Action Only (2)
2. Define functionality Define action_ACTION function for
each action carries out the action use add_message to show result or
error redirect to a different screen when
done
![Page 68: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/68.jpg)
Screen Plugin Template: Combined
Combine templates render displays link/buttons which
invoke actions Example: Delete EPrint screen
registers remove and cancel actions render function displays Are you sure?
screen with OK/Cancel buttons OK/Cancel buttons invoke remove/cancel actions
![Page 69: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/69.jpg)
Screen Plugin: Walkthrough
Report screen Render only Summary of document formats
How many of each document format are there in the repository
For editors and administrators only
![Page 70: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/70.jpg)
Formats Screen: Getting Started
Create a file for plugin perl_lib/EPrints/Plugin/Screen/Formats.pm
Tell EPrints this is a Screen plugin
package EPrints::Plugin::Screen::DocTypes;
@ISA = ( 'EPrints::Plugin::Screen' );
![Page 71: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/71.jpg)
Formats Screen: Registration
Add to list of plugins on Admin screensub new
{
my( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
$self->{appears} = [
{ place => "admin_actions",
position => 1000, },
];
return $self;
}
![Page 72: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/72.jpg)
Formats Screen: Authorisation
Restrict access Only editors and admins have the
status privilege
sub can_be_viewed
{
my( $self ) = @_;
return $self->allow( "status" );
}
![Page 73: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/73.jpg)
Formats Screen: Output Page
Generate output page First get the archive dataset...
sub render
{
my( $self ) = @_;
my $session = $self->{session};
my $ds = $session->get_repository
->get_dataset( "archive" );
![Page 74: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/74.jpg)
Formats Screen: Output Page (2)
...then use map to iterate over dataset Keep count of document formats
my %counts = ();$ds->map( $session, sub {my( $session, $ds, $eprint, $counts ) = @_;
}, \%counts );
![Page 75: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/75.jpg)
Formats Screen: Output Page (2)
...then use map to iterate over dataset Keep count of document formats
my %counts = ();$ds->map( $session, sub {my( $session, $ds, $eprint, $counts ) = @_;foreach my $doc ($eprint->get_all_documents){
}}, \%counts );
![Page 76: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/76.jpg)
Formats Screen: Output Page (2)
...then use map to iterate over dataset Keep count of document formats
my %counts = ();$ds->map( $session, sub {my( $session, $ds, $eprint, $counts ) = @_;foreach my $doc ($eprint->get_all_documents){
$counts->{$doc->get_type}++;}
}, \%counts );
![Page 77: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/77.jpg)
Formats Screen: Output Page (3)
Now ready to display something Start by creating a table to hold the
results
my $html = $session->make_doc_fragment;
my $table = $session->make_element( "table", border => 0 );
$html->appendChild( $table );
![Page 78: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/78.jpg)
Formats Screen: Output Page (4)
Add the document formats and totals to the table
foreach my $type ( keys %counts ){
}return $html;
![Page 79: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/79.jpg)
Formats Screen: Output Page (4)
Add the document formats and totals to the table
foreach my $type ( keys %counts ){$table->appendChild(
$session->render_row($session->html_phrase(
"document_typename_$type" ),$session->make_text(
$counts{$type} ) ) );}return $html;
![Page 80: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/80.jpg)
Formats Screen: Testing
Formats screen appears on list of admin tools
![Page 81: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/81.jpg)
Formats Screen: Testing
Formats screen output
page
![Page 82: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/82.jpg)
Format Screen: Simple Improvements
Count document formats in other datasets
inbox, buffer, deletion
..or whole repository eprint dataset
Report zero counts Better output display
simple bar chart
![Page 83: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/83.jpg)
Formats Screen: Sharing
2 files Formats.pm Small phrases file
formats.xml phrases to use for title and description
Share with community via http://files.eprints.org/
![Page 84: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/84.jpg)
Summary of Talk
Walked through 2 useful plugins Minimal coding
both ~50 lines of (well formatted) code
Minimal learning curve API essentials plugin templates
Minimal hassle easy to share easy to install
![Page 85: Easy Extensions for EPrints](https://reader035.fdocuments.in/reader035/viewer/2022081501/56814937550346895db67a73/html5/thumbnails/85.jpg)
OR08 Training Resources
Live CD Plugin exercises
http://software.eprints.org/training/
Plugin walkthroughs http://wiki.eprints.org/w/Contribute
:_Plugins
Community contributed plugins http://files.eprints.org/view/type/plugin.
html
EPrints Experts