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

feat(comment):add changyan comment system #247

Merged
merged 3 commits into from
Mar 27, 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
4 changes: 3 additions & 1 deletion _config.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ comment:
shortname:
duoshuo_thread_key_type: path
duoshuo_embed_js_url: "https://static.duoshuo.com/embed.js"

changyan_appid:
changyan_conf:
changyan_thread_key_type: path
# Search Systems
# Available value:
# swiftype | google | local
Expand Down
6 changes: 6 additions & 0 deletions layout/_partial/Isolation-post_entry.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<!-- Comment Number -->
<span class="ds-thread-count" data-thread-key="<% theme.comment.duoshuo_thread_key_type === 'id' ? page.id : page.path %>" data-count-type="comments"></span>
<% } %>
<% if(theme.comment.use === 'changyan') { %>
<!-- Comment Number -->
<span class="post_entry-comment" >
<span id = "sourceId::<%= theme.comment.changyan_thread_key_type === 'id' ? page.id : page.path %>" class = "cy_cmt_count" ></span>条评论
</span>
<% } %>
</div>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions layout/_partial/Paradox-post_entry.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
</span>
<% } %>

<% if(theme.comment.use === 'changyan') { %>
<!-- Comment Number -->
&nbsp;|&nbsp;
<span class="post_entry-comment" >
<span id = "sourceId::<%= theme.comment.changyan_thread_key_type === 'id' ? post.id : post.path %>" class = "cy_cmt_count" ></span>条评论
</span>
<% } %>

<!-- Post Views -->
<span class="post_entry-views">
</span>
Expand Down
17 changes: 15 additions & 2 deletions layout/_partial/comment.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
<%- partial('_widget/duoshuo') %>
<% } %>

<% if(theme.comment.use === 'changyan') { %>
<!-- 使用 changyan -->
<div id="changyan-comment">
<%- partial('_widget/changyan') %>
</div>
<style>
#changyan-comment{
background-color: #eee;
padding: 2pc;
}
</style>
<% } %>

<% if(theme.comment.use === 'disqus') { %>
<!-- 使用 DISQUS -->
<div id="disqus-comment">
Expand All @@ -18,7 +31,7 @@

<% if(theme.comment.use === 'disqus_click') { %>
<!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
<div id="disqus-comment">
<%- partial('_widget/disqus_click') %>
</div>
<style>
Expand All @@ -27,4 +40,4 @@
padding: 2pc;
}
</style>
<% } %>
<% } %>
6 changes: 6 additions & 0 deletions layout/_partial/footer-option.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
</script>
<!-- 多说公共 js 代码 end -->
<% } %>
<% if(theme.comment.use == "changyan"){ %>
<!-- 畅言公共 js 代码 start -->
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=<%=theme.comment.changyan_appid%>">
</script>
<!-- 畅言公共 js 代码 end -->
<% } %>

<% if(theme.comment.use === 'disqus') { %>
<!-- 使用 DISQUS js 代码 -->
Expand Down
9 changes: 9 additions & 0 deletions layout/_widget/changyan.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--PC和WAP自适应版-->
<div id="SOHUCS" sid="<% if(theme.comment.changyan_thread_key_type == "id"){ %><%= page.id %><% } else { %><%= page.path %><% } %>" ></div>
<script type="text/javascript">
(function(){
var appid = '<%= theme.comment.changyan_appid %>';
var conf = '<%= theme.comment.changyan_conf %>';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>