<commit_before># -*- encoding: utf-8 -*-


from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.urls import reverse

register = template.Library()


@register.filter(is_safe=True)
def authorlink(author):
    url = reverse('search')+'?authors='+author.name.full.replace(' ','+')
    if author.researcher_id:
        url = author.researcher.url
    elif author.orcid:
        url = reverse('researcher-by-orcid', kwargs={'orcid':author.orcid})
    return mark_safe('<a href="'+url+'" rel="nofollow">'+escape(str(author.name))+'</a>')


@register.filter(is_safe=True)
def publication(publi):
    result = ''
    if publi.publisher_id:
        if publi.publisher.canonical_url:
            result += '<a href="'+publi.publisher.canonical_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 != str(publi.journal):
        result += escape(str(publi.container))+', '
    if publi.journal:
        result += '<emph>'+escape(str(publi.journal.title))+'</emph>'
    else:<commit_msg>Only add rel=nofollow for author links that do not link to an existing profile<commit_after># -*- encoding: utf-8 -*-


from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.urls import reverse

register = template.Library()


@register.filter(is_safe=True)
def authorlink(author):
    url = reverse('search')+'?authors='+author.name.full.replace(' ','+')
    if author.researcher_id:
        url = author.researcher.url
    elif author.orcid:
        url = reverse('researcher-by-orcid', kwargs={'orcid':author.orcid})
    nofollow = ' rel="nofollow"' if not author.researcher_id else ''
    return mark_safe('<a href="'+url+'"'+nofollow+'>'+escape(str(author.name))+'</a>')


@register.filter(is_safe=True)
def publication(publi):
    result = ''
    if publi.publisher_id:
        if publi.publisher.canonical_url:
            result += '<a href="'+publi.publisher.canonical_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 != str(publi.journal):
        result += escape(str(publi.container))+', '
    if publi.journal:
        result += '<emph>'+escape(str(publi.journal.title))+'</emph>'
    else:
{'fraction_non_alphanumeric': 0.16221447928765, 'fraction_numerical': 0.0007742934572202865, 'mean_word_length': 3.5896980461811725, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6412346', 'n_tokens_mistral': 826, 'n_tokens_neox': 831, 'n_words': 159}