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

Gitment supported with mint #1919

Merged
merged 9 commits into from
Oct 6, 2017
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
16 changes: 16 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ valine:
# You can get your uid from https://livere.com/insight/myCode (General web site)
#livere_uid: your uid

# Gitment
# Introduction: https://imsun.net/posts/gitment-introduction/
gitment:
enable: false
mint: true # RECOMMEND, A mint on Gitment, to support count, language and proxy_gateway
count: true # Show comments count in post meta area
lazy: false # Comments lazy loading with a button
cleanly: false # Hide 'Powered by ...' on footer, and more
language: # Force language, or auto switch by theme
github_user: # MUST HAVE, Your Github ID
github_repo: # MUST HAVE, The repo you use to store Gitment comments
client_id: # MUST HAVE, Github client id for the Gitment
client_secret: # EITHER this or proxy_gateway, Github access secret token for the Gitment
proxy_gateway: # Address of api proxy, See: https://github.com/aimingoo/intersect
redirect_protocol: # Protocol of redirect_uri with force_redirect_protocol when mint enabled

# Baidu Share
# Available value:
# button | slide
Expand Down
2 changes: 2 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ reward:
wechatpay: WeChat Pay
alipay: Alipay
bitcoin: Bitcoin

gitmentbutton: Show comments from Gitment
2 changes: 2 additions & 0 deletions languages/zh-Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ reward:
wechatpay: 微信支付
alipay: 支付宝
bitcoin: 比特币

gitmentbutton: 显示 Gitment 评论
2 changes: 2 additions & 0 deletions languages/zh-hk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ reward:
wechatpay: 微信支付
alipay: 支付寶
bitcoin: 比特幣

gitmentbutton: 顯示 Gitment 評論
2 changes: 2 additions & 0 deletions languages/zh-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ reward:
wechatpay: 微信支付
alipay: 支付寶
bitcoin: 比特幣

gitmentbutton: 顯示 Gitment 評論
10 changes: 10 additions & 0 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@
<span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentsCount" ></span>
</a>
{% endif %}
{% elseif is_post() and theme.gitment.enable and theme.gitment.mint and theme.gitment.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 gitment-comments-count" data-xid="{{ url_for(post.path) }}" itemprop="commentsCount"></span>
</a>
</span>
{% endif %}
{% endif %}

Expand Down
20 changes: 20 additions & 0 deletions layout/_partials/comments.swig
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{% if page.comments %}

{% if (theme.duoshuo and theme.duoshuo.shortname) or theme.duoshuo_shortname %}
<div class="comments" id="comments">
<div class="ds-thread" data-thread-key="{{ page.path }}"
data-title="{{ page.title }}" data-url="{{ page.permalink }}">
</div>
</div>

{% elseif theme.facebook_sdk.enable and theme.facebook_comments_plugin.enable %}
<div class="comments" id="comments">
<div class="fb-comments"
Expand All @@ -14,10 +16,12 @@
data-colorscheme="{{ theme.facebook_comments_plugin.scheme }}">
</div>
</div>

{% elseif theme.vkontakte_api.enable and theme.vkontakte_api.comments %}
<div class="comments" id="comments">
<div id="vk_comments"></div>
</div>

{% elseif theme.disqus.enable %}
<div class="comments" id="comments">
<div id="disqus_thread">
Expand All @@ -27,25 +31,41 @@
</noscript>
</div>
</div>

{% elseif theme.hypercomments_id %}
<div class="comments" id="comments">
<div id="hypercomments_widget"></div>
</div>

{% elseif theme.youyan_uid %}
<div class="comments" id="comments">
<div id="uyan_frame"></div>
</div>

{% elseif theme.livere_uid %}
<div class="comments" id="comments">
<div id="lv-container" data-id="city" data-uid="{{ theme.livere_uid }}"></div>
</div>

{% elseif theme.changyan.appid and theme.changyan.appkey %}
<div class="comments" id="comments">
<div id="SOHUCS"></div>
</div>

{% elseif theme.gitment.enable %}
<div class="comments" id="comments">
{% if theme.gitment.lazy %}
<div onclick="showGitment()" id="gitment-display-button">{{ __('gitmentbutton') }}</div>
<div id="gitment-container" style="display:none"></div>
{% else %}
<div id="gitment-container"></div>
{% endif %}
</div>

{% elseif theme.valine.appid and theme.valine.appkey %}
<div class="comments" id="comments">
<div id="vcomments"></div>
</div>
{% endif %}

{% endif %}
59 changes: 59 additions & 0 deletions layout/_third-party/comments/gitment.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}
{% if theme.gitment.enable and theme.gitment.client_id %}
<!-- LOCAL: You can save these files to your site and update links -->
{% if theme.gitment.mint %}
{% set CommentsClass = "Gitmint" %}
<link rel="stylesheet" href="https://aimingoo.github.io/gitmint/style/default.css">
<script src="https://aimingoo.github.io/gitmint/dist/gitmint.browser.js"></script>
{% else %}
{% set CommentsClass = "Gitment" %}
<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">
<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
{% endif %}
<!-- END LOCAL -->

{% if theme.gitment.cleanly %}
<style>
a.gitment-editor-footer-tip { display: none; }
.gitment-container.gitment-footer-container { display: none; }
</style>
{% endif %}

{% if page.comments %}
<script type="text/javascript">
function renderGitment(){
var gitment = new {{CommentsClass}}({
id: document.location.href,
owner: '{{ theme.gitment.github_user }}',
repo: '{{ theme.gitment.github_repo }}',
{% if theme.gitment.mint %}
lang: "{{ theme.gitment.language }}" || navigator.language || navigator.systemLanguage || navigator.userLanguage,
{% endif %}
oauth: {
{% if theme.gitment.mint and theme.gitment.redirect_protocol %}
redirect_protocol: '{{ theme.gitment.redirect_protocol }}',
{% endif %}
{% if theme.gitment.mint and theme.gitment.proxy_gateway %}
proxy_gateway: '{{ theme.gitment.proxy_gateway }}',
{% else %}
client_secret: '{{ theme.gitment.client_secret }}',
{% endif %}
client_id: '{{ theme.gitment.client_id }}'
}});
gitment.render('gitment-container');
}

{% if not theme.gitment.lazy %}
renderGitment();
{% else %}
function showGitment(){
document.getElementById("gitment-display-button").style.display = "none";
document.getElementById("gitment-container").style.display = "block";
renderGitment();
}
{% endif %}
</script>
{% endif %}

{% endif %}
{% endif %}
1 change: 1 addition & 0 deletions layout/_third-party/comments/index.swig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
{% include 'youyan.swig' %}
{% include 'livere.swig' %}
{% include 'changyan.swig' %}
{% include 'gitment.swig' %}
{% include 'valine.swig' %}
Loading