# -*- encoding: utf-8 -*-
from __future__ import unicode_literals

from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse

register = template.Library()

@register.filter(is_safe=True)
def authorlink(author):
    if author.researcher_id:
        return mark_safe('<a href="'+author.researcher.url+'">'+escape(unicode(author.name))+'</a>')
    else:
        return mark_safe(escape(unicode(author.name)))

@register.filter(is_safe=True)
def publication(publi):
    result = ''
    if publi.publisher_id:
        if publi.publisher.url:
            result += '<a href="'+publi.publisher.url+'">'+escape(publi.publisher.name)+'</a>, '
        else:
            result += escape(publi.publisher.name)+', '
    if publi.pubtype == 'book-chapter' and publi.journal and publi.container and publi.container != unicode(publi.journal):
        result += escape(unicode(publi.container))+', '
    if publi.journal:
        result += '<emph>'+escape(unicode(publi.journal.title))+'</emph>'
    else:
        result = escape(unicode(publi.journal_title))
    if publi.issue or publi.volume or publi.pages or publi.pubdate:
        result += ', '
    if publi.issue:
        result += '<strong>'+escape(unicode(publi.issue))+'</strong>'
    if publi.volume:
        result += '('+escape(unicode(publi.volume))+')'
    if (publi.issue or publi.volume) and publi.pubdate:
        result += ', '
    if publi.pubdate:
        result += escape(unicode(str(publi.pubdate.year)))
    return mark_safe(result)

@@ -624,16 +624,26 @@
 blisher.
+canonical_
 url:%0A   
@@ -685,24 +685,34 @@
 i.publisher.
+canonical_
 url+'%22%3E'+esc

Fix link to publisher in publiListItem.html