from django.template import Library
from django.conf import settings

register = Library()


@register.inclusion_tag("blog/disqus.html", takes_context=True)
def show_comments(context):
    if not settings.COMMENTING:
        return {}

    new_context = {
        "disqus_url": context["request"].get_raw_uri(),
        "disqus_identifier": context["post"].slug
    }

    return new_context
