fix: comment counter don't display right comment count

This commit is contained in:
ppoffice 2016-02-06 21:39:29 +08:00
parent 0c9d6a21a3
commit d360f9662d
11 changed files with 114 additions and 91 deletions

View File

@ -9,6 +9,7 @@ menu:
# Customize
customize:
logo:
enabled: true
width: 40
height: 40
url: images/logo.png
@ -17,10 +18,10 @@ customize:
avatar: css/images/avatar.png
gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden
author: PPOffice
author_title: 'Web Developer & Designer'
location: 'Harbin, China'
author_title: Web Developer & Designer
location: Harbin, China
follow: https://github.com/ppoffice/
highlight: androidstudio
highlight: monokai
sidebar: right # sidebar position, options: left, right
thumbnail: true # enable posts thumbnail, options: true, false
favicon: # path to favicon
@ -43,7 +44,7 @@ widgets:
# Search
search:
swiftype: # enter swiftype install key here
baidu: false # you need to disable other search engines to use Baidu search, options: true, false
baidu: true # you need to disable other search engines to use Baidu search, options: true, false
# Comment
comment:

View File

@ -0,0 +1,9 @@
<% if (post.comments) { %>
<% if (theme.comment.disqus) { %>
<a href="<%- post.permalink %>#comments" class="article-comment-link disqus-comment-count" data-disqus-url="<%= post.permalink %>"><%= __('article.comments') %></a>
<% } else if (theme.comment.duoshuo) { %>
<a href="<%- post.permalink %>#comments" class="article-comment-link ds-thread-count" data-thread-key="<%= post.path %>"><%= __('article.comments') %></a>
<% } else if (theme.comment.youyan) { %>
<a href="<%- post.permalink %>#comments" class="article-comment-link"><%= __('article.comments') %></a>
<% } %>
<% } %>

View File

@ -1,19 +1,22 @@
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<script>
var disqus_shortname = '<%= theme.comment.disqus %>';
<% if (page.disqusId) { %>
var disqus_identifier = '<%= page.disqusId || page.slug %>';
<% } %>
<% if (page.permalink) { %>
var disqus_url = '<%= page.permalink %>';
<% } %>
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<% if (typeof(script) !== 'undefined' && script) { %>
<script>
var disqus_shortname = '<%= theme.comment.disqus %>';
<% if (page.disqusId) { %>
var disqus_identifier = '<%= page.disqusId || page.slug %>';
<% } %>
<% if (page.permalink) { %>
var disqus_url = '<%= page.permalink %>';
<% } %>
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<% } else { %>
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<% } %>

View File

@ -1,49 +1,52 @@
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<style>
#ds-thread #ds-reset .ds-textarea-wrapper {
background: none;
}
#ds-reset .ds-avatar img {
box-shadow: none;
}
#ds-reset .ds-gradient-bg {
background: #f7f7f7;
}
#ds-thread #ds-reset li.ds-tab a {
border-radius: 3px;
}
#ds-thread #ds-reset .ds-post-button {
color: white;
border: none;
box-shadow: none;
background: #d32;
text-shadow: none;
font-weight: normal;
font-family: 'Microsoft Yahei';
}
#ds-thread #ds-reset .ds-post-button:hover {
color: white;
background: #DE594C;
}
#ds-thread #ds-reset .ds-post-button:active {
background: #d32;
}
#ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current {
color: white;
background: #d32;
box-shadow: none;
text-shadow: none;
font-weight: normal;
}
</style>
<% if (typeof(script) !== 'undefined' && script) { %>
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<% } else { %>
<div class="ds-thread" data-thread-key="<%= post.path %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<style>
#ds-thread #ds-reset .ds-textarea-wrapper {
background: none;
}
#ds-reset .ds-avatar img {
box-shadow: none;
}
#ds-reset .ds-gradient-bg {
background: #f7f7f7;
}
#ds-thread #ds-reset li.ds-tab a {
border-radius: 3px;
}
#ds-thread #ds-reset .ds-post-button {
color: white;
border: none;
box-shadow: none;
background: #d32;
text-shadow: none;
font-weight: normal;
font-family: 'Microsoft Yahei';
}
#ds-thread #ds-reset .ds-post-button:hover {
color: white;
background: #DE594C;
}
#ds-thread #ds-reset .ds-post-button:active {
background: #d32;
}
#ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current {
color: white;
background: #d32;
box-shadow: none;
text-shadow: none;
font-weight: normal;
}
</style>
<% } %>

View File

@ -1,11 +1,11 @@
<% if (post.comments) { %>
<section id="comments">
<% if (theme.comment.disqus) { %>
<%- partial('comment/disqus') %>
<% } else if (theme.comment.duoshuo) { %>
<%- partial('comment/duoshuo') %>
<% } else if (theme.comment.youyan) { %>
<%- partial('comment/youyan') %>
<% } %>
</section>
<section id="comments">
<% if (theme.comment.disqus) { %>
<%- partial('comment/disqus') %>
<% } else if (theme.comment.duoshuo) { %>
<%- partial('comment/duoshuo') %>
<% } else if (theme.comment.youyan) { %>
<%- partial('comment/youyan') %>
<% } %>
</section>
<% } %>

View File

@ -0,0 +1,7 @@
<% if (theme.comment.disqus) { %>
<%- partial('comment/disqus', { script: true }) %>
<% } else if (theme.comment.duoshuo) { %>
<%- partial('comment/duoshuo', { script: true }) %>
<% } else if (theme.comment.youyan) { %>
<%- partial('comment/youyan', { script: true }) %>
<% } %>

View File

@ -1,2 +1,5 @@
<div id="uyan_frame"></div>
<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.comment.youyan %>"></script>
<% if (typeof(script) !== 'undefined' && script) { %>
<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.comment.youyan %>"></script>
<% } else { %>
<div id="uyan_frame"></div>
<% } %>

View File

@ -32,11 +32,7 @@
</div>
<footer class="article-footer">
<%- partial('share/index', { post: post }) %>
<% if (post.comments && config.disqus_shortname) { %>
<a href="<%- post.permalink %>#disqus_thread" class="article-comment-link"><%= __('article.comments') %></a>
<% } else if (post.comments && config.duoshuo_shortname) { %>
<a href="<%- post.permalink %>#ds-thread" class="article-comment-link"><%= __('article.comments') %></a>
<% } %>
<%- partial('comment/counter', { post: post }) %>
</footer>
</div>
<% if (!index) { %>

View File

@ -2,7 +2,7 @@
<div id="header-main" class="header-inner">
<div class="outer">
<a href="<%- url_for() %>" id="logo">
<%- (theme.customize.logo ? '<i class="logo"></i>':'') %>
<%- (theme.customize.logo && theme.customize.logo.enabled ? '<i class="logo"></i>':'') %>
<span class="site-title"><%= config.title %></span>
</a>
<nav id="main-nav">
@ -10,7 +10,7 @@
<a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
<% } %>
</nav>
<% if(theme.customize.profile) { %>
<% if(theme.customize.profile && theme.customize.profile.enabled) { %>
<nav id="sub-nav">
<div class="profile" id="profile-nav">
<a id="profile-anchor" href="javascript:;">

View File

@ -6,7 +6,7 @@
<h2 id="name"><%= profile.author %></h2>
<h3 id="title"><%= profile.author_title %></h3>
<span id="location"><i class="fa fa-map-marker"></i><%= profile.location %></span>
<a id="follow" href="<%= profile.follow %>"><%= __('profile.follow') %></a>
<a id="follow" target="_blank" href="<%= profile.follow %>"><%= __('profile.follow') %></a>
</div>
<div class="article-info profile-block">
<div class="article-info-block">

View File

@ -1,3 +1,4 @@
<%- partial('comment/scripts', { page: page }) %>
<%- partial('plugin/scripts') %>
<!-- Custom Scripts -->