====== BibTeX Plugin for Dokuwiki ====== Since this site is also my professional webpage, I have a need for referencing articles I have read or written (see [[public:subject]] and [[public:bibliography]] for example). A previous version of my site was using [[http://www.pmwiki.org|PmWiki]] and I had developped with some friends of mine a BibTeX plugin ([[http://www.pmwiki.org/wiki/Cookbook/BibtexRef|BibtexRef]]) to fit our needs and the ones of our research teams. When I switched to Dokuwiki, a plugin already existed ([[http://stat.genopole.cnrs.fr/~cambroise/doku.php?id=softwares:dokuwikibibtexplugin|bibtex]]) but it was not sufficient for what I expected. My code is a modification of both projects that has enough features for what I need, and probably the potential to be extended if needed. ===== Installation ===== * unzip the plugin ({{projects:bibtex.zip}}) in lib/plugins * install the 2 additional files given [[#citation pages|here]] ===== Markup ===== There are two commands available for wiki pages: * %%%% which displays all the citations contained in the page %%bib:value_file%%, with formatting style %%value_style%% ordered by %%value_sort%% * %%{[file:reference]}%% which allows to cite a reference extracted from a file ==== Example 1 ==== %%%% parses the content of [[bib:hodique]] and outputs : ==== Example 2 ==== %%{[hodique:ghsr06ijpeds]}%% looks for the reference ghsr06ijpeds in file [[bib:hodique]] and outputs : {[hodique:ghsr06ijpeds]} ===== Storage ===== The data for building the citations and references are stored in one or more wiki pages that reflect .bib files. For example, in this site there are 2 bibtex "files" : [[bib:hodique|hodique.bib]] for my publications and [[bib:biblio|biblio.bib]] for related works by others. Please note that the plugin will parse the content of the **underlying file**, not the interpreted page, so that it is very important that no additional markup is present in these. I find it convenient to prefix every single line of my bib pages with two spaces, so that the entire data is not interpreted by the wiki engine while remaining valid bibtex syntax : see the source of [[bib:hodique|hodique.bib]] for example. ===== Citation pages ===== When you cite a reference (or when you click the (BIB) link at the end of a citation), you have access to a dedicated page that summarizes the paper. Of course this page is not a wiki page, it is generated on demand from the data in the bibtex files. To obtain this, I had to add 2 files to my Dokuwiki installation : * a script to allow displaying such content (lib/exe/bib.php). It is called //via// a rewrite rule in .htaccess : %%RewriteRule ^_bib/(.*)/(.*) lib/exe/bib.php?file=$1&ref=$2 [QSA,L]%% expandMacro = TRUE; $parse->fieldExtract = TRUE; $parse->removeDelimit = TRUE; $parse->loadBibtexString($data); $parse->extractEntries(); list($preamble, $strings, $entries) = $parse->returnArrays(); $ref = $_REQUEST['ref']; foreach ($entries as $entry) { if (trim($entry['bibtexCitation']) == $ref) return rawOutput($entry); } } include(template('bib.php')); //Setup VIM: ex: et ts=2 enc=utf-8 : ?> * a theme file to render it (lib/tpl/artic/bib.php since I use Artic theme from http://chimeric.de). You may adapt your own theme instead. The important thing is %%%% where the page main content should be. Also I suppressed action links in those generated pages since they don't make sense. * additional editing by * @author Michael Klier * @link http://chimeric.de/wiki/dokuwiki/templates/arctic/ * */ require_once(dirname(__FILE__).'/tpl_functions.php'); $sepchar = tpl_getConf('sepchar'); ?> <?php tpl_pagetitle()?> [<?php echo strip_tags($conf['title'])?>]
[[]]
===== ToDo ===== This plugin is far from being complete. Here are the things that definitely should be done: * code cleanup. This is a hack, and not a really nice one * introduce configuration variables * allow more precise selection of papers to display (by author, by date, whatever) * stop depending on the storage backend as it could change