feat: add LiveRe and busuanzi (#17)

* LiveRe: commenting system
* busuanzi: count web traffic
This commit is contained in:
alicewish 2017-12-20 21:33:05 +08:00 committed by olOwOlo
parent 1bb6eea8a8
commit 5ec874d64e
10 changed files with 132 additions and 12 deletions

View file

@ -40,3 +40,8 @@ categories = "分类"
[counter.categories] [counter.categories]
zero = "暂无分类" zero = "暂无分类"
other = "共计 %d 个分类" other = "共计 %d 个分类"
[traffic]
siteUV = "本站总访客数 %s 人"
sitePV = "本站总访问量 %s 次"
pagePV = "%s 次阅读"

View file

@ -40,3 +40,8 @@ categories = "Categories"
[counter.categories] [counter.categories]
zero = "No Categories" zero = "No Categories"
other = "%d Categories In Total" other = "%d Categories In Total"
[traffic]
siteUV = "site uv: %s"
sitePV = "site pv: %s"
pagePV = "%s times read"

View file

@ -40,3 +40,8 @@ categories = "分类"
[counter.categories] [counter.categories]
zero = "暂无分类" zero = "暂无分类"
other = "共计 %d 个分类" other = "共计 %d 个分类"
[traffic]
siteUV = "本站总访客数 %s 人"
sitePV = "本站总访问量 %s 次"
pagePV = "%s 次阅读"

View file

@ -73,6 +73,7 @@ copyright = "" # default: author.name ↓ # 默认为下面配
changyanAppid = "" # Changyan app id # 畅言 changyanAppid = "" # Changyan app id # 畅言
changyanAppkey = "" # Changyan app key changyanAppkey = "" # Changyan app key
livereUID = "" # LiveRe UID # 来必力
baidu_push = false # baidu push # 百度 baidu_push = false # baidu push # 百度
baidu_analytics = "" # Baidu Analytics baidu_analytics = "" # Baidu Analytics
baidu_verification = "" # Baidu Verification baidu_verification = "" # Baidu Verification
@ -85,6 +86,12 @@ copyright = "" # default: author.name ↓ # 默认为下面配
fancyboxJs = '<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>' fancyboxJs = '<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>'
fancyboxCss = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">' fancyboxCss = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">'
[params.busuanzi] # count web traffic by busuanzi # 是否使用不蒜子统计站点访问量
enable = false
siteUV = true
sitePV = true
pagePV = true
[params.reward] # 文章打赏 [params.reward] # 文章打赏
enable = false enable = false
wechat = "/path/to/your/wechat-qr-code.png" # 微信二维码 wechat = "/path/to/your/wechat-qr-code.png" # 微信二维码

View file

@ -40,3 +40,8 @@ categories = "Categories"
[counter.categories] [counter.categories]
zero = "No Categories" zero = "No Categories"
other = "%d Categories In Total" other = "%d Categories In Total"
[traffic]
siteUV = "site uv: %s"
sitePV = "site pv: %s"
pagePV = "%s times read"

View file

@ -15,7 +15,6 @@
})(); })();
</script> </script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com/" class="dsq-brlink" target="_blank">comments powered by <span class="logo-disqus">Disqus</span></a>
{{- end }} {{- end }}
<!-- changyan --> <!-- changyan -->
@ -32,4 +31,24 @@
})(); })();
</script> </script>
{{- end }} {{- end }}
<!-- LiveRe -->
{{- if .Site.Params.livereUID -}}
<div id="lv-container" data-id="city" data-uid="{{ .Site.Params.livereUID }}">
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript>Please enable JavaScript to view the comments powered by <a href="https://livere.com/">LiveRe.</a></noscript>
</div>
{{- end }}
{{- end }} {{- end }}

View file

@ -1,3 +1,4 @@
{{ $lang := .Site.Data.even.default -}}
<div class="social-links"> <div class="social-links">
{{- range $name, $path := .Site.Params.social }} {{- range $name, $path := .Site.Params.social }}
{{- if $path }} {{- if $path }}
@ -10,14 +11,29 @@
<div class="copyright"> <div class="copyright">
<span class="power-by"> <span class="power-by">
{{ (printf .Site.Data.even.default.footer.powered `<a class="hexo-link" href="https://gohugo.io">Hugo</a>`) | safeHTML }} {{ (printf $lang.footer.powered `<a class="hexo-link" href="https://gohugo.io">Hugo</a>`) | safeHTML }}
</span> </span>
<span class="division">|</span> <span class="division">|</span>
<span class="theme-info"> <span class="theme-info">
{{ .Site.Data.even.default.footer.theme }} - {{ $lang.footer.theme }} -
<a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a> <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
</span> </span>
{{ if .Site.Params.busuanzi.enable -}}
<div class="busuanzi-footer">
{{ $spinner := "img/spinner.svg" | relURL -}}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.sitePV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_site_pv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_pv"> {{ printf $lang.traffic.sitePV $valueSpan | safeHTML }} </span>
{{ if .Site.Params.busuanzi.siteUV }}<span class="division">|</span>{{ end }}
{{- end }}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.siteUV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_site_uv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_uv"> {{ printf $lang.traffic.siteUV $valueSpan | safeHTML }} </span>
{{- end }}
</div>
{{- end }}
<span class="copyright-year"> <span class="copyright-year">
{{- $current := now.Format "2006" }} {{- $current := now.Format "2006" }}
&copy; &copy;

View file

@ -56,6 +56,11 @@
<script>eruda.init();</script> <script>eruda.init();</script>
{{- end }} {{- end }}
<!-- busuanzi -->
{{ if .Site.Params.busuanzi.enable -}}
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{{- end }}
<!-- Styles --> <!-- Styles -->
<link href="{{ "dist/even.min.css?v=2.7.0" | relURL }}" rel="stylesheet"> <link href="{{ "dist/even.min.css?v=2.7.0" | relURL }}" rel="stylesheet">
{{ if .Site.Params.bootcdn -}} {{ if .Site.Params.bootcdn -}}

View file

@ -18,6 +18,10 @@
<span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span> <span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span>
<span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span> <span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span>
{{- end }} {{- end }}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.pagePV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_page_pv"><img src="%s" alt="spinner.svg"/></span>` ("img/spinner.svg" | relURL) -}}
<span id="busuanzi_container_page_pv" class="more-meta"> {{ printf $lang.traffic.pagePV $valueSpan | safeHTML }} </span>
{{- end }}
</div> </div>
</header> </header>

49
static/img/spinner.svg Normal file
View file

@ -0,0 +1,49 @@
<svg class="lds-spinner" width="16px" height="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" style="background: none;"><g transform="rotate(0 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(30 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(60 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(90 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(120 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(150 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(180 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(210 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(240 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(270 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(300 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
</rect>
</g><g transform="rotate(330 50 50)">
<rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#c05b4d">
<animate attributeName="opacity" values="1;0" times="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>
</rect>
</g></svg>

After

Width:  |  Height:  |  Size: 3.2 KiB