monperrus / bibtexbrowser

Beautiful publication lists with bibtex and PHP (standalone or in Wordpress)
http://www.monperrus.net/martin/bibtexbrowser/
86 stars 54 forks source link

bibtexbrowser is a PHP script that creates publication lists from Bibtex files. bibtexbrowser is stable, mature and easy to install. It is used in [[http://www.monperrus.net/martin/bibtexbrowser/users|hundreds of different universities and institutions]] (over 469 different domains according to Google).

This documentation is collaborative, you can improve it using a [[https://github.com/monperrus/bibtexbrowser/edit/master/README.wiki|pull request]].

=====Features=====

=====Download===== For feature requests or bug reports, please comment this page below; patches can be contributed as pull requests on [[https://github.com/monperrus/bibtexbrowser|github]]:)

'''Stable Version''': [[http://www.monperrus.net/martin/bibtexbrowser.php.txt|bibtexbrowser.php]] [[https://github.com/monperrus/bibtexbrowser/commits/master|Changelog]]

Don't hesitate to contact me to be added in the [[http://www.monperrus.net/martin/bibtexbrowser/users|lists of bibtexbrowser users]]:-)

=====Bibtexbrowser Ecosystem=====

The following uses bibtexbrowser under the hood:

=====Demo and screenshot=====

Demo: [[http://bibtexbrowser.sourceforge.net/bibtexbrowser.php?bib=metrics.bib|Here, you can browse a bibtex file dedicated to software metrics]]

bibtexbrowser screenshot

=====Basic installation===== Create a bib file with the publication records (e.g. csgroup2008.bib) and upload it to your server.

'''Warning''': bibtexbrowser maintains a cached version of the parsed bibtex, for high performance, check that PHP can write in the working directory of PHP.

'''Handling mutliple bibtex files''': If you want to include several bibtex files, just give bibtexbrowser the files separated by semi-columns e.g: ''bibtexbrowser.php?bib=strings.bib;csgroup2008.bib''

=====FAQ=====

====How to embed Bibtexbrowser into a website?==== To embed Bibtexbrowser into a website, you could use it as a library:

load('biblio.bib');

// printing all 2014 entries
// can also be $query = array('year'=>'.*');
$query = array('year'=>'2014');
$entries=$db->multisearch($query);
uasort($entries, 'compare_bib_entries');

foreach ($entries as $bibentry) {
  echo $bibentry->toHTML()."
"; } ?>

====How to embed a publication list in an home page?====

Sorted by year Sorted by publication type
For a group/team/lab
For an individual

In the above snippets, only the bibtex-entries containing 'Martin Monperrus' as an auhor will be extracted, but not 'Monperrus, Martin'. To remedy this, you need to add ''define('USE_FIRST_THEN_LAST',true);'' either to the php-query, or to ''bibtexbrowser.local.php'' ====How to change the reference style?====

'''By modifying the CSS'''

If bibtexbrowser.css exists, it is used, otherwise bibtexbrowser uses its own embedded CSS style (see function bibtexbrowserDefaultCSS). An example of CSS tailoring is:

.date {   background-color: blue; }
.btb-header { }
.rheader {  font-size: large }
.bibref {  padding:3px; padding-left:15px;  vertical-align:top;}
.bibtitle { font-weight:bold; }
.bibbooktitle { font-style:italic; }

 

For instance, one can tweak the output by disabling the display of some headers and pieces of information.

.bibmenu {display:none} /* disables the [bibtex] and the like */
.bibanchor {display:none} /* disables the index [1] or [Name2010], etc. depending on the value of the configuration value ABBRV_TYPE and BIBTEXBROWSER_LAYOUT
.theader {display:none}
.sheader {display:none} /* disables the year header e.g., 2001 */

 

'''By setting your own style function''' The bibliography style is encapsulated in a function. If you want to modify the bibliography style, you can copy the default style in a new file, say ''bibtexbrowser-yourstyle.php'', and rename the function ''DefaultBibliographyStyle'' in say ''MyFancyBibliographyStyle''. Then, add in the file ''bibtexbrowser.local.php'':

getTitle().' ('.$bibentry->formattedAuthors(.')';
}
define('BIBLIOGRAPHYSTYLE','MyFancyBibliographyStyle');
?>

 

====How to use the IEEE bibliographic style?====

Create a file bibtexbrowser.local.php, in the same folder as bibtexbrowser.php, containing:


 

See also [[http://github.com/KaiBi/IEEEStyleForBibtexbrowser|another custom citation style for bibtexbrowser adhering to the IEEE citations guidelines (on github)]].

====How to change the link style?====

By default each bibliographic entry is followed by [bibtex] [pdf] [doi], etc.

This can be tailored by configuring as follows (in the file ''bibtexbrowser.local.php'')

getBibLink();

  $result .= ' '.$bibentry->getLink('url');

  // Google Scholar ID. empty string if no gsid field present
  $result .= ' '.$bibentry->getGSLink();

  // returns an empty string if no doi field present
  $result .= ' '.$bibentry->getDoiLink();

  return $result;
}
?>

 

You can use your personalized function to add support for new fields in bibtex (''pdf'', ''file'', etc.). Check-out the documentation of functions ''getLink()'', ''getBibLink()'', ''getGSLink()'' and ''getDoiLink()'': they accept an optional argument for providing an image/icon instead of printing text.

  // returns an empty string if no pdf field present
  $result .= $bibentry->getLink('pdf','http://url.to/icons/pdf.png');
  // returns an empty string if no slides field present
  $result .= $bibentry->getLink('slides');
  // returns an empty string if no poster field present
  $result .= $bibentry->getLink('poster');

====How to specify the encoding of bibtex files (UTF-8/ISO-8859-1/etc.)? ==== By default, bibtexbrowser assumes that the bibtex file is UTF-8 encoded. If you want to change it to e.g. ISO-8859-1, add into ''bibtexbrowser.local.php'':

define('BIBTEX_INPUT_ENCODING','ISO-8859-1');

Note that if the bibtex only contains latex-encoded diacritics (e.g. ''\'e''), it does not matter. The encoding of the bibtex file and the one of the generated HTML is identical.

====How to disable Javascript progressive enhancement?==== add into ''bibtexbrowser.local.php'': ''define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',false);''

====How to remove the "[bibtex]" links?==== ''@define('BIBTEXBROWSER_BIBTEX_LINKS',false);''

====How to change the reference indices?==== The configuration of ABBRV_TYPE drives the indices

// index => [1] The essence of metamodeling
// year => [2005] The essence of metamodeling
// x-abbrv => [SoSyM] The essence of metamodeling if the bibtex entry contains a field x-abbrv
define('ABBRV_TYPE','year');// may be year/x-abbrv/key/none/index

One can also extend class SimpleDisplay to tweak the indices.

For instance, this configuration ...

// bibtexbrowser.local.php
class SimpleDisplayExt extends SimpleDisplay {
  // overriding the default
  function setIndices() {
    $this->setIndicesInIncreasingOrderChangingEveryYear();
  }
}
bibtexbrowser_configure('BIBTEXBROWSER_DEFAULT_DISPLAY','SimpleDisplayExt');

results in resetting the numeric indices every year as follows

2017
[1] article1... (2017) [pdf] [doi]
[2] article2... (2017) [pdf] [doi]
[3] article3... (2017) [pdf] [doi]
etc..

2016
[1] article1... (2017) [pdf] [doi]
[2] article2... (2017) [pdf] [doi]
[3] article3... (2017) [pdf] [doi]

====How to use the "Academic style"?====

The default academic mode creates four sections:

You may create your own one in ''bibtexbrowser.local.php'' (see also "creating a bibtexbrowser.local.php" below):

define('BIBLIOGRAPHYSECTIONS','my_sectioning');
function my_sectioning() {
return
  array(
  // Books
    array(
      'query' => array(Q_TYPE=>'book'),
      'title' => 'Books'
    ),
  // Articles
    array(
      'query' => array(Q_TYPE=>'article'),
      'title' => 'Refereed Articles'
    ),
  // Conference and Workshop papers
    array(
      'query' => array(Q_TYPE=>'inproceedings'),
      'title' => 'Conference and Workshop  Papers'
    ),
  // others
    array(
      'query' => array(Q_TYPE=>'misc|phdthesis|mastersthesis|bachelorsthesis|techreport'),
      'title' => 'Other Publications'
    )
  );
}

====How to get the individual bib pages embedded as well?==== ''define('BIBTEXBROWSER_URL',""); ''

====How to add links to the slides of a conference/workshop paper?==== You can simply fill the ''comment'' field of the bib entry with an HTML link: @inproceedings{foo, author="Jean Dupont", title="Bibtexbrowser", year=2009, booktitle="Proceedings of the BIB conference", comment={[slides]} }

This comment field can also be used to add acceptance rates and impact factors.

====How to localize bibtexbrowser?==== Add in ''bibtexbrowser.local.php'':


====How to change the default frame?==== Add in ''bibtexbrowser.local.php'':


====How to configure the sorting order of Bibtex entries?====

The default order is first by bibtex field year, then by bibtex field month, per functions compare_bib_entry_by_year and compare_bib_entry_by_month.

You can change this with ''define('ORDER_FUNCTION',...)'' and ''define('ORDER_FUNCTION_FINE',...)'' in ''bibtexbrowser.local.php'':

getKey(),$b->getkey());
}

define('ORDER_FUNCTION','my_own_order');
?>

====How to change the title of the result page?====

You may create your own title function in ''bibtexbrowser.local.php'' (see "creating a bibtexbrowser.local.php" below):

define('BIBLIOGRAPHYTITLE','my_title_function');
function my_title_function($query) {
  return "Publications of the Nuclear Research Group";
}

See function DefaultBibliographyTitle for inspiration.

====How to disallow crawler indexing?====

Add in ''bibtexbrowser.local.php'' (see "creating a bibtexbrowser.local.php" below):

define('BIBTEXBROWSER_ROBOTS_NOINDEX', true);

====How to load Bibtex from a dynamic string?====

You can use the special ''php://memory'' feature in a new dispatcher. Add in ''bibtexbrowser.local.php'':

define("BIBTEXBROWSER_MAIN", 'DynamicDispatcher');

and then in ''bibtexbrowser.after.php'':

update_internal("inline", $data);
    return $db;
  }
}
?>

====How to load bibliographic data in other formats?====

If your bibliographic data comes from XML or a database, you can still browse it with bibtexbrowser as follows: Add in ''bibtexbrowser.local.php'':

define("BIBTEXBROWSER_MAIN", 'PgmDispatcher');

and then in ''bibtexbrowser.after.php'':

setType("article");
    $entry->setField("title", "foo");
    $entry->setField("year", "2014");
    $entry->setKey("kolp");
    $db->addEntry($entry);

    // builds the second entry
    $entry2 = new BibEntry();
    $entry2->setType("article");
    $entry2->setField("title", "bar");
    $entry2->setField("year", "2013");
    $entry2->setKey("tili");
    $db->addEntry($entry2);

    return $db;
  }
}
?>

====How to remove fields from the bibtex text?====

If you want to remove some fields (e.g. abbrv and comment) from the resulting bibtex, add in ''bibtexbrowser.local.php'':


====How to activate page numbering in the output?====

Add in ''bibtexbrowser.local.php'':


====How to override framesets and headers?====

You can customize every view as follows, in particular by playing with ''BIBTEXBROWSER_URL''.

''frameset.html'':







''menu.php'':

MENU (no header sent)

''output.php'':

OUTPUT (no header sent)

''elem.php'':

ELEM (no header sent)

====How to add hyperlink to the authors' web pages?====

You must add a ''@string'' block in the bibtex file, which contains the links. The key is a concatenation of ''hp_'' and then ''FirstNameLastName'' (no space). For instance:

@String {
  hp_ericfoo      = {http://www.foo.de/},
  hp_joebar      = {http://www.joebar.me/},
}

====How to modify bibtex entries on the command line?====

Use ''bibtexbrowser-cli.php''. For instance:

php bibtexbrowser-cli.php mybib.bib --id classical --set-title \"a new title\" --id with_abstract --set-title \"a new title\" --set-year 1990

====How to use with composer?==== Bibtexbrowser can now be downloaded from packagist with composer.

In your project's composer.json, just add this

"monperrus/bibtexbrowser": "dev-master"
. E.G.:

{
    "require": {
        "monperrus/bibtexbrowser": "dev-master"
    }
}

With composer, a test server can be started with the following commands:

cd vendor/monperrus/bibtexbrowser/
composer serve

Which runs this script:

php -S localhost:29896 bibtexbrowser.php

Now, to display a particular bibtex file in your browser, the URI should be of this form:

localhost:29896/?bib=bibfile.bib

Note the forward slash following the port number.

====How to add a banner to the main view in frameset mode?====

For instance, if you want to add a "home page" button in the main view of the frameset mode, add a banner function in ''bibtexbrowser.local.php'' as follows:

Home page';
}
?>

====How to configure the type of metadata that bibtexbrowser generates?====

Bibtexbrowser can generate [[https://en.wikipedia.org/wiki/COinS|Coins]], Google Scholar, Dublin Core (DC), Opengraph and Eprints metadata. This can be configured in ''bibtexbrowser.local.php'' as follows:


====How to run the test for another PHP version?====

Find the right image on Docker, eg ''8.3.11-cli-alpine'', and create container/Dockerfile

FROM php:8.3.11-cli-alpine
RUN apk add phpunit
WORKDIR /tmp
CMD [ "phpunit"]

Then, ''docker build container'', and ''docker run -v /path/to/bibtexbrowser.dir:/tmp -ti 4f3591b79a60 /tmp/BibtexbrowserTest.php''

=====Related tools=====

Old-fashioned: [[http://nxg.me.uk/dist/bibhtml/|bibhtml]], [[http://www.litech.org/~wkiri/bib2html/|bib2html]], [[http://ilab.usc.edu/bibTOhtml/|bibtohtml]], [[http://people.csail.mit.edu/rahimi/bibtex/|bibtextohtml]], [[http://www.lri.fr/~filliatr/bibtex2html/|bibtex2html]], [[http://people.csail.mit.edu/mernst/software/bibtex2web.html |bibtex2web]], [[http://strategoxt.org/Stratego/BibtexTools|stratego bibtex module]] Unlike them, bibtexbrowser is dynamic, i.e. generates the HTML pages on the fly. Thus, you do not need to regenerate the static HTML files each time the bib file is changed.

Heavyweight: [[http://www.rennes.supelec.fr/ren/perso/etotel/PhpBibtexDbMng/|PHP BibTeX Database Manager]], [[http://gforge.inria.fr/projects/bibadmin/|bibadmin]], [[http://artis.imag.fr/Software/Basilic/|basilic]], [[http://phpbibman.sourceforge.net/|phpbibman]], [[http://www.aigaion.nl/|aigaion]], [[http://www.refbase.net/|refbase]], [[http://wikindx.sourceforge.net/|wikindx]], [[http://refdb.sourceforge.net/|refdb]] Unlike them, bibtexbrowser does not need a MySQL database.

Main competitor: [[http://code.google.com/p/simplybibtex/|SimplyBibtex]] has the same spirit, but the project seems dead since 2006

Misc: [[http://www.sat.ltu.se/publications/publications.m|This matlab script is similar]]

=====Copyright=====

This script is a fork from an excellent script of Joel Garcia, Leonardo Ruiz, and Yoonsik Cheon from the University of Texas at El Paso.

Bibtexbrowser is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

=====Discussion/Comments/Feedback=====