Skip to content

Commit

Permalink
Update Disuqs service integration
Browse files Browse the repository at this point in the history
  • Loading branch information
iissnan committed Mar 24, 2017
1 parent b436399 commit 515b543
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
5 changes: 4 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ mathjax:
#duoshuo_shortname:

# Disqus
#disqus_shortname:
disqus:
enable: false
shortname:
count: true

# Hypercomments
#hypercomments_id:
Expand Down
5 changes: 3 additions & 2 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@
<span class="post-comments-count fb-comments-count" data-href="{{ post.permalink }}" itemprop="commentCount">0</span> comments
</a>
</span>
{% elseif theme.disqus_shortname %}
{% elseif theme.disqus.enable and theme.disqus.count %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
</a>
</span>
{% elseif theme.hypercomments_id %}
Expand Down
4 changes: 2 additions & 2 deletions layout/_partials/comments.swig
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
</div>
{% elseif theme.vkontakte_api.enable and theme.vkontakte_api.comments %}
<div id="vk_comments"></div>
{% elseif theme.disqus_shortname %}
{% elseif theme.disqus.enable %}
<div id="disqus_thread">
<noscript>
Please enable JavaScript to view the
<a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript>
</div>
{% elseif theme.hypercomments_id %}
Expand Down
40 changes: 15 additions & 25 deletions layout/_third-party/comments/disqus.swig
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}
{% if theme.disqus.enable %}

{% if theme.disqus_shortname %}
{% if theme.disqus.count %}
<script id="dsq-count-scr" src="https://{{theme.disqus.shortname}}.disqus.com/count.js" async></script>
{% endif %}

<script type="text/javascript">
var disqus_shortname = '{{theme.disqus_shortname}}';
var disqus_identifier = '{{ page.path }}';

var disqus_title = "{{ page.title|addslashes }}";


function run_disqus_script(disqus_script) {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}

run_disqus_script('count.js');

{% if page.comments %}
{% if page.comments %}
<script type="text/javascript">
var disqus_config = function () {
this.page.url = disqus_url;
this.page.identifier = disqus_identifier;
this.page.title = disqus_title;
this.page.url = '{{ page.permalink }}';
this.page.identifier = '{{ page.path }}';
this.page.title = '{{ page.title| addslashes }}';
};
run_disqus_script('embed.js');
{% endif %}
var d = document, s = d.createElement('script');
s.src = 'https://{{theme.disqus.shortname}}.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
</script>
{% endif %}

</script>
{% endif %}
{% endif %}

0 comments on commit 515b543

Please sign in to comment.