Difference between revisions of "Extension Packages"

From EPrints Documentation
Jump to: navigation, search
m (Reverted edit of WidQlg, changed back to last version by Tom)
Line 24: Line 24:
 
  $c->{extension}->{my_cool_extension}->{option_1} = 1;
 
  $c->{extension}->{my_cool_extension}->{option_1} = 1;
 
  $c->{extension}->{my_cool_extension}->{keep_alive} = "always";
 
  $c->{extension}->{my_cool_extension}->{keep_alive} = "always";
 +
 +
And access it in your code like:
 +
 +
$option_1 = $plugin->{session}->get_repository->get_conf( "extension", "my_cool_extension", "option_1" )
  
 
etc.
 
etc.
  
 
You could use a shorter path in the $c datastructure, but try and make sure it's distinct to your extension so clashes don't happen.
 
You could use a shorter path in the $c datastructure, but try and make sure it's distinct to your extension so clashes don't happen.

Revision as of 13:02, 31 January 2008

An extension package is a .tgz file containing multiple files which adds a suite of functionality when unpacked in the /opt/eprint3 directory.

An extension can be as simple as a plugin plus a css file or add a whole exciting suite of new features.

Things you might want to put into an eprints extension package:

  • Plugins: perl_lib/EPrints/Plugin/...
  • Themes: lib/themes/...
  • scripts: bin/...
  • CGI scripts: cgi/...
  • autocompletion scripts: cgi/users/lookup/...
  • phrase files for use by plugins or scripts: lib/lang/.../phrases/...
  • images, icons, javascript and css files to support your plugins or scripts: lib/static/...

Other things you might want to include are...

  • configuration files
  • repository specific phrase files
  • autocompletion data files

...but these can't be installed directly as they must go in the repository specific directory: archives/ARCHIVEID/cfg/ If you have more than 2 files to go in the archive cfg dir you may consider including a second .tgz file to unpack in archives/ARCHIVEID/cfg/

The handy thing is that plugins are autoloaded, .xml files in the phrases directory are autoloaded and .pl files in the archive cfg.d are autoloaded. So if you want to give your plugin some config options, you could just give a .pl file to copy into the cfg.d/ dir looking something like.

$c->{extension}->{my_cool_extension}->{option_1} = 1;
$c->{extension}->{my_cool_extension}->{keep_alive} = "always";

And access it in your code like:

$option_1 = $plugin->{session}->get_repository->get_conf( "extension", "my_cool_extension", "option_1" )

etc.

You could use a shorter path in the $c datastructure, but try and make sure it's distinct to your extension so clashes don't happen.