<commit_before>
from django import template
from django.utils.safestring import mark_safe

register = template.Library()

@register.simple_tag
def paginator(page_obj, context=3):
    number = page_obj.number
    context_left = range(max(number-context, 2), number)
    context_right = range(number+1, min(number+context+1, page_obj.paginator.num_pages+1))

    lines = []

    if page_obj.has_previous():
        lines.append(u'<a class="number first" href="?page=1">1</a>')
        if number-context > 2:
            lines.append(u'<span class="ellipses">...</span>')

        for i in context_left:
            lines.append(u'<a class="prev number" href="?page=%d">%d</a>' % (i, i))

    lines.append(u'<span class="current number">%d</span>' % (number,))

    if page_obj.has_next():
        for i in context_right:
            lines.append(u'<a class="next number" href="?page=%d">%d</a>' % (i, i))

    return mark_safe(u'\n'.join(lines))<commit_msg>paginator: Add "Previous" and "Next" links<commit_after>
from django import template
from django.utils.safestring import mark_safe

register = template.Library()

@register.simple_tag
def paginator(page_obj, context=3):
    number = page_obj.number
    context_left = range(max(number-context, 2), number)
    context_right = range(number+1, min(number+context+1, page_obj.paginator.num_pages+1))

    lines = []

    if page_obj.has_previous():
        lines.append(u'<a class="number prev" href="?page=%d">Previous</a>' % (number-1,))
        lines.append(u'<a class="number first" href="?page=1">1</a>')
        if number-context > 2:
            lines.append(u'<span class="ellipses">...</span>')

        for i in context_left:
            lines.append(u'<a class="prev number" href="?page=%d">%d</a>' % (i, i))

    lines.append(u'<span class="current number">%d</span>' % (number,))

    if page_obj.has_next():
        for i in context_right:
            lines.append(u'<a class="next number" href="?page=%d">%d</a>' % (i, i))
        lines.append(u'<a class="number prev" href="?page=%d">Next</a>' % (number+1,))

    return mark_safe(u'\n'.join(lines))
{'fraction_non_alphanumeric': 0.17902692489371752, 'fraction_numerical': 0.008502598016060462, 'mean_word_length': 3.654945054945055, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '6073660', 'n_tokens_mistral': 740, 'n_tokens_neox': 725, 'n_words': 144}