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

refactor(comment): split comment provider/allow custom #311

Merged
merged 3 commits into from
Apr 29, 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
59 changes: 3 additions & 56 deletions layout/_partial/comment.ejs
Original file line number Diff line number Diff line change
@@ -1,56 +1,3 @@
<% if(theme.comment.use === 'duoshuo') { %>
<!-- 使用多说评论 -->
<%- 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">
<%- partial('_widget/disqus') %>
</div>
<style>
#disqus-comment{
background-color: #eee;
padding: 2pc;
}
</style>
<% } %>

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

<% if(theme.comment.use === 'disqus_proxy') { %>
<!-- 使用 DISQUS_PROXY -->
<div id="disqus-comment">
<%- partial('_widget/disqus_proxy') %>
</div>
<style>
#disqus-comment{
background-color: #eee;
padding: 2pc;
}
</style>
<% } %>
<% if(theme.comment.use) { %>
<%- partial('_widget/comment/' + theme.comment.use + '/enter') %>
<% } %>
32 changes: 2 additions & 30 deletions layout/_partial/footer-option.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,6 @@
<script src="<%= theme.busuanzi.busuanzi_pure_mini_js %>"></script>
<% } %>

<% if(theme.comment.use === 'duoshuo') { %>
<!-- 多说公共 js 代码 start -->
<script type="text/javascript">
queue.offer(function(){
var duoshuoQuery = {
short_name: '<%= theme.comment.shortname %>'
};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';
ds.async = true;
ds.src = '<%= theme.comment.duoshuo_embed_js_url %>';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
});
</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 代码 -->
<script id="dsq-count-scr" src="//<%= theme.comment.shortname %>.disqus.com/count.js" async></script>
<% if(theme.comment.use){ %>
<%- partial('_widget/comment/' + theme.comment.use + '/common') %>
<% } %>
4 changes: 4 additions & 0 deletions layout/_widget/comment/changyan/common.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- 畅言公共 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 -->
10 changes: 10 additions & 0 deletions layout/_widget/comment/changyan/enter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 使用 changyan -->
<div id="changyan-comment">
<%- partial('_widget/comment/' + theme.comment.use + '/main') %>
</div>
<style>
#changyan-comment{
background-color: #eee;
padding: 2pc;
}
</style>
File renamed without changes.
2 changes: 2 additions & 0 deletions layout/_widget/comment/disqus/common.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- 使用 DISQUS js 代码 -->
<script id="dsq-count-scr" src="//<%= theme.comment.shortname %>.disqus.com/count.js" async></script>
10 changes: 10 additions & 0 deletions layout/_widget/comment/disqus/enter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 使用 DISQUS -->
<div id="disqus-comment">
<%- partial('_widget/comment/' + theme.comment.use + '/main') %>
</div>
<style>
#disqus-comment{
background-color: #eee;
padding: 2pc;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div id="disqus_thread"></div>
<script type="text/ls-javascript" id="disqus-thread-script">
<script type="text/javascript">
var disqus_config = function () {
this.page.url = '<%= page.permalink %>'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '<%= page.permalink %>'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
</script>
<script type="text/ls-javascript" id="disqus-thread-script">
queue.offer(function() {
(function() { // DON'T EDIT BELOW THIS LINE
var d = document;
Expand Down
2 changes: 2 additions & 0 deletions layout/_widget/comment/disqus_click/common.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- 使用 DISQUS js 代码 -->
<script id="dsq-count-scr" src="//<%= theme.comment.shortname %>.disqus.com/count.js" async></script>
10 changes: 10 additions & 0 deletions layout/_widget/comment/disqus_click/enter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
<%- partial('_widget/comment/' + theme.comment.use + '/main') %>
</div>
<style>
#disqus-comment{
background-color: #eee;
padding: 2pc;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
<button class="disqus_click_btn"><%= __('post.comments_load_button') %></button>
</div>

<script type="text/ls-javascript" id="disqus-lazy-load-script">
<script type="text/javascript">
var disqus_config = function () {
this.page.url = '<%= page.permalink %>'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '<%= page.permalink %>'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
</script>

<script type="text/ls-javascript" id="disqus-lazy-load-script">
$('.btn_click_load').click(function() { //click to load comments
(function() { // DON'T EDIT BELOW THIS LINE
var d = document;
Expand Down
2 changes: 2 additions & 0 deletions layout/_widget/comment/disqus_proxy/common.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- 使用 DISQUS js 代码 -->
<script id="dsq-count-scr" src="//<%= theme.comment.shortname %>.disqus.com/count.js" async></script>
10 changes: 10 additions & 0 deletions layout/_widget/comment/disqus_proxy/enter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 使用 DISQUS_PROXY -->
<div id="disqus-comment">
<%- partial('_widget/comment/' + theme.comment.use + '/main') %>
</div>
<style>
#disqus-comment{
background-color: #eee;
padding: 2pc;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,81 +1,88 @@
<div id="comment" class="disqus_proxy"></div>
<div id="disqus_thread" class="disqus_normal"></div>

<!-- add animation -->
<style>
.disqus_click_btn {
line-height: 30px;
margin: 0;
min-width: 50px;
padding: 0 14px;
display: inline-block;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-size: 14px;
font-weight: 400;
text-transform: uppercase;
letter-spacing: 0;
overflow: hidden;
will-change: box-shadow;
transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
outline: 0;
cursor: pointer;
text-decoration: none;
text-align: center;
vertical-align: middle;
border: 0;
background: rgba(158, 158, 158, .2);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
color: #fff;
background-color: <%= theme.uiux.button_color %>;
text-shadow: 0
}
</style>

<% if(theme.materialcdn.use === true) { %>
<%- cssLsload(theme.materialcdn.base + '/css/disqus-proxy.min.css') %>
<%}else{%>
<%- cssLsload('css/disqus-proxy.min.css') %>
<%}%>

<script src="<%= theme.comment.disqus_proxy_js_url %>/disqus-api.js"></script>

<div class="dsq_click_load">
<button class="disqus_click_btn"><%= __('post.comments_fully_load_button') %></button>
</div>
<div class="dsq_click_proxy" style="display: none">
<button class="disqus_click_btn"><%= __('post.comments_proxy_load_button') %></button>
</div>
<div class="dsq_click_load_again" style="display: none">
<button class="disqus_click_btn"><%= __('post.comments_fully_load_button') %></button>
</div>

<script type="text/ls-javascript" id="disqus-thread-proxy-script">
var disqus_config = function () {
this.page.url = '<%= page.permalink %>'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '<%= page.permalink %>'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
$('.dsq_click_load').click(function() { //click to load comments
(function() { // DON'T EDIT BELOW THIS LINE
var d = document;
var s = d.createElement('script');
s.src = '//<%= theme.comment.shortname %>.disqus.com/embed.js';
s.setAttribute('data-timestamp', + new Date());
(d.head || d.body).appendChild(s);
})();
$('.dsq_click_load').css('display','none');
$('.disqus_proxy').css('display','none');
$('.dsq_click_proxy').css('display','block');
});
$('.dsq_click_proxy').click(function() {
$('.disqus_normal').css('display','none');
$('.disqus_proxy').css('display','block');
$('.dsq_click_proxy').css('display','none');
$('.dsq_click_load_again').css('display','block');
});
$('.dsq_click_load_again').click(function() {
$('.disqus_normal').css('display','block');
$('.disqus_proxy').css('display','none');
$('.dsq_click_proxy').css('display','block');
$('.dsq_click_load_again').css('display','none');
});
</script>
<div id="comment" class="disqus_proxy"></div>
<div id="disqus_thread" class="disqus_normal"></div>

<!-- add animation -->
<style>
.disqus_click_btn {
line-height: 30px;
margin: 0;
min-width: 50px;
padding: 0 14px;
display: inline-block;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-size: 14px;
font-weight: 400;
text-transform: uppercase;
letter-spacing: 0;
overflow: hidden;
will-change: box-shadow;
transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
outline: 0;
cursor: pointer;
text-decoration: none;
text-align: center;
vertical-align: middle;
border: 0;
background: rgba(158, 158, 158, .2);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
color: #fff;
background-color: <%= theme.uiux.button_color %>;
text-shadow: 0
}
</style>

<% if(theme.materialcdn.use === true) { %>
<%- cssLsload(theme.materialcdn.base + '/css/disqus-proxy.min.css') %>
<%}else{%>
<%- cssLsload('css/disqus-proxy.min.css') %>
<%}%>

<div class="dsq_click_load">
<button class="disqus_click_btn"><%= __('post.comments_fully_load_button') %></button>
</div>
<div class="dsq_click_proxy" style="display: none">
<button class="disqus_click_btn"><%= __('post.comments_proxy_load_button') %></button>
</div>
<div class="dsq_click_load_again" style="display: none">
<button class="disqus_click_btn"><%= __('post.comments_fully_load_button') %></button>
</div>

<script type="text/javascript">
var disqus_config = function () {
this.page.url = '<%= page.permalink %>'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '<%= page.permalink %>'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
</script>

<script type="text/ls-javascript" id="disqus-thread-proxy-script">
$('.dsq_click_load').click(function() { //click to load comments
(function() { // DON'T EDIT BELOW THIS LINE
var d = document;
var s = d.createElement('script');
s.src = '//<%= theme.comment.shortname %>.disqus.com/embed.js';
s.setAttribute('data-timestamp', + new Date());
(d.head || d.body).appendChild(s);
})();
$('.dsq_click_load').css('display','none');
$('.disqus_proxy').css('display','none');
$('.dsq_click_proxy').css('display','block');
});
$('.dsq_click_proxy').click(function() {
$('.disqus_normal').css('display','none');
$('.disqus_proxy').css('display','block');
$('.dsq_click_proxy').css('display','none');
$('.dsq_click_load_again').css('display','block');
});
$('.dsq_click_load_again').click(function() {
$('.disqus_normal').css('display','block');
$('.disqus_proxy').css('display','none');
$('.dsq_click_proxy').css('display','block');
$('.dsq_click_load_again').css('display','none');
});

queue.offer(function(){
var s=document.createElement('script');
s.src='<%= theme.comment.disqus_proxy_js_url %>/disqus-api.js';
(document.head || document.body).appendChild(s);
});
</script>
18 changes: 18 additions & 0 deletions layout/_widget/comment/duoshuo/common.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- 多说公共 js 代码 start -->
<script type="text/javascript">
queue.offer(function(){
var duoshuoQuery = {
short_name: '<%= theme.comment.shortname %>'
};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';
ds.async = true;
ds.src = '<%= theme.comment.duoshuo_embed_js_url %>';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
});
</script>
<!-- 多说公共 js 代码 end -->
2 changes: 2 additions & 0 deletions layout/_widget/comment/duoshuo/enter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- 使用多说评论 -->
<%- partial('_widget/comment/' + theme.comment.use + '/main') %>
File renamed without changes.