Skip to content

Instantly share code, notes, and snippets.

@btbytes
Created August 22, 2008 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btbytes/6707 to your computer and use it in GitHub Desktop.
Save btbytes/6707 to your computer and use it in GitHub Desktop.
MoinMoin macro to insert Disqus.com powered comment thread into the wiki page
# -*- coding: iso-8859-1 -*-
"""
DisqusThread - macro to insert Disqus.com powered comment thread into the wiki page
@copyright: 2008 Pradeep Kishore Gowda <pradeep@btbytes.com>
@license: GNU GPL, see COPYING for details.
2008-08-22 Pradeep Kishore Gowda
* Initial release v1.0.0
"""
from MoinMoin.wikiutil import get_unicode, get_bool, get_int, get_float, escape
embed_code = '''<div id="disqus_thread"></div><script type="text/javascript" sr\
c="http://disqus.com/forums/%(username)s/embed.js"></script><noscript><a href="\
http://%(username)s.disqus.com/?url=ref">View the discussion thread.</a></noscr\
ipt><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <sp\
an class="logo-disqus">Disqus</span></a>'''
def macro_DisqusThread(macro, username='testuser'):
username = get_unicode(macro.request, username)
username = strip_tags(username)
try:
return macro.formatter.rawHTML(embed_code % ({'username': username}))
except:
return macro.formatter.escapedText('Error inserting Disqus code')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment