logo4 Evolution is progress—                          
progress is creativity.        
vline

Implement Zotero citations into a Django application

view wiki view wiki view wiki view wiki

I wanted to provide a simple method to create citations from my web pages. I use Zotero, so I would like to offer a one-click way to include my pages into any Zotero database.

Unfortunately, googling Django AND Zotero did not provide any clue. I did not find an application or or code snipped. Finally I found an easy solution through metadata. I created this page to provide links to resources and my first simple copy-and-past solution.

A good point to start from is this Zotero page http://www.zotero.org/support/dev/exposing_metadata. It offers many solutions that can be implemented in a django project. I found it a little bit disappointing that although a wordpress plug-in exists there is no django plug-in available from that web page.

Embedded Metadata

I found the Embedded Metadata approach most convenient. The easiest way would be to implement the Highwire key-value system, but as I understand the page's example this is only applicable for journal articles. It seems to me a bit awkward to represent a web page as a journal article, so I used the more flexible solution defined by Dublin Core description. I found this link even more useful as it lists all the key attributes available. Unfortunately, that resource does not provide enough examples to correctly format dates, for instance.

My code snippet has to be included into the templates follow below. The base template should contain:

<head profile="http://dublincore.org/documents/2008/08/04/dc-html/">
....
  {% block extrahead %}{% endblock %}
....
</head>

and the application specific template:

{% block extrahead %}
....
    <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" >
    <meta name="DC.title" content="{{ rev.title }}" >
    <meta name="DC.issued" content="{{ rev.modified }}" >
    <meta name="DC.created" content="{{ rev.created }}" >
    <meta name="DC.creator" content="Mato Nagel" >
....
{% endblock %}
</head>

But this solution has its drawbacks. The number of DC terms is quite limited.

COinS

COinS has also a good Wikipedia representation. The idea is to provide an empty span tag that in its title attribute contains all the information necessary to build the reference information. The Wikipedia example below contains white spaces that of course have to be removed from the title string.

<span class="Z3988"
  title="ctx_ver=Z39.88-2004&amp;
  rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;
  rft.genre=book&amp;
  rft.btitle=Hallo+Welt&amp;
  rft.title=Hallo+Welt&amp;
  rft.aulast=Mustermann&amp;
  rft.aufirst=Max&amp;
  rft.au=Max+Mustermann&amp;
  rft.date=2005&amp;
  rft.pub=Wikipedia-Press&amp;
  rft.place=Musterstadt">
</span>

For this technique journal and book templates are available. Here formats for other publication types are published.

The implemetation of that technique into django requires a function that creates the title attribute.

unAPI

By contrast to all previous solution in which all the data are included into the web page, unAPI requires a server that provided bibliographical data for a given web page, so the web page only provides the server address and the id, and all the bibliographical data are retrieved by s second request.

The server address is put into the head instruction.

<head> 
.....
<link rel="unapi-server" type="application/xml" title="unAPI" href="http://my-unapi-server/"> 
</head>

The id is put into the body. The span tag necessary but helps to suppress the essential abbr tag.

<span style="display:none;"> 
   <abbr class="unapi-id" title="000409718">unapi</abbr> 
</span>

Now by a second request the unapi can be retrieved by that get request:

http://vlib.mpg.de/aleph-cgi/unapi.cgi?format=mods&id=000206951

mods is a quite popular format. Most aunapi-server provide different formats you may choose the one your client prefers.


Tags: Software


Categories: Software

 
   

(c) Mato Nagel, Weißwasser 2004-2013, Disclaimer