diff --git a/snipts/templates/snipts/detail.html b/snipts/templates/snipts/detail.html index 531a1ef..6fe7ed0 100644 --- a/snipts/templates/snipts/detail.html +++ b/snipts/templates/snipts/detail.html @@ -21,21 +21,23 @@ {% with 'true' as detail %} {% include "snipts/snipt-list.html" %} {% endwith %} -
- + (function() { + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); + })(); + + {% endif %} {% endblock %} diff --git a/snipts/templatetags/snipt_tags.py b/snipts/templatetags/snipt_tags.py index d10d22a..7f967bb 100644 --- a/snipts/templatetags/snipt_tags.py +++ b/snipts/templatetags/snipt_tags.py @@ -3,7 +3,7 @@ from django import template from templatetag_sugar.register import tag from templatetag_sugar.parser import Variable, Constant -from snipts.models import Favorite +from snipts.models import Favorite, Snipt import hashlib @@ -29,6 +29,19 @@ def snipt_is_favorited_by_user(context, asvar): return '' +@tag(register, []) +def snipts_count_for_user(context): + + user = context['request'].user + + if user.is_authenticated(): + snipts = Snipt.objects.filter(user=user).values('id').count() + else: + snipts = 0 + + return snipts + + @register.filter def md5(string): return hashlib.md5(string.lower()).hexdigest() diff --git a/templates/base.html b/templates/base.html index baefdb5..8daf54e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{% load compress %} +{% load compress snipt_tags %} @@ -243,19 +243,19 @@ {% include 'snipts/snipt-edit-js-template.html' %} {% if not debug %} - + {% else %} - + {% if not debug %} + + + {% endif %} {% endif %}