Files/Import BibTeX via CGI

From EPrints Documentation
Revision as of 10:54, 22 December 2006 by Bernhard (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

   * 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 

Download the script

Drop this file into /cgi/users/

Install perl modules

You'll need to install these modules from CPAN:


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

After downloading Text::BibTeX, you may need to download and put it in the ".cpan/build/Text-BibTeX-0.??/" directory.

edit home script

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

In home script, put:

       ### Import BibTex? SGT_RULEZ

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, something like these examples in English and Spanish (you can of course make this text archive specific by puttnig it in the archive's phases-??.xml file):

<ep:phrase ref="cgi/users/home:bibimport_link">Import BibTeX records</ep:phrase>
<ep:phrase ref="cgi/users/home:bibimport_info"><p>This will allow the import of bibtex records in to Sussex Research Online. Simply paste the bibtex records in to the following form.</p></ep:phrase>
<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


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+)/) {
           } else {
               $data->{'pages'} = $t;