Skip to content

Commit 8843437

Browse files
authored
merge from dev branch, v1.4 (#141)
1. 增加基于“不蒜子”的站点总访客数、总浏览量和文章总阅读量的统计功能 2. 增加百度统计和腾讯分析的支持 3. 增加多说评论数显示功能
1 parent 2e69c76 commit 8843437

33 files changed

+2410
-2318
lines changed

_config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ excerpt_link: 阅读全文...
5353
mathjax: false
5454
archive_yearly: true
5555

56+
# 是否显示文章最后更新时间
57+
show_last_updated: true
58+
5659
#是否开启分享
5760
share: true
5861

@@ -79,6 +82,12 @@ copyright: 这里写留言或版权声明:<a href="<%- url_for(page.path).repl
7982
#站长统计,如要开启,输入CNZZ站点id,如 cnzz: 1255152447
8083
cnzz: false
8184

85+
# 百度统计,如要开启,改为你的 key
86+
baidu_tongji: 7463f50742128877845ac0184756a337
87+
88+
# 腾讯分析,如要开启,输入站点id
89+
tajs: false
90+
8291
# Miscellaneous
8392
google_analytics: false
8493
google_site_verification: false
@@ -101,7 +110,12 @@ disqus_shortname: false
101110
canonical: false
102111

103112
# 版权起始年份
104-
since_year: 2006
113+
since_year: 2015
105114

106115
# 用户页面中作者相关的描述性文字,如不需要设为 false
107116
about: 用户页面中作者相关的描述性文字,如不需要设为 false
117+
118+
# “不蒜子”访问量统计,详见 http://ibruce.info/2015/04/04/busuanzi/
119+
visit_counter:
120+
site_uv: 站点总访客数:
121+
site_pv: 站点总访问量:

layout/_partial/after-footer.ejs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<div class="mask" id="mask"></div>
22
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>
3-
<script>
4-
var BLOG = { ROOT: '<%= config.root %>', SHARE: <%- theme.share %>, REWARD: <%- Boolean(page.reward) %> }</script>
53
<% if(theme.share){ %>
64
<%- partial('post/share', {scope: 'global'}) %>
75
<% } %>

layout/_partial/footer.ejs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<footer class="footer">
2-
<p><a rel="license" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0;vertical-align:middle;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAMAAABEF7i9AAAAllBMVEUAAAD///+rsapERER3d3eIiIjMzMzu7u4iIiKUmZO6v7rKzsoODg4RERFVVVUNDQ0NDg0PEA8zMzNLTEtbXltmZmZydnF9gn2AgICPkI+ZmZmqqqq7u7vFxsXIzMgNDQwZGRkgICAhISEkJSMnKCcuMC4xMzE5Ozk7PTtBQkFCQkJDQ0Nna2eGhoaHh4ezuLLGysbd3d1wVGpAAAAA4UlEQVR42q2T1xqCMAyFk7QsBQeKA9x7j/d/OSm22CpX0nzcpA1/T05aAOuBVkMAScQFHLnEwoCo2f1TnQIGoVMewjZEjVFN4GH1Ue1Cn2jWqwfsOOj6wDwGvotsl/c8lv7KIq1eLOsT0HMFHMIE/RZyHnlphryT9zyV+8WH5e8yQw3wnQvgAFxPTKUVi555SHR/lOfLMgVTeDlSfN+TaoUsiTyeIm+bCkHvCA2FUKG48LDtYBZBknsYP/G8NTw0gaaHyuQf4H5pecrB/FYCT2sL9zAfy1Xyjou6L8X2W7YcLyBZCRtnq/zfAAAAAElFTkSuQmCC" /></a></p>
3-
<p><%=config.title %> &copy; <%if (theme.since_year && theme.since_year < date(new Date(), 'YYYY')) {%><%= theme.since_year %> - <%}%><%= date(new Date(), 'YYYY') %></p>
4-
<p>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme
5-
<a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></p>
6-
<a href="<%=theme.rss %>" target="_blank" class="rss" title="rss"><i class="icon icon-2x icon-rss-square"></i></a>
2+
<div class="top">
3+
<%- partial('plugins/site-visit') %>
4+
<p>
5+
<span><a href="<%-theme.rss %>" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
6+
<span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
7+
</p>
8+
</div>
9+
<div class="bottom">
10+
<p>
11+
<span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></span>
12+
<span><%-config.title %> &copy; <%if (theme.since_year && theme.since_year < date(new Date(), 'YYYY')) {%><%- theme.since_year %> - <%}%><%- date(new Date(), 'YYYY') %></span>
13+
</p>
14+
</div>
715
</footer>

layout/_partial/head.ejs

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
11
<head>
2-
<meta charset="utf-8">
3-
<% if(theme.google_site_verification){ %>
4-
<meta name="google-site-verification" content="<%- theme.google_site_verification%>">
5-
<% }%>
6-
<% if(theme.canonical){ %>
7-
<link rel="canonical" href="<%- (theme.canonical + url_for(page.path)).replace(/index\.html$/, '') %>">
8-
<% }%>
9-
<%
10-
var title = page.title;
2+
<%- partial('plugins/google-analytics') %>
3+
<%- partial('plugins/tajs') %>
4+
<%- partial('plugins/baidu') %>
5+
<meta charset="utf-8">
6+
<% if(theme.google_site_verification){ %>
7+
<meta name="google-site-verification" content="<%- theme.google_site_verification%>">
8+
<% }%>
9+
<% if(theme.canonical){ %>
10+
<link rel="canonical" href="<%- (theme.canonical + url_for(page.path)).replace(/index\.html$/, '') %>">
11+
<% }%>
12+
<%
13+
var title = page.title;
1114
12-
if (is_archive()){
13-
title = theme.archives_title || 'Archives';
15+
if (is_archive()){
16+
title = theme.archives_title || 'Archives';
1417
15-
if (is_month()){
16-
title += ': ' + page.year + '/' + page.month;
17-
} else if (is_year()){
18-
title += ': ' + page.year;
19-
}
20-
} else if (is_category()){
21-
title = (theme.categories_title || 'Categories') + ': ' + page.category;
22-
} else if (is_tag()){
23-
title = (theme.tags_title || 'Tags') + ': ' + page.tag;
24-
}
25-
%>
26-
<title><% if (title){ %><%= title %> | <% } %><%= config.title %> | <%= config.subtitle %></title>
27-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
28-
<% if(theme.color){ %>
29-
<meta name="theme-color" content="<%=theme.color%>">
30-
<% } %>
31-
<%
32-
var keyWords = config.keywords;
33-
if(page.tags){
34-
keyWords = [];
18+
if (is_month()){
19+
title += ': ' + page.year + '/' + page.month;
20+
} else if (is_year()){
21+
title += ': ' + page.year;
22+
}
23+
} else if (is_category()){
24+
title = (theme.categories_title || 'Categories') + ': ' + page.category;
25+
} else if (is_tag()){
26+
title = (theme.tags_title || 'Tags') + ': ' + page.tag;
27+
}
28+
%>
29+
<title><% if (title){ %><%= title %> | <% } %><%= config.title %> | <%= config.subtitle %></title>
30+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
31+
<% if(theme.color){ %>
32+
<meta name="theme-color" content="<%=theme.color%>">
33+
<% } %>
34+
<%
35+
var keyWords = config.keywords;
36+
if(page.tags){
37+
keyWords = [];
3538
36-
_.isArray(page.tags) ? ( keyWords = page.tags )
37-
: page.tags.each(function(k){
38-
keyWords.push(k.name);
39-
});
40-
}
41-
%>
42-
<meta name="keywords" content="<%= keyWords %>">
43-
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
44-
<% if (theme.rss){ %>
45-
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
46-
<% } %>
47-
<%- favicon_tag(theme.favicon) %>
48-
<link rel="stylesheet" href="<%= url_for('/css/style.css?v='+ theme_version()) %>">
49-
<script>window.lazyScripts=[]</script>
50-
<%- partial('google-analytics') %>
39+
_.isArray(page.tags) ? ( keyWords = page.tags )
40+
: page.tags.each(function(k){
41+
keyWords.push(k.name);
42+
});
43+
}
44+
%>
45+
<meta name="keywords" content="<%= keyWords %>">
46+
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
47+
<% if (theme.rss){ %>
48+
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
49+
<% } %>
50+
<%- favicon_tag(theme.favicon) %>
51+
<link rel="stylesheet" href="<%= url_for('/css/style.css?v='+ theme_version()) %>">
52+
<script>window.lazyScripts=[]</script>
5153
</head>

layout/_partial/index-item.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
<div class="post-meta">
55
<%- partial('post/date', {date_format: config.date_format}) %>
66
<%- partial('post/category') %>
7+
<%- partial('plugins/duoshuo-count') %>
78
</div>
89

910
<%- partial('post/title', { hasLink: true }) %>
1011

11-
<div class="post-content" id="post-content" itemprop="postContent" >
12+
<div class="post-content" id="post-content" itemprop="postContent">
1213

1314
<% if(theme.excerpt_render) { %>
1415
<%- post.excerpt || post.content %>

layout/_partial/menu.ejs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
</li>
3333
<% } %>
3434
</ul>
35-
36-
<%- partial('footer') %>
3735
</div>
3836
</div>
3937
</aside>

layout/_partial/plugins/baidu.ejs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<% if (theme.baidu_tongji){ %>
2+
<!-- Baidu Tongji -->
3+
<script>var _hmt = _hmt || []</script>
4+
<script async src="//hm.baidu.com/hm.js?<%- theme.baidu_tongji %>"></script>
5+
<!-- End Baidu Tongji -->
6+
<% } %>
7+
8+
<% if(theme.baidu_push){ %>
9+
<!-- Baidu Push -->
10+
<script>
11+
(function(){
12+
var bp = document.createElement('script');
13+
var curProtocol = window.location.protocol.split(':')[0];
14+
if (curProtocol === 'https') {
15+
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
16+
}
17+
else {
18+
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
19+
}
20+
var s = document.getElementsByTagName("script")[0];
21+
s.parentNode.insertBefore(bp, s);
22+
})();
23+
</script>
24+
<!-- End Baidu Push -->
25+
<% } %>

layout/_partial/plugins/disqus.ejs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<% if (theme.disqus_shortname){ %>
2+
<section class="comments" id="comments">
3+
<div id="disqus_thread"></div>
4+
<script>
5+
var disqus_shortname = '<%- theme.disqus_shortname %>';
6+
lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
7+
</script>
8+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
9+
</section>
10+
<% } %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% if (theme.duoshuo && post.comments){ %>
2+
<span>
3+
<a href="<%- url_for(post.path) %>#comments" class="ds-thread-count" data-thread-key="<%- post.slug %>" data-count-type="comments"></a>
4+
</span>
5+
<% }%>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<% if (theme.duoshuo){ %>
2+
var duoshuoQuery = {short_name:'<%- theme.duoshuo %>', theme: 'none'};
3+
lazyScripts.push('<%- url_for('/js/embed' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>');
4+
<% } %>

layout/_partial/plugins/duoshuo.ejs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% if (theme.duoshuo){ %>
2+
<div class="comments" id="comments">
3+
<div class="ds-thread" data-thread-key="<%-key%>" data-title="<%=title%>" data-url="<%=url.replace(/index\.html$/, '')%>"></div>
4+
</div>
5+
<script>
6+
lazyScripts.push('//cdn.bootcss.com/marked/0.3.6/marked.min.js')
7+
</script>
8+
<% } %>
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% if (theme.visit_counter) { %>
2+
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
3+
<i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
4+
</span>
5+
<% } %>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<% if (theme.visit_counter) { %>
2+
<p>
3+
<span id="busuanzi_container_site_uv" style='display:none'>
4+
<%- theme.visit_counter.site_uv %><span id="busuanzi_value_site_uv"></span>
5+
</span>
6+
<span id="busuanzi_container_site_pv" style='display:none'>
7+
<%- theme.visit_counter.site_pv %><span id="busuanzi_value_site_pv"></span>
8+
</span>
9+
</p>
10+
<% } %>

layout/_partial/plugins/tajs.ejs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% if (theme.tajs){ %>
2+
<!-- Tencent Speed -->
3+
<script>var _speedMark = new Date()</script>
4+
<!-- End Tencent Speed -->
5+
<!-- Tencent Analysis -->
6+
<script async src="//tajs.qq.com/stats?sId=<%- theme.tajs %>"></script>
7+
<!-- End Tencent Analysis -->
8+
<% } %>

layout/_partial/post.ejs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<div class="post-meta">
88
<%- partial('post/date', {date_format: config.date_format}) %>
99
<%- partial('post/category') %>
10+
<%- partial('plugins/page-visit') %>
11+
<%- partial('plugins/duoshuo-count') %>
1012
</div>
1113
<div class="post-content" id="post-content" itemprop="postContent">
1214
<%- post.content %>

layout/_partial/post/comment.ejs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
<% if (theme.duoshuo && post.comments){ %>
2-
<%- partial('duoshuo', {
1+
<% if(post.comments){ %>
2+
<%- partial('../plugins/duoshuo', {
33
key: post.slug,
44
title: post.title,
55
url: url
66
}) %>
7-
<% } %>
87
9-
<% if (post.comments && theme.disqus_shortname){ %>
10-
<section id="comments">
11-
<div id="disqus_thread"></div>
12-
<script>
13-
var disqus_shortname = '<%- theme.disqus_shortname %>';
14-
lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
15-
</script>
16-
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
17-
</section>
18-
<% } %>
8+
<%- partial('../plugins/disqus') %>
9+
<%} %>

layout/_partial/post/copyright.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<blockquote class="post-copyright">
22
<div class="content">
3+
<%- partial('updated') %>
34
<%- _.template(theme.copyright)(locals) %>
45
</div>
56
<footer>
@@ -8,4 +9,4 @@
89
<%- config.author %>
910
</a>
1011
</footer>
11-
</blockquote>
12+
</blockquote>

layout/_partial/post/date.ejs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished" class="post-time">
2-
<%= post.date.format(date_format) %>
3-
</time>
1+
<time class="post-time" title="<%- post.date.format('YYYY-M-D H:mm') %>" datetime="<%- date_xml(post.date) %>" itemprop="datePublished"><%- post.date.format(date_format) %></time>

layout/_partial/post/duoshuo.ejs

Lines changed: 0 additions & 8 deletions
This file was deleted.

layout/_partial/post/share.ejs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
%>
1111

1212
<div class="<%- scope %>-share" id="<%- scope %>Share">
13-
<div class="tit">分享到:</div>
1413
<ul class="reset share-icons">
1514
<li>
1615
<a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>" data-title="微博">

layout/_partial/post/updated.ejs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% if(theme.show_last_updated){ %>
2+
<span class="post-time">
3+
最后更新时间:<time datetime="<%- date_xml(post.updated) %>" title="<%- post.updated.formt('YYYY-M-D H:mm') %>" itemprop="dateUpdated"><%- post.updated.format('YYYY年M月D日 H:mm') %></time>
4+
</span><br>
5+
<%} %>

layout/_partial/script.ejs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
2-
3-
<%- partial('mathjax') %>
4-
2+
<script>
3+
var BLOG = { ROOT: '<%= config.root %>', SHARE: <%- theme.share %>, REWARD: <%- Boolean(page.reward) %> };
4+
<%- partial('plugins/duoshuo-js') %>
55
<% if (theme.cnzz){ %>
6-
<script>lazyScripts.push('//s95.cnzz.com/z_stat.php?id=<%-theme.cnzz %>&web_id=<%-theme.cnzz %>')</script>
6+
lazyScripts.push('//s95.cnzz.com/z_stat.php?id=<%-theme.cnzz %>&web_id=<%-theme.cnzz %>')
77
<% } %>
8+
</script>
89

910
<script src="<%- url_for('/js/main' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>"></script>
10-
1111
<% if (theme.search){ %>
1212
<%- partial('search') %>
1313
<script src="<%- url_for('/js/search' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>" async></script>
1414
<% } %>
15+
16+
<%- partial('plugins/mathjax') %>
17+
18+
<% if (theme.visit_counter) { %>
19+
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
20+
<% } %>

layout/layout.ejs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<html>
33
<%- partial('_partial/head') %>
44
<body>
5-
<%- partial('_partial/loading') %>
6-
<%- partial('_partial/menu') %>
7-
<main id="main">
8-
<%- body %>
9-
</main>
10-
<%- partial('_partial/after-footer') %>
11-
<%- partial('_partial/script') %>
5+
<%- partial('_partial/loading') %>
6+
<%- partial('_partial/menu') %>
7+
<main id="main">
8+
<%- body %>
9+
<%- partial('_partial/footer') %>
10+
</main>
11+
<%- partial('_partial/after-footer') %>
12+
<%- partial('_partial/script') %>
1213
</body>
1314
</html>

0 commit comments

Comments
 (0)