Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hypercomments system. #1155

Merged
merged 5 commits into from
Oct 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ mathjax:
# Disqus
#disqus_shortname:

# Hypercomments
#hypercomments_id:

# Baidu Share
# Available value:
# button | slide
Expand Down
12 changes: 12 additions & 0 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentsCount"></span>
</a>
</span>
{% elseif theme.hypercomments_id %}
<!--noindex-->
<span class="post-comments-count">
&nbsp;|&nbsp;
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
<span class="post-comments-count hc-comment-count" data-xid="{{ post.path }}" itemprop="commentsCount"></span>
</a>
</span>
</span>
<!--/noindex-->
{% endif %}
{% endif %}

Expand Down
2 changes: 2 additions & 0 deletions layout/_partials/comments.swig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript>
</div>
{% elseif theme.hypercomments_id %}
<div id="hypercomments_widget"></div>
{% endif %}
</div>
{% endif %}
1 change: 1 addition & 0 deletions layout/_scripts/third-party/comments.swig
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{% include './comments/duoshuo.swig' %}
{% include './comments/disqus.swig' %}
{% include './comments/hypercomments.swig' %}
27 changes: 27 additions & 0 deletions layout/_scripts/third-party/comments/hypercomments.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname and not theme.disqus_shortname %}

{% if theme.hypercomments_id %}

<script type="text/javascript">
_hcwp = window._hcwp || [];

_hcwp.push({widget:"Bloggerstream", widget_id: {{ theme.hypercomments_id }}, selector:".hc-comment-count", label: "{\%COUNT%\}" });

{% if page.comments %}
_hcwp.push({widget:"Stream", widget_id: {{ theme.hypercomments_id }}, xid: "{{ page.path }}"});
{% endif %}

(function() {
if("HC_LOAD_INIT" in window)return;
HC_LOAD_INIT = true;
var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/{{ theme.hypercomments_id }}/"+lang+"/widget.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hcc, s.nextSibling);
})();
</script>

{% endif %}

{% endif %}