fix: comment counter don't display right comment count

pull/93/head
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) { %>
<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> <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div> </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>

View File

@ -1,16 +1,18 @@
<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 { %>
<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 { #ds-thread #ds-reset .ds-textarea-wrapper {
background: none; background: none;
} }
@ -46,4 +48,5 @@ ds.charset = 'UTF-8';
text-shadow: none; text-shadow: none;
font-weight: normal; font-weight: normal;
} }
</style> </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 -->