💄 Support more of analytics engine such as baidu, google, busuanzi and so on, then add new web information widget. close #19

This commit is contained in:
凡梦星尘 2022-09-11 18:33:41 +08:00
parent c38a439171
commit 2a7fd9f8fb
21 changed files with 197 additions and 86 deletions

View File

@ -97,16 +97,3 @@
vertical-align: middle; vertical-align: middle;
} }
} }
.busuanzi-count {
@if $busuanzi_visitors {
#busuanzi_container_site_uv {
display: none;
}
}
@if $busuanzi_views {
#busuanzi_container_site_pv {
display: none;
}
}
}

View File

@ -1,4 +1,4 @@
.sidebar-inner { .sidebar-inner, .sidebar-card-widget {
color: $grey-dark; color: $grey-dark;
// Init Sidebar & TOC inner dimensions on all pages and for all schemes. // Init Sidebar & TOC inner dimensions on all pages and for all schemes.
$offset : if(($scheme == 'Pisces') or ($scheme == 'Gemini'), $sidebar-offset, $sidebar-padding); $offset : if(($scheme == 'Pisces') or ($scheme == 'Gemini'), $sidebar-offset, $sidebar-padding);
@ -39,3 +39,4 @@
@import 'sidebar-toggle'; @import 'sidebar-toggle';
@import 'sidebar-toc'; @import 'sidebar-toc';
@import 'site-state'; @import 'site-state';
@import 'sidebar-card-widget';

View File

@ -0,0 +1,58 @@
.sidebar-card-widget {
background: var(--content-bg-color);
border-radius: $border-radius;
box-shadow: $box-shadow;
box-sizing: border-box;
color: var(--text-color);
margin-top: $sidebar-offset;
.item-headline {
text-align: left;
font-size: $font-size-small;
font-weight: bold;
span {
margin-left: 8px;
}
}
.webinfo {
font-size: $font-size-small;
text-align: left;
.webinfo-item {
display: flex;
-webkit-box-align: center;
align-items: center;
padding: 2px 10px 0;
i {
width: 16px;
height: 16px;
text-align: center;
margin-right: 4px;
}
div:first-child {
-webkit-box-flex: 1;
-moz-box-flex: 1;
-o-box-flex: 1;
box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
padding-right: 20px;
}
}
}
}
.back-to-top-card {
margin: 0;
padding: 0;
div:first-child {
margin: 0;
}
}

View File

@ -34,9 +34,7 @@ $footer_vendors_enable : {{ isset $P.footer "vendors" }};
{{ end }} {{ end }}
// Counter // Counter
$busuanzi_visitors : {{ $P.busuanzi.visitors }}; $busuanzi_post_views : {{ $P.analytics.busuanzi.postViews }};
$busuanzi_views : {{ $P.busuanzi.views }};
$busuanzi_post_views : {{ $P.busuanzi.postViews }};
// Font // Font
$font_enable : {{ $P.font.enable }}; $font_enable : {{ $P.font.enable }};

View File

@ -10,10 +10,6 @@ js:
- name: animejs - name: animejs
version: 3.2.1 version: 3.2.1
file: lib/anime.min.js file: lib/anime.min.js
# TODO
#- name: mathjax
# version: 3.2.0
# file: es5/tex-mml-chtml.js
# CSS 资源 # CSS 资源
# CSS Resources # CSS Resources
@ -33,6 +29,9 @@ css:
# Site analytics engine # Site analytics engine
analytics: analytics:
la: https://sdk.51.la/js-sdk-pro.min.js la: https://sdk.51.la/js-sdk-pro.min.js
baidu: https://hm.baidu.com/hm.js?
google: https://www.googletagmanager.com/gtag/js?id=
busuanzi: https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js
# 文章分享 # 文章分享
# Share # Share
@ -95,7 +94,7 @@ plugins:
version: 0.16.0 version: 0.16.0
file: dist/katex.min.js file: dist/katex.min.js
- name: auto-render - name: auto-render
alias: katex alias2: katex
version: 0.16.0 version: 0.16.0
file: dist/contrib/auto-render.min.js file: dist/contrib/auto-render.min.js
css: css:

View File

@ -895,17 +895,19 @@ params:
# 51La Analytics # 51La Analytics
# See: https://invite.51.la/1NUfGTS1?target=V6 # See: https://invite.51.la/1NUfGTS1?target=V6
laId: #<anaytics_id> laId: #<anaytics_id>
# 百度统计
# TODO # Baidu Analytics
#baidu: #<anaytics_id>
# 谷歌统计
# Google Analytics
#google: #<anaytics_id>
# 不蒜子统计
# Show Views / Visitors of the website / page with busuanzi. # Show Views / Visitors of the website / page with busuanzi.
# For more information: http://ibruce.info/2015/04/04/busuanzi/ # For more information: http://ibruce.info/2015/04/04/busuanzi/
busuanzi: busuanzi:
visitors: false
visitorsIcon: fa fa-user visitorsIcon: fa fa-user
views: false
viewsIcon: fa fa-eye viewsIcon: fa fa-eye
postViews: false postViews: true
postViewsIcon: far fa-eye
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -136,9 +136,9 @@ PostCommentTitle:
other: 评论交流 other: 评论交流
VisitorsLabel: VisitorsLabel:
other: 总访客 other: 总访客数:
PageViewsLabel: PageViewsLabel:
other: 总访问量 other: 页面浏览:
FooterPowerby: FooterPowerby:
other: 由 %s 强力驱动 other: 由 %s 强力驱动

View File

@ -17,7 +17,7 @@
<main class="main"> <main class="main">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"> <header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"> <div class="header-inner">
{{- partial "header.html" . }} {{- partialCached "header.html" . }}
</div> </div>
<!-- Sidebar --> <!-- Sidebar -->
{{- if ne .Site.Params.sidebar.display "remove" }} {{- if ne .Site.Params.sidebar.display "remove" }}

View File

@ -3,14 +3,19 @@
{{ $fmt := "%s/%s@%s/%s" }} {{ $fmt := "%s/%s@%s/%s" }}
{{ $npm := .res.name }} {{ $npm := .res.name }}
{{ with .res.alias }} {{ with .res.alias2 }}
{{ $npm = . }} {{ $npm = . }}
{{ end }} {{ end }}
{{ $file := .res.file }} {{- $file := .res.file }}
{{ if eq .vendor "cdnjs" }}
{{ $file = replaceRE `(dist|lib|source\/js)\/` "" .res.file }} {{- if eq .vendor "cdnjs" }}
{{ $fmt = "%s/%s/%s/%s" }} {{- with .res.alias }}
{{ end }} {{- $npm = . }}
{{- end }}
{{- $file = replaceRE `(dist|lib|source\/js)\/` "" .res.file }}
{{- $fmt = "%s/%s/%s/%s" }}
{{- end }}
{{ $pluginRes := printf $fmt .router $npm .res.version $file }} {{ $pluginRes := printf $fmt .router $npm .res.version $file }}
{{ return $pluginRes }} {{ return $pluginRes }}

View File

@ -13,5 +13,5 @@
} }
document.head.appendChild(script); document.head.appendChild(script);
}); });
</script> </script>

View File

@ -0,0 +1,11 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
var script = document.createElement('script');
script.charset = "UTF-8";
script.src = "{{ .Site.Data.resources.analytics.baidu }}{{ .Site.Params.analytics.baidu }}";
script.async = "true"
document.head.appendChild(script);
});
</script>

View File

@ -0,0 +1,11 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
var script = document.createElement('script');
script.charset = "UTF-8";
script.src = "{{ .Site.Data.resources.analytics.busuanzi }}";
script.async = "true"
document.head.appendChild(script);
});
</script>

View File

@ -0,0 +1,18 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
var script = document.createElement('script');
script.charset = "UTF-8";
script.src = "{{ .Site.Data.resources.analytics.google }}{{ .Site.Params.analytics.google }}";
script.async = "true"
script.onload = function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ .Site.Params.analytics.google }} ');
}
document.head.appendChild(script);
});
</script>

View File

@ -3,7 +3,7 @@
{{- partial "head/twitter.html" . }} {{- partial "head/twitter.html" . }}
{{- partial "head/googleplus.html" . }} {{- partial "head/googleplus.html" . }}
{{- partial "head/facebook.html" . }} {{- partial "head/facebook.html" . }}
{{- partial "head/verify.html" . }} {{- partialCached "head/verify.html" . }}
{{- partialCached "head/style.html" . }} {{- partialCached "head/style.html" . }}
{{- partial "head/config.html" . }} {{- partial "head/config.html" . }}
{{- partialCached "head/analytics.html" . }} {{- partialCached "head/analytics.html" . }}

View File

@ -1,3 +1,12 @@
{{- if isset .Site.Params.analytics "laid" }} {{- if isset .Site.Params.analytics "laid" }}
{{ partial "_thirdparty/analytics/51la.html" . }} {{ partial "_thirdparty/analytics/51la.html" . }}
{{- end }} {{- end }}
{{- if isset .Site.Params.analytics "baidu" }}
{{ partial "_thirdparty/analytics/baidu.html" . }}
{{- end }}
{{- if isset .Site.Params.analytics "google" }}
{{ partial "_thirdparty/analytics/google.html" . }}
{{- end }}
{{- if isset .Site.Params.analytics "busuanzi" }}
{{ partial "_thirdparty/analytics/busuanzi.html" . }}
{{- end }}

View File

@ -1,19 +0,0 @@
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css">
<!-- NexT theme css style -->
{{- $scssVars := resources.Get "css/_sitevars.scss"}}
{{- $scssVars = $scssVars | resources.ExecuteAsTemplate "sitevars.scss" . }}
{{- $scssMain := resources.Get "css/main.scss" }}
{{- $scss := slice $scssVars $scssMain | resources.Concat "css/main.scss" }}
{{- $css := $scss | toCSS (dict "targetPath" "/css/main_new.css" "outputStyle" "expanded") }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
{{- $scheme := lower .Site.Params.scheme }}
{{- $styleScheme := (printf "css/%s/style.css" $scheme) }}
<link rel="stylesheet" href="/css/{{ $scheme }}/main.css">
{{- $style := resources.Get $styleScheme | resources.ExecuteAsTemplate $styleScheme . }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
<link rel="stylesheet" href="/css/hover.css">

View File

@ -2,19 +2,10 @@
{{- $cssRes := .Site.Data.resources.css }} {{- $cssRes := .Site.Data.resources.css }}
{{- $vendor := .Site.Params.vendors.plugins }} {{- $vendor := .Site.Params.vendors.plugins }}
{{- $router := .Scratch.Get "router" }} {{- $router := .Scratch.Get "router" }}
{{ $cssFmt := "%s/%s@%s/%s" }}
{{- range $css := $cssRes }} {{- range $css := $cssRes }}
{{- $npm := $css.name }} {{ $pluginCss := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
{{- $file := $css.file }} <link type="text/css" rel="stylesheet" href="{{ $pluginCss }}" />
{{- if eq $vendor "cdnjs" }}
{{- with $css.alias }}
{{- $npm = . }}
{{- end }}
{{- $file = replaceRE `(dist|lib|source\/js)\/` "" $css.file }}
{{- $cssFmt = "%s/%s/%s/%s" }}
{{- end }}
{{- $pluginCSS := printf $cssFmt $router $npm $css.version $file }}
<link type="text/css" rel="stylesheet" href="{{ $pluginCSS }}" />
{{- end }} {{- end }}
<!-- Main Style file --> <!-- Main Style file -->

View File

@ -1,12 +1,12 @@
{{- $pageViewCls := "" }} {{- $pageViewId := "" }}
{{- if .Site.Params.leancloudVisitors.enable }} {{- if .Site.Params.leancloudVisitors.enable }}
{{- $pageViewCls = "leancloud-visitors-count" }} {{- $pageViewId = "leancloud-visitors-count" }}
{{- end }} {{- end }}
{{- if .Site.Params.waline.pageView }} {{- if .Site.Params.waline.pageView }}
{{- $pageViewCls = "waline-pageview-count" }} {{- $pageViewId = "waline-pageview-count" }}
{{- end }} {{- end }}
{{- if .Site.Params.busuanzi.postViews }} {{- if .Site.Params.analytics.busuanzi.postViews }}
{{- $pageViewCls = "busuanzi_value_page_pv" }} {{- $pageViewId = "busuanzi_value_page_pv" }}
{{- end }} {{- end }}
<span class="post-meta-item" title="{{ T "PostViews" }}"> <span class="post-meta-item" title="{{ T "PostViews" }}">
<span class="post-meta-item-icon"> <span class="post-meta-item-icon">
@ -15,5 +15,5 @@
<span class="post-meta-item-text"> <span class="post-meta-item-text">
{{ print (T "PostViews") (T "SymbolColon") }} {{ print (T "PostViews") (T "SymbolColon") }}
</span> </span>
<span class="{{ $pageViewCls }}" data-path="{{ .RelPermalink | relLangURL }}"><i class="fa fa-sync fa-spin"></i></span> <span id="{{ $pageViewId }}" data-path="{{ .RelPermalink | relLangURL }}"><i class="fa fa-sync fa-spin"></i></span>
</span> </span>

View File

@ -6,7 +6,7 @@
{{ if $cssRes }} {{ if $cssRes }}
{{ range $cssRes }} {{ range $cssRes }}
{{ $css := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }} {{ $css := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
<link rel="stylesheet" href="{{ $css }}"/> <link type="text/css" rel="stylesheet" href="{{ $css }}"/>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- $jsRes := $res.js }} {{- $jsRes := $res.js }}

View File

@ -31,12 +31,18 @@
{{- end }} {{- end }}
</div> </div>
</div> </div>
</div>
{{ partial "sidebar/webinfo.html" . }}
{{- if and .Site.Params.backTop.enable .Site.Params.backTop.sidebar }} {{- if and .Site.Params.backTop.enable .Site.Params.backTop.sidebar }}
<div class="sidebar-card-widget back-to-top-card">
<div class="back-to-top animated" role="button" aria-label="{{ T "BackTop" }}"> <div class="back-to-top animated" role="button" aria-label="{{ T "BackTop" }}">
<i class="fa fa-arrow-up"></i> <i class="fa fa-arrow-up"></i>
<span>0%</span> <span>0%</span>
</div> </div>
{{- end }}
</div> </div>
{{- end }}
</aside> </aside>
<div class="sidebar-dimmer"></div> <div class="sidebar-dimmer"></div>

View File

@ -0,0 +1,34 @@
<div class="sidebar-card-widget">
<div class="item-headline">
<i class="fas fa-chart-line"></i>
<span>网站资讯</span>
</div>
<div class="webinfo">
<!-- <div class="webinfo-item">
<div class="item-name">已运行时间 :</div>
<div class="item-count" id="runtimeshow" data-publishdate="2021-07-28T14:00:00.000Z">409 天</div>
</div>
<div class="webinfo-item">
<div class="item-name">本站总字数 :</div>
<div class="item-count">21.4k</div>
</div> -->
{{ with .Site.Params.analytics.busuanzi }}
<div class="webinfo-item">
<div class="item-name">
<i class="fas {{ .visitorsIcon }}"></i>{{ T "VisitorsLabel" }}
</div>
<div class="item-count" id="busuanzi_value_site_uv"></div>
</div>
<div class="webinfo-item">
<div class="item-name">
<i class="fas {{ .viewsIcon }}"></i>{{ T "PageViewsLabel" }}
</div>
<div class="item-count" id="busuanzi_value_site_pv"></div>
</div>
{{ end }}
<!-- <div class="webinfo-item">
<div class="item-name">最后更新时间 :</div>
<div class="item-count" id="last-push-date" data-lastpushdate="2022-05-13T03:49:57.728Z">4 个月前</div>
</div> -->
</div>
</div>