Difference between revisions of "My First Bazaar Package"

From EPrints Documentation
Jump to: navigation, search
(Step 2 - Develop your package contents)
Line 7: Line 7:
 
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.
 
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.
  
=Step 1 - Create a blank package=
+
=Step 1 - Develop your package contents=
 
 
In ''Admin'' → ''System Tools'' → ''EPrints Bazaar'', select the ''Developer Tools'' tab.
 
 
 
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) "hello_world" and click ''Create''.
 
 
 
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to "1.0.0".
 
 
 
Click ''Save and Return'' to return to the ''EPrints Bazaar'' screen.
 
 
 
=Step 2 - Develop your package contents=
 
  
 
From the root of the EPrints installation create the directory to contain the ''Screen'' plugin you're going to package:
 
From the root of the EPrints installation create the directory to contain the ''Screen'' plugin you're going to package:
Line 67: Line 57:
 
  1;
 
  1;
  
You need a configuration file to enable the plugin:
+
Create the package directory that will contain the package's configuration file:
 +
 
 +
$ mkdir -p lib/epm/hello_world/cfg/cfg.d
 +
 
 +
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:
  
 
  $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl
 
  $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl
 
This file will be copied into the repository's configuration directory when an admin user enables the package.
 
  
 
==hello_world.pl==
 
==hello_world.pl==
Line 77: Line 69:
 
  $c->{plugins}{"Screen::Hello"}{params}{disable} = 0;
 
  $c->{plugins}{"Screen::Hello"}{params}{disable} = 0;
  
=Step 3 - Add files to the package=
+
=Step 2 - Create a blank package=
  
You now have a blank package and some source files in the EPrint's directory. To add these files to the package go to the ''Developer Tools'' tab and click ''Edit'' for the '''hello_world''' package. Scroll to the bottom of the page and you will find a directory tree. You need to add the two files you created above:
+
In ''Admin'' → ''System Tools'' → ''EPrints Bazaar'', select the ''Developer Tools'' tab.
 +
 
 +
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) "hello_world" and click ''Create''.
 +
 
 +
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to "1.0.0".
 +
 
 +
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:
  
 
* epm/hello_world/cfg/cfg.d/hello_world.pl
 
* epm/hello_world/cfg/cfg.d/hello_world.pl
Line 85: Line 83:
  
 
Click ''Save and Return'' to return to the EPrints Bazaar screen.
 
Click ''Save and Return'' to return to the EPrints Bazaar screen.
 +
 +
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.
  
 
=Step 4 - Enable and test the package=
 
=Step 4 - Enable and test the package=
Line 90: Line 90:
 
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.
 
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.
  
In ''Admin'' → ''System Tools'' → ''Misc. Tools'' you should now see your plugin appear (with a missing phrase).
+
In ''Admin'' → ''System Tools'' → ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).
  
 
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].
 
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].
  
 
[[Category:EPrints_Bazaar]]
 
[[Category:EPrints_Bazaar]]

Revision as of 10:48, 4 July 2011

Introduction

In this tutorial you will create a "Hello, World" Screen and package it as a Bazaar Package (.epm).

Requirements

You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.

Step 1 - Develop your package contents

From the root of the EPrints installation create the directory to contain the Screen plugin you're going to package:

$ mkdir -p lib/plugins/EPrints/Plugin/Screen/

Create the screen plugin using your preferred text editor:

$ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm

Hello.pm

package EPrints::Plugin::Screen::Hello;

@ISA = ( 'EPrints::Plugin::Screen' );

use strict;
# Make the plug-in
sub new
{
   my( $class, %params ) = @_;

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

   # Where the button to access the screen appears if anywhere, and what priority
   $self->{appears} = [
      {
          place => "admin_actions",
          position => 1247,
      },
   ];

   return $self;
}

# Anyone can see this screen
sub can_be_viewed { 1 }

# What to display
sub render
{
   my( $self ) = @_;

   my $frag = $self->{repository}->xml->create_text_node( "Hello, World!" );

   return $frag;
}

1;

Create the package directory that will contain the package's configuration file:

$ mkdir -p lib/epm/hello_world/cfg/cfg.d

Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:

$ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl

hello_world.pl

$c->{plugins}{"Screen::Hello"}{params}{disable} = 0;

Step 2 - Create a blank package

In AdminSystem ToolsEPrints Bazaar, select the Developer Tools tab.

At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) "hello_world" and click Create.

You can fill out the metadata if you wish but at this stage you are only required to have a version, which defaults to "1.0.0".

At the bottom of the screen (the Files selector) you need to add the two files you created above:

  • epm/hello_world/cfg/cfg.d/hello_world.pl
  • plugins/EPrints/Plugin/Screen/Hello.pm

Click Save and Return to return to the EPrints Bazaar screen.

If you make a mistake you can click Edit on the Developer Tools tab to re-edit the package.

Step 4 - Enable and test the package

On the EPrints Bazaar Installed tab click Enable for the hello_world package. After a short time you should see a repository configuration reloaded message.

In AdminSystem ToolsMisc. Tools you should now a button-link to your plugin (although with a missing phrase).

For some hints on loading and manipulating EPrints see Manipulating eprints in 3.2.