Difference between revisions of "EdShareToolbox"

From EPrints Documentation
Jump to: navigation, search
(Installation)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category:EdShare]]
 +
{{EdShare}}
 
=Introduction=
 
=Introduction=
 
The EdShareToolbox is a very simple plugin that allows a repository administrator to easily add links to carry out actions on EPrint items.
 
The EdShareToolbox is a very simple plugin that allows a repository administrator to easily add links to carry out actions on EPrint items.
Line 11: Line 13:
  
 
=Installation=
 
=Installation=
 +
Installation should be relatively simple and similar to the installation of other plugins from the EdShare family.
  
 
==Extract Package==
 
==Extract Package==
Line 25: Line 28:
 
  ln -s /opt/eprints3/archives/ARCHIVEID/cgi/edsharetoolbox/ /opt/eprints3/cgi/
 
  ln -s /opt/eprints3/archives/ARCHIVEID/cgi/edsharetoolbox/ /opt/eprints3/cgi/
  
=Usage=
+
==Modify Plugins==
Having your plugin register an action on the toolbox is very simple. All you need to do is add a <code>render_toolbox_item</code> function to your plugin. This function is expected to return a DOM node that will be appended to a list element in the toolbox.
+
Having your plugin register an action on the toolbox is very simple. All you need to do is add a <code>render_toolbox_item</code> function to your plugin. This function is expected to return a DOM node that will be appended to a list element in the toolbox. You then just need to add the name of the plugin to the ''archives/ARCHIVEID/cfg/cfg.d/edsharetoolbox.pl'' file.
  
==Static Rendered Actions==
+
Here is an example for EPrints::Plugin::Foo.
  
==Dynamic Rendered Actions==
+
First in EPrints::Plugin::Foo we add the following <code>render_toolbox_item</code> function;
If your action fires it's own ajax based request then you need to make a call to <code>ep_refresh_edshare_toolbox</code>.
+
 
 +
sub render_toolbox_item
 +
{
 +
        my( $session, $processor, $dynamic ) = @_;
 +
 +
        my $frag = $session->make_doc_fragment;
 +
 +
        if( $dynamic )
 +
        {
 +
                my $link = $session->make_element( "a", href=>"#", onclick=>"ep_foo_action(); return false;" );
 +
                $link->appendChild( $session->make_text( "This is an ajax action" ) );
 +
                $frag->appendChild( $link );
 +
        }
 +
        else
 +
        {
 +
                my $link = $session->make_element( "a", href=>"/cgi/user/home?screen=Foo" );
 +
                $link->appendChild( $session->make_text( "This is a standard link" ) );
 +
                $frag->appendChild( $link );
 +
        }
 +
 +
        return $frag;
 +
}
 +
 
 +
In this function we have an example of a link which has both a default static function and an AJAX function call when you click on it in the event of <code>$dynamic</code> being true. Note that in the <code>ep_foo_action()</code> that a call to <code>ep_refresh_edshare_toolbox</code> should be made at the end of the function. This is needed to update the list as a result of your action being executed.
 +
 
 +
Finally you need to add the name of the plugin, ''EPrints::Plugin::Foo'', to both the ''toolbox_static_plugins'' and  ''toolbox_dynamic_plugins'' array. If you don't add it to ''toolbox_dynamic_plugins'' then it will not be re-rendered at the page load falling back to just the static render case.
 +
 
 +
Now you just need to run;
 +
 
 +
bin/generate_abstracts *archiveid*
 +
 
 +
If this is the first install of the plugin then you will also need to run;
 +
 +
bin/generate_static *archiveid*
 +
 
 +
Finally restart your web server and you should have the toolbox on your abstract pages.

Latest revision as of 14:44, 10 February 2010


EdShare

Edshare logo.png

Supported EPrints Versions 3.2

Project Started 2009

Project Webpage http://edshare.org.uk


Created By ECS, University of Southampton

Introduction

The EdShareToolbox is a very simple plugin that allows a repository administrator to easily add links to carry out actions on EPrint items.

Authors

The EdShareToolbox was created by Marcus Ramsden.

Copyright

EdShare Toolbox, Copyright © 2009 University of Southampton

This plugin is released under the terms of the GNU General Public License v3. Details of this license can be found here.

Installation

Installation should be relatively simple and similar to the installation of other plugins from the EdShare family.

Extract Package

The package should be extracted in the appropriate archive directory of your EPrints installation. Run the following commands replacing ARCHIVEID with the name of the archive you want the collections on, and replace VERSION with the appropriate version number based on the package you have downloaded;

cd /opt/eprints3/archives/ARCHIVEID
tar -xzf toolbox-VERSION.tar.gz

These commands assume that you installed EPrints to /opt/eprints3 substitute this for something else if you installed it elsewhere. Users of the Ubuntu version of EPrints will find that it is installed by default at /usr/share/eprints3.

Install CGI Scripts

Link the toolbox CGI script to the EPrints CGI directory;

ln -s /opt/eprints3/archives/ARCHIVEID/cgi/edsharetoolbox/ /opt/eprints3/cgi/

Modify Plugins

Having your plugin register an action on the toolbox is very simple. All you need to do is add a render_toolbox_item function to your plugin. This function is expected to return a DOM node that will be appended to a list element in the toolbox. You then just need to add the name of the plugin to the archives/ARCHIVEID/cfg/cfg.d/edsharetoolbox.pl file.

Here is an example for EPrints::Plugin::Foo.

First in EPrints::Plugin::Foo we add the following render_toolbox_item function;

sub render_toolbox_item
{
        my( $session, $processor, $dynamic ) = @_;

        my $frag = $session->make_doc_fragment;

        if( $dynamic )
        {
                my $link = $session->make_element( "a", href=>"#", onclick=>"ep_foo_action(); return false;" );
                $link->appendChild( $session->make_text( "This is an ajax action" ) );
                $frag->appendChild( $link );
        }
        else
        {
                my $link = $session->make_element( "a", href=>"/cgi/user/home?screen=Foo" );
                $link->appendChild( $session->make_text( "This is a standard link" ) );
                $frag->appendChild( $link );
        }

        return $frag;
}

In this function we have an example of a link which has both a default static function and an AJAX function call when you click on it in the event of $dynamic being true. Note that in the ep_foo_action() that a call to ep_refresh_edshare_toolbox should be made at the end of the function. This is needed to update the list as a result of your action being executed.

Finally you need to add the name of the plugin, EPrints::Plugin::Foo, to both the toolbox_static_plugins and toolbox_dynamic_plugins array. If you don't add it to toolbox_dynamic_plugins then it will not be re-rendered at the page load falling back to just the static render case.

Now you just need to run;

bin/generate_abstracts *archiveid*

If this is the first install of the plugin then you will also need to run;

bin/generate_static *archiveid*

Finally restart your web server and you should have the toolbox on your abstract pages.