<commit_before>__license__ = "Apache 2.0"
__copyright__ = "Copyright 2008 nb.io"
__author__ = "<NAME> - <EMAIL>"


from django.template import Library, Node
from django.conf import settings
from nbio.django.shortcuts import build_url


class StaticUrlsNode(Node):
    def __init__(self, path):
        self.path = path

    def render(self, context):
        request = context.get('request')
        return build_url(request, host=settings.HOSTS['static'], path=self.path)


def static_url(parser, token):
    try:
        tag_name, path = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[0]
    return StaticUrlsNode(path)


register = Library()
register.tag("static_url", static_url)<commit_msg>added app_url template tag for sitemap.xml support<commit_after>__license__ = "Apache 2.0"
__copyright__ = "Copyright 2008 nb.io"
__author__ = "<NAME> - <EMAIL>"


from django.template import Library, Node
from django.conf import settings
from nbio.django.shortcuts import build_url


class UrlNode(Node):
    def __init__(self, host=None, path=''):
        self.host = host
        self.path = path
        if not self.path.startswith('/'):
            self.path = '/' + self.path

    def render(self, context):
        request = context.get('request')
        return build_url(request, host=self.host, path=self.path)


def static_url(parser, token):
    try:
        path = ''
        tag_name, path = token.split_contents()
    except ValueError:
        pass
    return UrlNode(host=settings.HOSTS['static'], path=path)


def app_url(parser, token):
    try:
        path = ''
        tag_name, path = token.split_contents()
    except ValueError:
        pass
    return UrlNode(host=settings.HOSTS['app'], path=path)


register = Library()
register.tag("static_url", static_url)
register.tag("app_url", app_url)
{'fraction_non_alphanumeric': 0.11758584807492195, 'fraction_numerical': 0.006763787721123829, 'mean_word_length': 3.4929906542056073, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '7362183', 'n_tokens_mistral': 606, 'n_tokens_neox': 582, 'n_words': 149}