Skip to content

Instantly share code, notes, and snippets.

@ojii
Created April 4, 2011 13:08
Show Gist options
  • Save ojii/901604 to your computer and use it in GitHub Desktop.
Save ojii/901604 to your computer and use it in GitHub Desktop.
<div id="disqus_thread"></div>
<script type="text/javascript">{% if debug %}
var disqus_developer = 1;{% endif %}
var disqus_shortname = '{{ shortname }}';
var disqus_identifier = 'idguid={{ identifier }}';
var disqus_url = '{{ url }}';
(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);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
from classytags.arguments import Argument
from classytags.core import Options
from classytags.helpers import InclusionTag
from django import template
from django.conf import settings
register = template.Library()
class Disqus(InclusionTag):
options = Options(
Argument('identifier'),
Argument('namespace', required=False),
)
template = 'inc/disqus.html'
def get_context(self, context, identifier, namespace):
url = 'http://www.django-cms.org%s' % context['request'].path
if namespace:
identifier = '%s-%s' % (namespace, identifier)
context = {
'url': url,
'identifier': identifier,
'shortname': settings.DISQUS_SHORTNAME,
'debug': settings.DEBUG,
}
return context
register.tag(Disqus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment