Skip to content

Commit

Permalink
Adds disqus integration
Browse files Browse the repository at this point in the history
  • Loading branch information
href committed Jun 20, 2012
1 parent e491135 commit 23e1095
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 13 deletions.
3 changes: 2 additions & 1 deletion syte/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def compress_js():
if settings.INSTAGRAM_INTEGRATION_ENABLED:
js_files.append('components/instagram.js')


if settings.DISQUS_INTEGRATION_ENABLED:
js_files.append('components/disqus.js')

combined = ''
for js in js_files:
Expand Down
2 changes: 2 additions & 0 deletions syte/context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ def site_pages(request):
context['DRIBBBLE_INTEGRATION_ENABLED'] = settings.DRIBBBLE_INTEGRATION_ENABLED
context['INSTAGRAM_INTEGRATION_ENABLED'] = settings.INSTAGRAM_INTEGRATION_ENABLED
context['GOOGLE_ANALYTICS_TRACKING_ID'] = settings.GOOGLE_ANALYTICS_TRACKING_ID
context['DISQUS_INTEGRATION_ENABLED'] = settings.DISQUS_INTEGRATION_ENABLED
context['DISQUS_SHORTNAME'] = settings.DISQUS_SHORTNAME

return context
20 changes: 20 additions & 0 deletions syte/static/js/components/disqus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var _embed_disqus = 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);
};

var _embed_disqus_count = function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}

var embed_disqus = function() {
setTimeout(_embed_disqus, 500);
}

var embed_disqus_count = function() {
setTimeout(_embed_disqus_count, 500);
}
7 changes: 5 additions & 2 deletions syte/static/templates/blog-post-audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ <h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
{{#if caption}}
{{{ caption }}}
{{/if}}
{{#if tags }}
<footer>
{{#if tags }}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}

<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}
</article>
6 changes: 4 additions & 2 deletions syte/static/templates/blog-post-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ <h2><a href="{{url}}">Link: {{title}}</a></h2>
<h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
</hgroup>
{{{ description }}}
{{#if tags}}
<footer>
{{#if tags}}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}
<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}
</article>
8 changes: 6 additions & 2 deletions syte/static/templates/blog-post-photo.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ <h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
{{#if caption}}
{{{ caption }}}
{{/if}}
{{#if tags }}

<footer>
{{#if tags }}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}
<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}

</article>
6 changes: 4 additions & 2 deletions syte/static/templates/blog-post-quote.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ <h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
{{#if source}}
<p>{{{ source }}}</p>
{{/if}}
{{#if tags }}
<footer>
{{#if tags }}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}
<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}
</article>
8 changes: 6 additions & 2 deletions syte/static/templates/blog-post-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ <h2><a href="/post/{{ id }}">{{ title }}&nbsp;</a></h2>
<h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
</hgroup>
{{{ body }}}
{{#if tags}}

<footer>
{{#if tags}}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}

<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}
</article>
7 changes: 5 additions & 2 deletions syte/static/templates/blog-post-video.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ <h3><a href="#{{ id }}">{{ formated_date }}</a></h3>
<p>
<a href="{{ permalink_url }}" class="no-border"><img src="{{ thumbnail_url }}" /></a>
</p>
{{#if tags }}
<footer>
{{#if tags }}
<h4>Tags</h4>
<ul class="tags">
{{#each tags}}
<li><a href="/tags/{{ this }}">{{ this }}</a></li>
{{/each}}
</ul>
{{/if}}

<a href="/post/{{ id }}#disqus_thread"></a>
<div id="disqus_thread"></div>
</footer>
{{/if}}
</article>
4 changes: 4 additions & 0 deletions syte/syte_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
GOOGLE_ANALYTICS_TRACKING_ID = ''


#Disqus
DISQUS_INTEGRATION_ENABLED = False
DISQUS_SHORTNAME = ''

if DEPLOYMENT_MODE == 'dev':
SITE_ROOT_URI = 'http://127.0.0.1:8000/'
DEBUG = True
Expand Down
2 changes: 2 additions & 0 deletions syte/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ <h3><a href="/">rigoneri.com</a></h3>
github_integration_enabled = {% if GITHUB_INTEGRATION_ENABLED %}true{% else %}false{% endif %},
dribbble_integration_enabled = {% if DRIBBBLE_INTEGRATION_ENABLED %}true{% else %}false{% endif %},
instagram_integration_enabled = {% if INSTAGRAM_INTEGRATION_ENABLED %}true{% else %}false{% endif %};
{% if DISQUS_INTEGRATION_ENABLED %}var disqus_shortname = '{{ DISQUS_SHORTNAME }}';{% endif %}
</script>

{% if DEV_DEPLOYMENT_MODE %}
Expand All @@ -73,6 +74,7 @@ <h3><a href="/">rigoneri.com</a></h3>
{% if GITHUB_INTEGRATION_ENABLED %}<script src="{{ MEDIA_URL }}js/components/github.js"></script>{% endif %}
{% if DRIBBBLE_INTEGRATION_ENABLED %}<script src="{{ MEDIA_URL }}js/components/dribbble.js"></script>{% endif %}
{% if INSTAGRAM_INTEGRATION_ENABLED %}<script src="{{ MEDIA_URL }}js/components/instagram.js"></script>{% endif %}
{% if DISQUS_INTEGRATION_ENABLED %}<script src="{{ MEDIA_URL }}js/components/disqus.js"></script>{% endif %}

{% else %}
<script src="{{ MEDIA_URL }}js/min/scripts-{{ COMPRESS_REVISION_NUMBER }}.min.js"></script>
Expand Down
3 changes: 3 additions & 0 deletions syte/templates/blog-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
{% block extra_inline_js %}
$(function() {
adjustBlogHeaders();
{% if DISQUS_INTEGRATION_ENABLED %}
embed_disqus();
{% endif %}
});
{% endblock %}
3 changes: 3 additions & 0 deletions syte/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{% else %}
fetchBlogPosts();
{% endif %}
{% if DISQUS_INTEGRATION_ENABLED %}
embed_disqus_count();
{% endif %}
});
{% endblock %}

Expand Down

0 comments on commit 23e1095

Please sign in to comment.