Skip to content

Commit

Permalink
merge from dev branch, v1.4 (#141)
Browse files Browse the repository at this point in the history
1. 增加基于“不蒜子”的站点总访客数、总浏览量和文章总阅读量的统计功能
2. 增加百度统计和腾讯分析的支持
3. 增加多说评论数显示功能
  • Loading branch information
yscoder authored Dec 4, 2016
1 parent 2e69c76 commit 8843437
Show file tree
Hide file tree
Showing 33 changed files with 2,410 additions and 2,318 deletions.
16 changes: 15 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ excerpt_link: 阅读全文...
mathjax: false
archive_yearly: true

# 是否显示文章最后更新时间
show_last_updated: true

#是否开启分享
share: true

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

# 百度统计,如要开启,改为你的 key
baidu_tongji: 7463f50742128877845ac0184756a337

# 腾讯分析,如要开启,输入站点id
tajs: false

# Miscellaneous
google_analytics: false
google_site_verification: false
Expand All @@ -101,7 +110,12 @@ disqus_shortname: false
canonical: false

# 版权起始年份
since_year: 2006
since_year: 2015

# 用户页面中作者相关的描述性文字,如不需要设为 false
about: 用户页面中作者相关的描述性文字,如不需要设为 false

# “不蒜子”访问量统计,详见 http://ibruce.info/2015/04/04/busuanzi/
visit_counter:
site_uv: 站点总访客数:
site_pv: 站点总访问量:
2 changes: 0 additions & 2 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>
<script>
var BLOG = { ROOT: '<%= config.root %>', SHARE: <%- theme.share %>, REWARD: <%- Boolean(page.reward) %> }</script>
<% if(theme.share){ %>
<%- partial('post/share', {scope: 'global'}) %>
<% } %>
18 changes: 13 additions & 5 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<footer class="footer">
<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>
<p><%=config.title %> &copy; <%if (theme.since_year && theme.since_year < date(new Date(), 'YYYY')) {%><%= theme.since_year %> - <%}%><%= date(new Date(), 'YYYY') %></p>
<p>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></p>
<a href="<%=theme.rss %>" target="_blank" class="rss" title="rss"><i class="icon icon-2x icon-rss-square"></i></a>
<div class="top">
<%- partial('plugins/site-visit') %>
<p>
<span><a href="<%-theme.rss %>" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
<span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
</p>
</div>
<div class="bottom">
<p>
<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>
<span><%-config.title %> &copy; <%if (theme.since_year && theme.since_year < date(new Date(), 'YYYY')) {%><%- theme.since_year %> - <%}%><%- date(new Date(), 'YYYY') %></span>
</p>
</div>
</footer>
94 changes: 48 additions & 46 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
<head>
<meta charset="utf-8">
<% if(theme.google_site_verification){ %>
<meta name="google-site-verification" content="<%- theme.google_site_verification%>">
<% }%>
<% if(theme.canonical){ %>
<link rel="canonical" href="<%- (theme.canonical + url_for(page.path)).replace(/index\.html$/, '') %>">
<% }%>
<%
var title = page.title;
<%- partial('plugins/google-analytics') %>
<%- partial('plugins/tajs') %>
<%- partial('plugins/baidu') %>
<meta charset="utf-8">
<% if(theme.google_site_verification){ %>
<meta name="google-site-verification" content="<%- theme.google_site_verification%>">
<% }%>
<% if(theme.canonical){ %>
<link rel="canonical" href="<%- (theme.canonical + url_for(page.path)).replace(/index\.html$/, '') %>">
<% }%>
<%
var title = page.title;
if (is_archive()){
title = theme.archives_title || 'Archives';
if (is_archive()){
title = theme.archives_title || 'Archives';
if (is_month()){
title += ': ' + page.year + '/' + page.month;
} else if (is_year()){
title += ': ' + page.year;
}
} else if (is_category()){
title = (theme.categories_title || 'Categories') + ': ' + page.category;
} else if (is_tag()){
title = (theme.tags_title || 'Tags') + ': ' + page.tag;
}
%>
<title><% if (title){ %><%= title %> | <% } %><%= config.title %> | <%= config.subtitle %></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<% if(theme.color){ %>
<meta name="theme-color" content="<%=theme.color%>">
<% } %>
<%
var keyWords = config.keywords;
if(page.tags){
keyWords = [];
if (is_month()){
title += ': ' + page.year + '/' + page.month;
} else if (is_year()){
title += ': ' + page.year;
}
} else if (is_category()){
title = (theme.categories_title || 'Categories') + ': ' + page.category;
} else if (is_tag()){
title = (theme.tags_title || 'Tags') + ': ' + page.tag;
}
%>
<title><% if (title){ %><%= title %> | <% } %><%= config.title %> | <%= config.subtitle %></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<% if(theme.color){ %>
<meta name="theme-color" content="<%=theme.color%>">
<% } %>
<%
var keyWords = config.keywords;
if(page.tags){
keyWords = [];
_.isArray(page.tags) ? ( keyWords = page.tags )
: page.tags.each(function(k){
keyWords.push(k.name);
});
}
%>
<meta name="keywords" content="<%= keyWords %>">
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<% if (theme.rss){ %>
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<%- favicon_tag(theme.favicon) %>
<link rel="stylesheet" href="<%= url_for('/css/style.css?v='+ theme_version()) %>">
<script>window.lazyScripts=[]</script>
<%- partial('google-analytics') %>
_.isArray(page.tags) ? ( keyWords = page.tags )
: page.tags.each(function(k){
keyWords.push(k.name);
});
}
%>
<meta name="keywords" content="<%= keyWords %>">
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<% if (theme.rss){ %>
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<%- favicon_tag(theme.favicon) %>
<link rel="stylesheet" href="<%= url_for('/css/style.css?v='+ theme_version()) %>">
<script>window.lazyScripts=[]</script>
</head>
3 changes: 2 additions & 1 deletion layout/_partial/index-item.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<div class="post-meta">
<%- partial('post/date', {date_format: config.date_format}) %>
<%- partial('post/category') %>
<%- partial('plugins/duoshuo-count') %>
</div>

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

<div class="post-content" id="post-content" itemprop="postContent" >
<div class="post-content" id="post-content" itemprop="postContent">

<% if(theme.excerpt_render) { %>
<%- post.excerpt || post.content %>
Expand Down
2 changes: 0 additions & 2 deletions layout/_partial/menu.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
</li>
<% } %>
</ul>

<%- partial('footer') %>
</div>
</div>
</aside>
25 changes: 25 additions & 0 deletions layout/_partial/plugins/baidu.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% if (theme.baidu_tongji){ %>
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?<%- theme.baidu_tongji %>"></script>
<!-- End Baidu Tongji -->
<% } %>

<% if(theme.baidu_push){ %>
<!-- Baidu Push -->
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
<!-- End Baidu Push -->
<% } %>
10 changes: 10 additions & 0 deletions layout/_partial/plugins/disqus.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if (theme.disqus_shortname){ %>
<section class="comments" id="comments">
<div id="disqus_thread"></div>
<script>
var disqus_shortname = '<%- theme.disqus_shortname %>';
lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>
<% } %>
5 changes: 5 additions & 0 deletions layout/_partial/plugins/duoshuo-count.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if (theme.duoshuo && post.comments){ %>
<span>
<a href="<%- url_for(post.path) %>#comments" class="ds-thread-count" data-thread-key="<%- post.slug %>" data-count-type="comments"></a>
</span>
<% }%>
4 changes: 4 additions & 0 deletions layout/_partial/plugins/duoshuo-js.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% if (theme.duoshuo){ %>
var duoshuoQuery = {short_name:'<%- theme.duoshuo %>', theme: 'none'};
lazyScripts.push('<%- url_for('/js/embed' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>');
<% } %>
8 changes: 8 additions & 0 deletions layout/_partial/plugins/duoshuo.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if (theme.duoshuo){ %>
<div class="comments" id="comments">
<div class="ds-thread" data-thread-key="<%-key%>" data-title="<%=title%>" data-url="<%=url.replace(/index\.html$/, '')%>"></div>
</div>
<script>
lazyScripts.push('//cdn.bootcss.com/marked/0.3.6/marked.min.js')
</script>
<% } %>
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions layout/_partial/plugins/page-visit.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if (theme.visit_counter) { %>
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
<i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>
<% } %>
10 changes: 10 additions & 0 deletions layout/_partial/plugins/site-visit.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if (theme.visit_counter) { %>
<p>
<span id="busuanzi_container_site_uv" style='display:none'>
<%- theme.visit_counter.site_uv %><span id="busuanzi_value_site_uv"></span>
</span>
<span id="busuanzi_container_site_pv" style='display:none'>
<%- theme.visit_counter.site_pv %><span id="busuanzi_value_site_pv"></span>
</span>
</p>
<% } %>
8 changes: 8 additions & 0 deletions layout/_partial/plugins/tajs.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if (theme.tajs){ %>
<!-- Tencent Speed -->
<script>var _speedMark = new Date()</script>
<!-- End Tencent Speed -->
<!-- Tencent Analysis -->
<script async src="//tajs.qq.com/stats?sId=<%- theme.tajs %>"></script>
<!-- End Tencent Analysis -->
<% } %>
2 changes: 2 additions & 0 deletions layout/_partial/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<div class="post-meta">
<%- partial('post/date', {date_format: config.date_format}) %>
<%- partial('post/category') %>
<%- partial('plugins/page-visit') %>
<%- partial('plugins/duoshuo-count') %>
</div>
<div class="post-content" id="post-content" itemprop="postContent">
<%- post.content %>
Expand Down
17 changes: 4 additions & 13 deletions layout/_partial/post/comment.ejs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<% if (theme.duoshuo && post.comments){ %>
<%- partial('duoshuo', {
<% if(post.comments){ %>
<%- partial('../plugins/duoshuo', {
key: post.slug,
title: post.title,
url: url
}) %>
<% } %>
<% if (post.comments && theme.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread"></div>
<script>
var disqus_shortname = '<%- theme.disqus_shortname %>';
lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>
<% } %>
<%- partial('../plugins/disqus') %>
<%} %>
3 changes: 2 additions & 1 deletion layout/_partial/post/copyright.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<blockquote class="post-copyright">
<div class="content">
<%- partial('updated') %>
<%- _.template(theme.copyright)(locals) %>
</div>
<footer>
Expand All @@ -8,4 +9,4 @@
<%- config.author %>
</a>
</footer>
</blockquote>
</blockquote>
4 changes: 1 addition & 3 deletions layout/_partial/post/date.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished" class="post-time">
<%= post.date.format(date_format) %>
</time>
<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>
8 changes: 0 additions & 8 deletions layout/_partial/post/duoshuo.ejs

This file was deleted.

1 change: 0 additions & 1 deletion layout/_partial/post/share.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
%>

<div class="<%- scope %>-share" id="<%- scope %>Share">
<div class="tit">分享到:</div>
<ul class="reset share-icons">
<li>
<a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>" data-title="微博">
Expand Down
5 changes: 5 additions & 0 deletions layout/_partial/post/updated.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if(theme.show_last_updated){ %>
<span class="post-time">
最后更新时间:<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>
</span><br>
<%} %>
16 changes: 11 additions & 5 deletions layout/_partial/script.ejs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>

<%- partial('mathjax') %>

<script>
var BLOG = { ROOT: '<%= config.root %>', SHARE: <%- theme.share %>, REWARD: <%- Boolean(page.reward) %> };
<%- partial('plugins/duoshuo-js') %>
<% if (theme.cnzz){ %>
<script>lazyScripts.push('//s95.cnzz.com/z_stat.php?id=<%-theme.cnzz %>&web_id=<%-theme.cnzz %>')</script>
lazyScripts.push('//s95.cnzz.com/z_stat.php?id=<%-theme.cnzz %>&web_id=<%-theme.cnzz %>')
<% } %>
</script>

<script src="<%- url_for('/js/main' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>"></script>

<% if (theme.search){ %>
<%- partial('search') %>
<script src="<%- url_for('/js/search' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>" async></script>
<% } %>

<%- partial('plugins/mathjax') %>

<% if (theme.visit_counter) { %>
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<% } %>
15 changes: 8 additions & 7 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<html>
<%- partial('_partial/head') %>
<body>
<%- partial('_partial/loading') %>
<%- partial('_partial/menu') %>
<main id="main">
<%- body %>
</main>
<%- partial('_partial/after-footer') %>
<%- partial('_partial/script') %>
<%- partial('_partial/loading') %>
<%- partial('_partial/menu') %>
<main id="main">
<%- body %>
<%- partial('_partial/footer') %>
</main>
<%- partial('_partial/after-footer') %>
<%- partial('_partial/script') %>
</body>
</html>
Loading

4 comments on commit 8843437

@xdcxdc
Copy link
Contributor

@xdcxdc xdcxdc commented on 8843437 Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在做了一个 深色的 footer 在最下面感觉好违和。。。。
还是原来的在左下角的布局更好看

@yuangezhizao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同感+1

@xdcxdc
Copy link
Contributor

@xdcxdc xdcxdc commented on 8843437 Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layout/_partial/post/updated.ejs 第3行
post.updated.formt 拼写错误

@yscoder
Copy link
Owner Author

@yscoder yscoder commented on 8843437 Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

习惯就好了。
后面的版本我会把 categories/index 去掉,分类加到左侧二级菜单。
@xdcxdc @yuangezhizao

Please sign in to comment.