<commit_before>from django import template
from wagtail.wagtailadmin import edit_bird, hooks
from wagtail.wagtailcore.models import Page

register = template.Library()


@register.simple_tag(takes_context=True)
def wagtail_edit_bird(context, current_page=None, items=None):
    # Find page object
    if not current_page:
        if 'self' in context and isinstance(context['self'], Page):
            current_page = context['self']
        else:
            return ''

    # Find request object
    request = context['request']

    # Get items
    if items is None:
        if hasattr(request, 'wagtail_edit_bird_items'):
            items = request.wagtail_edit_bird_items
        else:
            items = [
                edit_bird.EditPageItem(current_page),
            ]
    for fn in hooks.get_hooks('construct_wagtail_edit_bird'):
        fn(request, items)

    # Render edit bird
    edit_bird_rendered = edit_bird.render_edit_bird(request, items)

    if edit_bird_rendered:
        # Disable cache
        request.disable_cache = True

        return edit_bird_rendered
    else:
        return ''<commit_msg>Removed disable_cache from wagtail_edit_bird_tag This was used to disable caching when the edit bird was rendered. It is no longer needed.<commit_after>from django import template
from wagtail.wagtailadmin import edit_bird, hooks
from wagtail.wagtailcore.models import Page

register = template.Library()


@register.simple_tag(takes_context=True)
def wagtail_edit_bird(context, current_page=None, items=None):
    # Find page object
    if not current_page:
        if 'self' in context and isinstance(context['self'], Page):
            current_page = context['self']
        else:
            return ''

    # Find request object
    request = context['request']

    # Get items
    if items is None:
        if hasattr(request, 'wagtail_edit_bird_items'):
            items = request.wagtail_edit_bird_items
        else:
            items = [
                edit_bird.EditPageItem(current_page),
            ]
    for fn in hooks.get_hooks('construct_wagtail_edit_bird'):
        fn(request, items)

    # Render edit bird
    return edit_bird.render_edit_bird(request, items)
{'fraction_non_alphanumeric': 0.07793384685092886, 'fraction_numerical': 0.0, 'mean_word_length': 2.86013986013986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '673275', 'n_tokens_mistral': 644, 'n_tokens_neox': 631, 'n_words': 166}