Files/Import BibTeX via CGI

From EPrints Documentation
Revision as of 12:24, 13 November 2006 by Ckeene (talk | contribs)
Jump to: navigation, search

This allows a user to cut and paste a bibtex record into a form, and it will create a new eprint in their inbox based on the values in the bibtex.

File moved to http://files.eprints.org/29/

   * Contributor: Christopher Gutteridge
   * Eprints version: 2.3
   * Purpose: CGI script to import a single bibtex record operable by individual users
   * License: GNU General Public License
   * Files: bibimport 

Overview

* download file
* Install perl modules
* edit home script
* edit system-phrases-es.xml

Download file

Drop this file into /cgi/users/

Install perl modules

You'll need to install these modules from CPAN:

Text::BibTeX
Text::BibTeX::Name


To install these packages, please make sure you do these steps:

 * perl -MCPAN -e shell
 * get Text::BibTeX
 * exit
 * cd ".cpan/build/Text-BibTeX-0.36/"
 * perl Makefile.PL
 * make
 * make test
 * make install

edit home script

The home script is located in eprints2 at: /opt/eprints2/cgi/users

In home script, put:

       ### Import BibTex? SGT_RULEZ
       {
               location=>"create",
               code=>"bibimport",
               page=>"bibimport",
               priv=>"deposit"
       },

This should go within the 'my $tools' section where you will find similar entries, if you are adding this to the end of the list, make sure you add a comma to the preceding entry, and remove the comma from the end of the code above.

Edit system-phrases-es.xml

And in /opt/eprints2/cfg/system-phrases-es.xml file, put this:

<ep:phrase ref="cgi/users/home:bibimport_link">Importar Objeto a partir de BibTeX</ep:phrase>
<ep:phrase ref="cgi/users/home:bibimport_info"><p>Esto permitirá importar publicaciones a partir del BibTex?. Sólo es necesario copiar el c ontenido en formato BibTex? en el formulario correspondiente, y la publicación será incluida en el repositorio de EPrints.</p></ep:phrase>

Suggestion for a patch

Jussi Karlgren, SICS

Most BibTeX users use the "pages" field to indicate page range rather than the number of pages in the entire book. The script as it stands moves the "pages" field from BibTeX into the "pages" field in EPrints.

Remove the line

'pages',

from the long sequence of BibTeX field names in the foreach clause about halfway in the bibimport code and instead add the clause:


  if (defined $entry->get('pages')) {
           my $t = $entry->get('pages');
           if ($t =~ m/(\d+)-+(\d+)/) {
               $data->{'pagerange'}=$1."-".$2;
           } else {
               $data->{'pages'} = $t;
           }
       }