Skip to content

Commit

Permalink
added simplistic disqus comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dduan committed Jul 12, 2010
1 parent f29bd8f commit b071075
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions sophie/models.py
Expand Up @@ -14,6 +14,7 @@ class Blog(models.Model):
full_entry_in_page = models.BooleanField(default = True)
full_entry_in_feed = models.BooleanField(default = True)
g_analytics_tracking_id = models.CharField(max_length=50, blank=True)
disqus_shortname = models.CharField(max_length=200, blank=True)

class Meta:
ordering = ['id']
Expand Down
31 changes: 31 additions & 0 deletions sophie/templates/sophie/entry_details.html
@@ -1,5 +1,18 @@
{% extends 'sophie/base.html' %}

{% block pre_body %}
{% if blog.disqus_shortname %}
<script type="text/javascript">
var disqus_shortname = '{{ blog.disqus_shortname }}';
(function () {
var s = document.createElement('script'); s.async = true;
s.src = 'http://disqus.com/forums/{{ blog.disqus_shortname }}/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
{% endif %}
{% endblock pre_body %}

{% block title %}
{{ entry.title }} - {{ blog.title }}
{% endblock title %}
Expand All @@ -19,4 +32,22 @@ <h2><a href="{{ entry.get_absolute_url }}">{{ entry.title }}</a></h2>
<span class="entry-author">{{ entry.author.get_full_name}}</span>
</div>
<div class="entry-body">{{ entry.body_html|safe }}</div>

{% if blog.disqus_shortname %}
<hr />
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://danmarner-cnblog.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=danmarner-cnblog">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>
{% endif %}

{% endblock main %}

0 comments on commit b071075

Please sign in to comment.