diff options
author | alicewish <anywaywillgo@gmail.com> | 2017-12-20 21:33:05 +0800 |
---|---|---|
committer | olOwOlo <26087907+olOwOlo@users.noreply.github.com> | 2017-12-20 21:33:05 +0800 |
commit | 5ec874d64e1fe31278acde1b1444b26620a0fbc8 (patch) | |
tree | bda6321c4d3e9b94113ac829bfbe536abbe18762 | |
parent | 1bb6eea8a84cbf67a7396abb63223f6a719aad60 (diff) |
feat: add LiveRe and busuanzi (#17)
* LiveRe: commenting system
* busuanzi: count web traffic
-rw-r--r-- | data/even/default.toml | 5 | ||||
-rw-r--r-- | data/even/en.toml | 5 | ||||
-rw-r--r-- | data/even/zh-CN.toml | 5 | ||||
-rw-r--r-- | exampleSite/config.toml | 7 | ||||
-rw-r--r-- | exampleSite/data/even/default.toml | 5 | ||||
-rw-r--r-- | layouts/partials/comments.html | 39 | ||||
-rw-r--r-- | layouts/partials/footer.html | 20 | ||||
-rw-r--r-- | layouts/partials/head.html | 5 | ||||
-rw-r--r-- | layouts/post/single.html | 4 | ||||
-rw-r--r-- | static/img/spinner.svg | 49 |
10 files changed, 132 insertions, 12 deletions
diff --git a/data/even/default.toml b/data/even/default.toml index ebbb7b6..e87bd7c 100644 --- a/data/even/default.toml +++ b/data/even/default.toml @@ -40,3 +40,8 @@ categories = "分类" [counter.categories] zero = "暂无分类" other = "共计 %d 个分类" + +[traffic] + siteUV = "本站总访客数 %s 人" + sitePV = "本站总访问量 %s 次" + pagePV = "%s 次阅读" diff --git a/data/even/en.toml b/data/even/en.toml index 742649e..09cb578 100644 --- a/data/even/en.toml +++ b/data/even/en.toml @@ -40,3 +40,8 @@ categories = "Categories" [counter.categories] zero = "No Categories" other = "%d Categories In Total" + +[traffic] + siteUV = "site uv: %s" + sitePV = "site pv: %s" + pagePV = "%s times read" diff --git a/data/even/zh-CN.toml b/data/even/zh-CN.toml index ebbb7b6..e87bd7c 100644 --- a/data/even/zh-CN.toml +++ b/data/even/zh-CN.toml @@ -40,3 +40,8 @@ categories = "分类" [counter.categories] zero = "暂无分类" other = "共计 %d 个分类" + +[traffic] + siteUV = "本站总访客数 %s 人" + sitePV = "本站总访问量 %s 次" + pagePV = "%s 次阅读" diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 373a33c..e2ed85c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -73,6 +73,7 @@ copyright = "" # default: author.name ↓ # 默认为下面配 changyanAppid = "" # Changyan app id # 畅言 changyanAppkey = "" # Changyan app key + livereUID = "" # LiveRe UID # 来必力 baidu_push = false # baidu push # 百度 baidu_analytics = "" # Baidu Analytics 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>' 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] # 文章打赏 enable = false wechat = "/path/to/your/wechat-qr-code.png" # 微信二维码 diff --git a/exampleSite/data/even/default.toml b/exampleSite/data/even/default.toml index 742649e..09cb578 100644 --- a/exampleSite/data/even/default.toml +++ b/exampleSite/data/even/default.toml @@ -40,3 +40,8 @@ categories = "Categories" [counter.categories] zero = "No Categories" other = "%d Categories In Total" + +[traffic] + siteUV = "site uv: %s" + sitePV = "site pv: %s" + pagePV = "%s times read" diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html index 8728c17..afce2a3 100644 --- a/layouts/partials/comments.html +++ b/layouts/partials/comments.html @@ -4,24 +4,23 @@ <div id="disqus_thread"></div> <script type="text/javascript"> (function() { - // Don't ever inject Disqus on localhost--it creates unwanted - // discussions from 'localhost:1313' on your Disqus account... - if (window.location.hostname === 'localhost') return; + // Don't ever inject Disqus on localhost--it creates unwanted + // discussions from 'localhost:1313' on your Disqus account... + if (window.location.hostname === 'localhost') return; - var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - var disqus_shortname = '{{ .Site.DisqusShortname }}'; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + var disqus_shortname = '{{ .Site.DisqusShortname }}'; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <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 }} <!-- changyan --> {{- if and .Site.Params.changyanAppid .Site.Params.changyanAppkey -}} - <div id="SOHUCS"></div> - <script type="text/javascript"> + <div id="SOHUCS"></div> + <script type="text/javascript"> (function(){ if (window.location.hostname === 'localhost') return; @@ -32,4 +31,24 @@ })(); </script> {{- 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 }}
\ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 7ce1aaf..50ddeb4 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,3 +1,4 @@ +{{ $lang := .Site.Data.even.default -}} <div class="social-links"> {{- range $name, $path := .Site.Params.social }} {{- if $path }} @@ -10,14 +11,29 @@ <div class="copyright"> <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 class="division">|</span> <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> </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"> {{- $current := now.Format "2006" }} © diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 086adee..46c771e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -56,6 +56,11 @@ <script>eruda.init();</script> {{- end }} +<!-- busuanzi --> +{{ if .Site.Params.busuanzi.enable -}} +<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script> +{{- end }} + <!-- Styles --> <link href="{{ "dist/even.min.css?v=2.7.0" | relURL }}" rel="stylesheet"> {{ if .Site.Params.bootcdn -}} diff --git a/layouts/post/single.html b/layouts/post/single.html index 3a737d3..6f8e545 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -18,6 +18,10 @@ <span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span> <span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span> {{- 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> </header> diff --git a/static/img/spinner.svg b/static/img/spinner.svg new file mode 100644 index 0000000..cbd8855 --- /dev/null +++ b/static/img/spinner.svg @@ -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>
\ No newline at end of file |