<commit_before>from datetime import date, datetime
from django.conf import settings
from django.template import Library
from fluent_blogs.models import get_entry_model
from fluent_blogs.models.query import query_entries, query_tags
from tag_parser import template_tag
from tag_parser.basetags import BaseAssignmentOrInclusionNode, BaseAssignmentOrOutputNode

BlogPage = None

HAS_APP_URLS = 'fluent_pages' in settings.INSTALLED_APPS
if HAS_APP_URLS:
    # HACK: accessing BlogPage directly. Apps are not completely separated this way.
    # Should have some kind of registry and filter system (like middleware) instead.
    from fluent_blogs.pagetypes.blogpage.models import BlogPage


register = Library()


@register.tag
def blogurl(parser, token):
    """
    Compatibility tag to allow django-fluent-blogs to operate stand-alone.
    Either the app can be hooked in the URLconf directly, or it can be added as a pagetype of django-fluent-pages.
    For the former, URL resolving works via the normal '{% url "viewname" arg1 arg2 %}' syntax.
    For the latter, the URL resolving works via '{% appurl "viewname" arg1 arg2 %}' syntax.
    """
    if HAS_APP_URLS:
        from fluent_pages.templatetags.appurl_tags import appurl
        return appurl(parser, token)
    else:
        # Using url from future, so the syntax is the same modern style.
        from django.templatetags.future import url
        return url(parser, token)


@template_tag(register, 'get_entry_url')
class GetEntryUrl(BaseAssignmentOrOutputNode):
    """
    Get the URL of a blog entry.

    When using django-fluent-pages, this takes the current ``page`` variable into account.
    It makes sure the blog entry is relative to the current page.

    When django-fluent-pages is not used, using this is identical to calling ``entry.get_absolute_url()``.<commit_msg>Fix Django 1.9 issue with `{% blogurl .. %}`<commit_after>from datetime import date, datetime

import django
from django.conf import settings
from django.template import Library
from fluent_blogs.models import get_entry_model
from fluent_blogs.models.query import query_entries, query_tags
from tag_parser import template_tag
from tag_parser.basetags import BaseAssignmentOrInclusionNode, BaseAssignmentOrOutputNode

BlogPage = None

HAS_APP_URLS = 'fluent_pages' in settings.INSTALLED_APPS
if HAS_APP_URLS:
    # HACK: accessing BlogPage directly. Apps are not completely separated this way.
    # Should have some kind of registry and filter system (like middleware) instead.
    from fluent_blogs.pagetypes.blogpage.models import BlogPage


register = Library()


@register.tag
def blogurl(parser, token):
    """
    Compatibility tag to allow django-fluent-blogs to operate stand-alone.
    Either the app can be hooked in the URLconf directly, or it can be added as a pagetype of django-fluent-pages.
    For the former, URL resolving works via the normal '{% url "viewname" arg1 arg2 %}' syntax.
    For the latter, the URL resolving works via '{% appurl "viewname" arg1 arg2 %}' syntax.
    """
    if HAS_APP_URLS:
        from fluent_pages.templatetags.appurl_tags import appurl
        return appurl(parser, token)
    else:
        # Using url from future, so the syntax is the same modern style.
        if django.VERSION < (1, 8):
            from django.templatetags.future import url
        else:
            from django.template.defaulttags import url
        return url(parser, token)


@template_tag(register, 'get_entry_url')
class GetEntryUrl(BaseAssignmentOrOutputNode):
    """
    Get the URL of a blog entry.

    When using django-fluent-pages, this takes the current ``page`` variable into account.
    It makes sure the blog entry is relative to the current page.

    When django-fluent-pages is not used, using this is identical to calling ``entry.get_absolute_url()``.
{'fraction_non_alphanumeric': 0.06711758584807492, 'fraction_numerical': 0.003121748178980229, 'mean_word_length': 3.867088607594937, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5992426', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1069, 'n_words': 420}