Files/Import BibTeX via CGI

From EPrints Documentation
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 located at http://files.eprints.org/226/ Original version at 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

Download the script

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

After downloading Text::BibTeX, you may need to download http://www.cpan.org/authors/id/A/AM/AMBS/btparse/btparse-0.35.tar.gz 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
       {
               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, 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>


Changes

Suggestion for a patch

the current version of this script already has this patch included (http://files.eprints.org/226/). You only need to make this change if you are using the original version.

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;
           }
       }

Suggestion for a patch2

the current version of this script already has this patch included (http://files.eprints.org/226/). You only need to make this change if you are using the original version.

This patch should allow the year to be imported correctly.


Remove the line

'year',

from the long sequence of BibTeX field names in the foreach clause about halfway in the bibimport code (around line 87, probably the first in the list) and instead add the clause:

       my $year = $entry->get('year');
       if( defined $year )
       {
               $data->{date_issue} = "$year";
       }

You will see similar clauses (e.g. one for 'month') further down and it is suggest you add it there.