2 This module enables support fot the Disqus comment system.
4 This module requires the following configuration parameters:
6 disqus_short_name - The short name of the website account
9 The following parameters are optional:
11 disqus_developer - A boolean value for allowing testing on a private
12 server. See http://disqus.com/help/#faq-14
14 The comments are enabled for the flavours that contain a template file named:
17 For example, for enabling the comments for the flavour 'html', an empty file
18 named 'disqus-enabled.html' must be created under the directory 'html.flav'.
20 This program is distributed under the BSD license.
23 __author__ = "Juan Manuel Caicedo"
25 __url__ = "http://cavorite.com/labs/pyblosxom-disqus/"
26 __description__ = "Allows to use the service Disqus for comments on each blog entry."
30 Sets the defaults values for the optional configuration properties.
32 request = args["request"]
33 config = request.getConfiguration()
35 if not config.has_key('disqus_developer'):
36 config['disqus_developer'] = False
38 def verify_installation(request):
40 Verifies the plugin installation checking for the required configuration properties.
42 config = request.getConfiguration()
44 if not config.has_key('disqus_short_name'):
45 print 'The "short name" of the Disqus account dmust be specified in the config file'
53 Adds the Disqus code for embedding the comments.
55 renderer = args['renderer']
57 template = args['template']
58 request = args["request"]
59 data = request.getData()
60 config = request.getConfiguration()
62 if len(renderer.getContent()) == 1 \
63 and renderer.flavour.has_key('disqus-enabled') \
64 and not entry.has_key("nocomments"):
66 short_name = config['disqus_short_name']
67 template = '<div id="disqus_thread"></div>'
68 if config.get('disqus_developer'):
69 template = template + '''
70 <script type="text/javascript" >
71 var disqus_developer = 1;
75 template = template + '''<script type="text/javascript" src="http://disqus.com/forums/%(short_name)s/embed.js"></script><noscript><a href="http://%(short_name)s.disqus.com/?url=ref">View the discussion thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>''' % {'short_name': short_name}
77 args['template'] = args['template'] + template