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
customize: customize:
logo: logo:
enabled: true
width: 40 width: 40
height: 40 height: 40
url: images/logo.png url: images/logo.png
@ -17,10 +18,10 @@ customize:
avatar: css/images/avatar.png avatar: css/images/avatar.png
gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden
author: PPOffice author: PPOffice
author_title: 'Web Developer & Designer' author_title: Web Developer & Designer
location: 'Harbin, China' location: Harbin, China
follow: https://github.com/ppoffice/ follow: https://github.com/ppoffice/
highlight: androidstudio highlight: monokai
sidebar: right # sidebar position, options: left, right sidebar: right # sidebar position, options: left, right
thumbnail: true # enable posts thumbnail, options: true, false thumbnail: true # enable posts thumbnail, options: true, false
favicon: # path to favicon favicon: # path to favicon
@ -43,7 +44,7 @@ widgets:
# Search # Search
search: search:
swiftype: # enter swiftype install key here 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
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"> <% if (typeof(script) !== 'undefined' && script) { %>
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <script>
</div> var disqus_shortname = '<%= theme.comment.disqus %>';
<script> <% if (page.disqusId) { %>
var disqus_shortname = '<%= theme.comment.disqus %>'; var disqus_identifier = '<%= page.disqusId || page.slug %>';
<% if (page.disqusId) { %> <% } %>
var disqus_identifier = '<%= page.disqusId || page.slug %>'; <% if (page.permalink) { %>
<% } %> var disqus_url = '<%= page.permalink %>';
<% if (page.permalink) { %> <% } %>
var disqus_url = '<%= page.permalink %>'; (function() {
<% } %> var dsq = document.createElement('script');
(function() { dsq.type = 'text/javascript';
var dsq = document.createElement('script'); dsq.async = true;
dsq.type = 'text/javascript'; dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
dsq.async = true; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
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 { %>
</script> <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> <% if (typeof(script) !== 'undefined' && script) { %>
<script type="text/javascript"> <script type="text/javascript">
var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'}; var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'};
(function() { (function() {
var ds = document.createElement('script'); var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true; ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8'; ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0] (document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds); || document.getElementsByTagName('body')[0]).appendChild(ds);
})(); })();
</script> </script>
<style> <% } else { %>
#ds-thread #ds-reset .ds-textarea-wrapper { <div class="ds-thread" data-thread-key="<%= post.path %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
background: none; <style>
} #ds-thread #ds-reset .ds-textarea-wrapper {
#ds-reset .ds-avatar img { background: none;
box-shadow: none; }
} #ds-reset .ds-avatar img {
#ds-reset .ds-gradient-bg { box-shadow: none;
background: #f7f7f7; }
} #ds-reset .ds-gradient-bg {
#ds-thread #ds-reset li.ds-tab a { background: #f7f7f7;
border-radius: 3px; }
} #ds-thread #ds-reset li.ds-tab a {
#ds-thread #ds-reset .ds-post-button { border-radius: 3px;
color: white; }
border: none; #ds-thread #ds-reset .ds-post-button {
box-shadow: none; color: white;
background: #d32; border: none;
text-shadow: none; box-shadow: none;
font-weight: normal; background: #d32;
font-family: 'Microsoft Yahei'; text-shadow: none;
} font-weight: normal;
#ds-thread #ds-reset .ds-post-button:hover { font-family: 'Microsoft Yahei';
color: white; }
background: #DE594C; #ds-thread #ds-reset .ds-post-button:hover {
} color: white;
#ds-thread #ds-reset .ds-post-button:active { background: #DE594C;
background: #d32; }
} #ds-thread #ds-reset .ds-post-button:active {
#ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current { background: #d32;
color: white; }
background: #d32; #ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current {
box-shadow: none; color: white;
text-shadow: none; background: #d32;
font-weight: normal; box-shadow: none;
} text-shadow: none;
</style> font-weight: normal;
}
</style>
<% } %>

View File

@ -1,11 +1,11 @@
<% if (post.comments) { %> <% if (post.comments) { %>
<section id="comments"> <section id="comments">
<% if (theme.comment.disqus) { %> <% if (theme.comment.disqus) { %>
<%- partial('comment/disqus') %> <%- partial('comment/disqus') %>
<% } else if (theme.comment.duoshuo) { %> <% } else if (theme.comment.duoshuo) { %>
<%- partial('comment/duoshuo') %> <%- partial('comment/duoshuo') %>
<% } else if (theme.comment.youyan) { %> <% } else if (theme.comment.youyan) { %>
<%- partial('comment/youyan') %> <%- partial('comment/youyan') %>
<% } %> <% } %>
</section> </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> <% if (typeof(script) !== 'undefined' && script) { %>
<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.comment.youyan %>"></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> </div>
<footer class="article-footer"> <footer class="article-footer">
<%- partial('share/index', { post: post }) %> <%- partial('share/index', { post: post }) %>
<% if (post.comments && config.disqus_shortname) { %> <%- partial('comment/counter', { post: post }) %>
<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>
<% } %>
</footer> </footer>
</div> </div>
<% if (!index) { %> <% if (!index) { %>

View File

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

View File

@ -6,7 +6,7 @@
<h2 id="name"><%= profile.author %></h2> <h2 id="name"><%= profile.author %></h2>
<h3 id="title"><%= profile.author_title %></h3> <h3 id="title"><%= profile.author_title %></h3>
<span id="location"><i class="fa fa-map-marker"></i><%= profile.location %></span> <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>
<div class="article-info profile-block"> <div class="article-info profile-block">
<div class="article-info-block"> <div class="article-info-block">

View File

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