Skip to main content

BibTeX references for Wagtail

Project description

Wagtail References Build Status

BibTeX based bibliography entries, as wagtail snippets

Templates

"But, where are the templates?!" is a natural question. Answer: There aren't any templates or tags so far... I run all my wagtail installations in headless mode with a react front end, so can only justify putting in place the templates for managing the references on wagtail.

If you'd like to do so, I'm very open to collaboration :)

I might get around to adding some templates for the listings shown in wagtail, as they're currently pretty ugly (showing the raw BibTeX) but will see if this project gets some traction and users first. Bottom line: Star this repo on Github , so I know you're reading this and interested!

Displaying references on the front end

I recommend bibtex-js for parsing and displaying the bibtex on your front end. It doesn't convert tex strings, so you'll want to ensure the WAGTAILREFERENCES_ENSURE_UNICODE setting is True.

Roadmap

I'd like to include:

  • A better snippet editor, possibly using a json editor component and allowing the user to switch between tex and json
  • Improved listings template in wagtail
  • A ListSerializer for serializing out multiple references as a bibjson collection
  • A matching react component library for the front end (front end offerings are a hassle)
  • An HTML renderer and viewset

Requirements

Wagtail References is tested on Django 2.1 or later and Wagtail 2.3 or later.

Supported Versions

Python: 3.6

Django: 2.1

Wagtail: 2.3

Getting started

Installing from pip:

pip install wagtail_references

Adding to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'wagtail_references',
    ...
]

Running the migrations:

python manage.py migrate wagtail_references

Reference Model

There's only one database model Reference, which is registered as a snippet in Wagtail, making it searchable and selectable. The model has a (required) slug field which is automatically set by signal handlers which extract and normalise the reference key.

For example, if you have the following bibtex entry:

@article{Clark2017a,
author = {Clark, Thomas H. E. and Lueck, Rolf G. and Hay, Alex E. and Davey, Thomas and Stern, Peter and Horwitz, Rachel and Pearson, Nicola},
journal = {Proc. of the 12th European Wave and Tidal Energy Conference},
pages = {7},
title = {{InSTREAM : Measurement , Characterisation and Simulation of Turbulence from Test Tank to Ocean .}},
year = {2017}
}

the slug will automatically be set to clark2017a. Duplicate slugs are not valid, which is how we maintain uniqueness across all the references added to the CMS.

The reference model comprises a bibtex field (containing the bibtex string, raw) and a bibjson field. Yes, I know this is duplication of data. But I'd rather do that than incur the cost of re-parsing the data every time I want to serialize it out in a different form. I could've chosen to cache it, but then I don't know how much memory you folks have, and don't want to screw your cache if you're managing a lot of references). It was a judgement call. Use-case and an alternative solution? File an issue. The bibjson is stored natively as JSON if you have POSTGRES, otherwise as a string (thanks to django-jsonfield).

Django Settings

The following settings can be defined in your SETTINGS.py:

  • WAGTAILREFERENCES_CONVERT_BIBTEX (default: False) Before saving new records, the record will be homogenized to strict latex. This forces a conversion to unicode and, for example, adds braces to force capitalization.
  • WAGTAILREFERENCES_ENABLE_UNICODE (default: True) If enabled, items such as "C{\"o}ze" will be converted to their unicode equivalents. If you're using entries in a LaTeX rendering engine, this isn't necessary. If you're using them to rendering HTML (which you probably are, this is a web CMS after all), you probably want this.
  • WAGTAILREFERENCES_COLLECTION_NAME (default: None) Applies a default collection name to records rendered in bibjson form.

Examples

For your and our testing purposes, it's useful to have some examples to hand, so I've prepared some in the examples.py file, which simply contains a series of different bibtex references.

If you encounter awkward references or ones which won't validate, please post them into a github issue so I can help diagnose and add them for test.

Thanks

Thanks are due to internaut for providing the bibtex-json converter. Their code isn't licensed so I don't know how to credit it other than saying thanks!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_references-0.2.1.tar.gz (24.7 kB view details)

Uploaded Source

File details

Details for the file wagtail_references-0.2.1.tar.gz.

File metadata

  • Download URL: wagtail_references-0.2.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

File hashes

Hashes for wagtail_references-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4d2ac1aaf7a09a57cc4581b2a62d41ebc95b636952b81c5826eb492bae138bd0
MD5 dc38309258ad0283ac7d71a2a69938be
BLAKE2b-256 aea1e78df89ec4e51dca094a89171d4520e684d87cef9f2acbf6d61db287724f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page