Package: pelican-bib
Pelican BibOrganize your scientific publications with BibTeX in Pelican. The package is based on Vlad'spelican-bibtex. The current version is backward compatible and can replace thepelican-bibtexinstall of your current project.Installationpelican_bibrequirespybtex.pip install pybtexUsing pippip install pelican-bibAdd the plugin to thePLUGINSvariable:PLUGINS = ['pelican_bib', ...]As a SubmoduleIn your Pelican site:$ mkdir plugins
$ git submodule add https://github.com/scheunemann/pelican-bib plugins/pelican-bibAnd Pelican config:PLUGIN_PATHS = ['plugins/pelican_bib', ...]
PLUGINS = ['pelican_bib', ...]How to UseThis plugin reads a user-specified BibTeX file and populates the context with
a list of publications, ready to be used in your Jinja2 template.Configuration is simply:PUBLICATIONS_SRC = 'content/pubs.bib'If the file is present and readable, you will be able to find thepublicationsvariable in all templates.  It is a list of dictionaries with the following keys:keyis the BibTeX key (identifier) of the entry.yearis the year when the entry was published.  Useful for grouping by year in templates using Jinja'sgroupbytextis the HTML formatted entry, generated bypybtex.bibtexis a string containing BibTeX code for the entry, useful to make it
available to people who want to cite your work.pdf,slides,poster: in your BibTeX file, you can add these special fields,
for example:@article{
   foo13
   ...
   pdf = {/papers/foo13.pdf},
   slides = {/slides/foo13.html}
}This plugin will take all defined fields and make them available in the template.
If a field is not defined, the tuple field will beNone.  Furthermore, the
fields are stripped from the generated BibTeX (found in thebibtexfield).Split into lists of publicationsYou can add an extra field to each bibtex entry. This value of that field is a comma seperated list.
These values will become the keys of a listpublications_listscontaining the associated bibtex entries in your template.For example, if you want to associate an entry with two different tags (foo-tag,bar-tag),
you add the following field to the bib entry:@article{
   foo13
   ...
   tags = {foo-tag, bar-tag}
}In yourpelicanconf.pyyou'll need to set:PUBLICATIONS_SPLIT_BY = 'tags'In your template you can then access these lists with the variablespublications_lists['foo-tag']andpublications_lists['bar-tag'].If you want to assign all untagged entries (i.e. entries without
the field defined inPUBLICATIONS_SPLIT_BY) to a tag namedothers, set:PUBLICATIONS_UNTAGGED_TITLE = 'others'Page with a list of publicationsTo generate a page displaying the publications with one of the methods below, you need to add a template file and a page.1.) place the template file aspublications.htmlincontent/templatesand add it as direct template to your webpage. Add in yourpelicanconf.py:THEME_TEMPLATES_OVERRIDES.append('templates')2.) Create a page in your page folder, e.g., 'content/pages/publications.rst' with the following metadata in your content:Publications
############

:template: publicationsExample templatesExample content of thepublications.htmltemplate:{% extends "base.html" %}
{% block title %}Publications{% endblock %}
{% block content %}

<script type="text/javascript">
    function disp(s) {
        var win;
        var doc;
        win = window.open("", "WINDOWID");
        doc = win.document;
        doc.open("text/plain");
        doc.write("<pre>" + s + "</pre>");
        doc.close();
    }
</script>
<section id="content" class="body">
    <h1 class="entry-title">Publications</h1>
    <ul>
        {% for publication in publications %}
          <li id="{{ publication.key }}">{{ publication.text }}
          [&nbsp;<a href="javascript:disp('{{ publication.bibtex|replace('\n', '\\n')|escape|forceescape }}');">Bibtex</a>&nbsp;]
          {% for label, target in [('PDF', publication.pdf), ('Slides', publication.slides), ('Poster', publication.poster)] %}
            {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
          {% endfor %}
          </li>
        {% endfor %}
    </ul>
</section>
{% endblock %}(Note: that we are escaping the BibTeX string twice in order to properly display it.
This can be achieved usingforceescape)Sorting entriesThe entries can be sorted by one of the attributes, for example, if you want to sort the entries by date, your unordered list would look like the following:...
    <ul>
        {% for publication in publications|sort(True, attribute='year') %}
          <li id="{{ publication.key }}">{{ publication.text }}
          [&nbsp;<a href="javascript:disp('{{ publication.bibtex|replace('\n', '\\n')|escape|forceescape }}');">Bibtex</a>&nbsp;]
          {% for label, target in [('PDF', publication.pdf), ('Slides', publication.slides), ('Poster', publication.poster)] %}
            {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
          {% endfor %}
          </li>
        {% endfor %}
    </ul>
...Thesort builtin filterwas added in version 2.6 of jinja2.Grouping entriesTo group entries by year,...
<ul>
  {% for grouper, publist in publications|groupby('year')|reverse %}
  <li> {{grouper}}
    <ul>
    {% for publication in publist %}
      <li id="{{ publication.key }}">{{ publication.text }}
      [&nbsp;<a href="javascript:disp('{{ publication.bibtex|replace('\n', '\\n')|escape|forceescape }}');">Bibtex</a>&nbsp;]
      {% for label, target in [('PDF', publication.pdf), ('Slides', publication.slides), ('Poster', publication.poster)] %}
        {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
      {% endfor %}
      </li>
    {% endfor %}
    </ul></li>
  {% endfor %}
</ul>
...Using lists of publicationsAs described above, lists of publications are stored inpublications_lists.
You can replacepublicationsfrom the previous example withpublications_lists['foo-tag']to only show the publications with tagged withfoo-tag.You can also iterate over the map and present all bib entries of each list.
The section of the previous example changes to:...
<section id="content" class="body">
    <h1 class="entry-title">Publications</h1>
    {% for tag in publications_lists %}
        {% if publications_lists|length > 1 %}
            <h2>{{tag}}</h2>
        {% endif %}
	       <ul>
	       {% for publication  in  publications_lists[tag] %}
            <li id="{{ publication.bibkey }}">{{ publication.text }}
            [&nbsp;<a href="javascript:disp('{{ publication.bibtex|replace('\n', '\\n')|escape|forceescape }}');">Bibtex</a>&nbsp;]
            {% for label, target in [('PDF', publication.pdf), ('Slides', publication.slides), ('Poster', publication.poster)] %}
                {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
            {% endfor %}
            </li>
	       {% endfor %}
	       </ul>
	   {% endfor %}
</section>
...