mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-09-02 11:42:39 +00:00
🎉 Feat: add "不蒜子" count and site run time (#18)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
- :tada: Feat: add PWA support
|
||||
- :tada: Feat: add Watermark support ([#16](https://github.com/Lruihao/FixIt/issues/16))
|
||||
- :tada: Feat: add "不蒜子" count and site run time ([#18](https://github.com/Lruihao/FixIt/issues/18))
|
||||
- :sparkles: Feat: add public network security config (only in China) ([#15](https://github.com/Lruihao/FixIt/issues/15))
|
||||
- :bug: Fix: add scroll-margin to headerlink
|
||||
- :bug: Fix: Check if content is empty beforing passing
|
||||
|
||||
@@ -17,8 +17,35 @@ footer {
|
||||
margin-right: .25rem;
|
||||
}
|
||||
|
||||
.animate-icon {
|
||||
color: #dc143c;
|
||||
animation: icon-animate 1.33s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.color-dark-gray{
|
||||
color: DarkSlateGray;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@include blur;
|
||||
}
|
||||
|
||||
@keyframes icon-animate {
|
||||
0%,100% {
|
||||
transform: scale(1)
|
||||
}
|
||||
|
||||
10%,30% {
|
||||
transform: scale(.9)
|
||||
}
|
||||
|
||||
20%,40%,60%,80% {
|
||||
transform: scale(1.1)
|
||||
}
|
||||
|
||||
50%,70% {
|
||||
transform: scale(1.1)
|
||||
}
|
||||
}
|
||||
@@ -1010,6 +1010,17 @@ enableEmoji = true
|
||||
# 水印字体大小,单位:rem
|
||||
fontSize = 0.85
|
||||
|
||||
# Busuanzi count since v0.2.12
|
||||
# 不蒜子统计
|
||||
[params.ibruce]
|
||||
enable = true
|
||||
# Enable in post meta
|
||||
# 在文章中开启
|
||||
enablePost = false
|
||||
# Site creation time
|
||||
# 网站创立时间
|
||||
siteTime = '2018-05-28T20:01:01+08:00'
|
||||
|
||||
# Site verification code for Google/Bing/Yandex/Pinterest/Baidu
|
||||
# 网站验证代码,用于 Google/Bing/Yandex/Pinterest/Baidu
|
||||
[params.verification]
|
||||
|
||||
+10
-1
@@ -53,6 +53,15 @@ other = "Switch Theme"
|
||||
# === partials/footer.html ===
|
||||
[poweredBySome]
|
||||
other = "Powered by {{ .Hugo }} | Theme - {{ .Theme }}"
|
||||
|
||||
[siteUV]
|
||||
other = "Total visitors"
|
||||
|
||||
[sitePV]
|
||||
other = "Total visits"
|
||||
|
||||
[siteRuning]
|
||||
other = "Site running ..."
|
||||
# === partials/footer.html ===
|
||||
|
||||
# === partials/comment.html ===
|
||||
@@ -71,7 +80,7 @@ other = "en_US"
|
||||
other = "Search"
|
||||
|
||||
[searchPlaceholder]
|
||||
other = "Search titles or contents..."
|
||||
other = "Search titles or contents ..."
|
||||
|
||||
[clear]
|
||||
other = "Clear"
|
||||
|
||||
+10
-1
@@ -54,6 +54,15 @@ other = "切换主题"
|
||||
# === partials/footer.html ===
|
||||
[poweredBySome]
|
||||
other = "由 {{ .Hugo }} 强力驱动 | 主题 - {{ .Theme }}"
|
||||
|
||||
[siteUV]
|
||||
other = "总访客数"
|
||||
|
||||
[sitePV]
|
||||
other = "总访问量"
|
||||
|
||||
[siteRuning]
|
||||
other = "网站运行中 ..."
|
||||
# === partials/footer.html ===
|
||||
|
||||
# === partials/comment.html ===
|
||||
@@ -72,7 +81,7 @@ other = "zh_CN"
|
||||
other = "搜索"
|
||||
|
||||
[searchPlaceholder]
|
||||
other = "搜索文章标题或内容..."
|
||||
other = "搜索文章标题或内容 ..."
|
||||
|
||||
[clear]
|
||||
other = "清空"
|
||||
|
||||
@@ -54,6 +54,15 @@ other = "切換主題"
|
||||
# === partials/footer.html ===
|
||||
[poweredBySome]
|
||||
other = "Powered by {{ .Hugo }} | Theme - {{ .Theme }}"
|
||||
|
||||
[siteUV]
|
||||
other = "總訪客數"
|
||||
|
||||
[sitePV]
|
||||
other = "總訪問量"
|
||||
|
||||
[siteRuning]
|
||||
other = "網站運行中 ..."
|
||||
# === partials/footer.html ===
|
||||
|
||||
# === partials/comment.html ===
|
||||
|
||||
@@ -172,6 +172,12 @@
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* 不蒜子 */ -}}
|
||||
{{- if eq .Site.Params.ibruce.enable true -}}
|
||||
{{- $source := "//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $params.library.css -}}
|
||||
{{- dict "Source" . "Fingerprint" $fingerprint | dict "Scratch" $.Scratch "Data" | partial "scratch/style.html" -}}
|
||||
{{- end -}}
|
||||
@@ -211,22 +217,20 @@
|
||||
{{- /* Inline scripts */ -}}
|
||||
<script type="text/javascript">
|
||||
{{- /* PWA */ -}}
|
||||
{{- if eq .Site.Params.enablePWA true -}}
|
||||
{{- if eq hugo.Environment "production" -}}
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/service-worker.min.js', { scope: '/' })
|
||||
.then(function (registration) {
|
||||
// console.log('Service Worker Registered');
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('error: ', error);
|
||||
});
|
||||
navigator.serviceWorker.ready.then(function (registration) {
|
||||
// console.log('Service Worker Ready');
|
||||
{{- if eq hugo.Environment "production" | and .Site.Params.enablePWA -}}
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/service-worker.min.js', { scope: '/' })
|
||||
.then(function (registration) {
|
||||
// console.log('Service Worker Registered');
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('error: ', error);
|
||||
});
|
||||
}
|
||||
{{- end -}}
|
||||
navigator.serviceWorker.ready.then(function (registration) {
|
||||
// console.log('Service Worker Ready');
|
||||
});
|
||||
}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Watermark */ -}}
|
||||
@@ -243,4 +247,25 @@
|
||||
fontSize: {{ $.Site.Params.watermark.fontSize }}
|
||||
});
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Site time */ -}}
|
||||
{{- if eq .Site.Params.ibruce.enable true | and .Site.Params.ibruce.siteTime -}}
|
||||
function createTime() {
|
||||
let now = new Date();
|
||||
let run = new Date({{ $.Site.Params.ibruce.siteTime }});
|
||||
//總的秒數
|
||||
let runTime = (now - run) / 1000,
|
||||
days = Math.floor(runTime / 60 / 60 / 24),
|
||||
hours = Math.floor(runTime / 60 / 60 - (24 * days)),
|
||||
minutes = Math.floor(runTime / 60 - (24 * 60 * days) - (60 * hours)),
|
||||
seconds = Math.floor((now - run) / 1000 - (24 * 60 * 60 * days) - (60 * 60 * hours) - (60 * minutes));
|
||||
document.querySelector(".run-times").innerHTML = `${days}d ${String(hours).padStart(2,0)}h ${String(minutes).padStart(2,0)}m ${String(seconds).padStart(2,0)}s`;
|
||||
}
|
||||
|
||||
if (!document.hidden) {
|
||||
var siteTime = setInterval("createTime()", 500);
|
||||
} else {
|
||||
clearInterval(siteTime);
|
||||
}
|
||||
{{- end -}}
|
||||
</script>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
{{- safeHTML . -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Hugo and FixIt */ -}}
|
||||
{{- if ne .Site.Params.footer.hugo false -}}
|
||||
<div class="footer-line">
|
||||
@@ -42,6 +43,30 @@
|
||||
<span class="license footer-divider">{{ . | safeHTML }}</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
<div class="footer-line">
|
||||
{{- /* 不蒜子 */ -}}
|
||||
{{- if eq .Site.Params.ibruce.enable true -}}
|
||||
<span id="busuanzi_container_site_uv" title={{ T "siteUV" }}>
|
||||
<i class="fas fa-user color-dark-gray"></i>
|
||||
<span id="busuanzi_value_site_uv">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
</span>
|
||||
</span>
|
||||
{{- if .Site.Params.ibruce.siteTime -}}
|
||||
<span class="site-time footer-divider" title={{ T "siteRuning" }}>
|
||||
<i class="fas fa-heartbeat animate-icon"></i>
|
||||
<span class="run-times">Loading...</span>
|
||||
</span>
|
||||
{{- end -}}
|
||||
<span id="busuanzi_container_site_pv" class="footer-divider" title={{ T "siteUV" }}>
|
||||
<i class="fas fa-eye color-dark-gray"></i>
|
||||
<span id="busuanzi_value_site_pv">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
</span>
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
<div class="footer-line">
|
||||
{{- /* GOV */ -}}
|
||||
|
||||
+93
-88
@@ -1,101 +1,106 @@
|
||||
{{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}}
|
||||
|
||||
{{- define "content" -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- $toc := $params.toc -}}
|
||||
{{- if eq $toc true -}}
|
||||
{{- $toc = .Site.Params.page.toc | default dict -}}
|
||||
{{- else if eq $toc false -}}
|
||||
{{- $toc = dict "enable" false -}}
|
||||
{{- $toc := $params.toc -}}
|
||||
{{- if eq $toc true -}}
|
||||
{{- $toc = .Site.Params.page.toc | default dict -}}
|
||||
{{- else if eq $toc false -}}
|
||||
{{- $toc = dict "enable" false -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- if ne $toc.enable false -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
<article class="page single">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animated flipInX">{{ .Title }}</h1>
|
||||
|
||||
{{- /* Subtitle */ -}}
|
||||
{{- with $params.subtitle -}}
|
||||
<h2 class="single-subtitle">{{ . }}</h2>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- /* Meta */ -}}
|
||||
<div class="post-meta">
|
||||
<div class="post-meta-line">
|
||||
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
|
||||
<span class="post-author">
|
||||
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
</span>
|
||||
|
||||
{{- $categories := slice -}}
|
||||
{{- range .Params.categories -}}
|
||||
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
|
||||
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
|
||||
{{- end -}}
|
||||
{{- with delimit $categories " " -}}
|
||||
<span class="post-category">
|
||||
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
<div class="post-meta-line">
|
||||
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
|
||||
<i class="far fa-calendar-alt fa-fw"></i> <time datetime="{{ . }}">{{ . }}</time>
|
||||
{{- end -}}
|
||||
<i class="fas fa-pencil-alt fa-fw"></i> {{ T "wordCount" .WordCount }}
|
||||
<i class="far fa-clock fa-fw"></i> {{ T "readingTime" .ReadingTime }}
|
||||
{{- $comment := .Scratch.Get "comment" | default dict -}}
|
||||
{{- if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
|
||||
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
|
||||
<i class="far fa-eye fa-fw"></i> <span class="leancloud-visitors-count"></span> {{ T "views" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- if .Site.Params.ibruce.enable | and .Site.Params.ibruce.enablePost -}}
|
||||
<span id="busuanzi_container_page_pv" class="busuanzi_visitors" data-flag-title="{{ .Title }}">
|
||||
<i class="far fa-eye fa-fw"></i> <span id="busuanzi_value_page_pv"></span> {{ T "views" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{- /* Featured image */ -}}
|
||||
{{- $image := $params.featuredimage -}}
|
||||
{{- with .Resources.GetMatch "featured-image" -}}
|
||||
{{- $image = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- with $image -}}
|
||||
<div class="featured-image">
|
||||
{{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if ne $toc.enable false -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
|
||||
<div class="details-summary toc-title">
|
||||
<span>{{ T "contents" }}</span>
|
||||
<span><i class="details-icon fas fa-angle-right"></i></span>
|
||||
</div>
|
||||
<div class="details-content toc-content" id="toc-content-static">
|
||||
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
<article class="page single">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animated flipInX">{{ .Title }}</h1>
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
|
||||
{{- /* Subtitle */ -}}
|
||||
{{- with $params.subtitle -}}
|
||||
<h2 class="single-subtitle">{{ . }}</h2>
|
||||
{{- end -}}
|
||||
{{- /* Footer */ -}}
|
||||
{{- partial "single/footer.html" . -}}
|
||||
|
||||
{{- /* Meta */ -}}
|
||||
<div class="post-meta">
|
||||
<div class="post-meta-line">
|
||||
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
|
||||
<span class="post-author">
|
||||
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
</span>
|
||||
|
||||
{{- $categories := slice -}}
|
||||
{{- range .Params.categories -}}
|
||||
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
|
||||
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
|
||||
{{- end -}}
|
||||
{{- with delimit $categories " " -}}
|
||||
<span class="post-category">
|
||||
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
<div class="post-meta-line">
|
||||
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
|
||||
<i class="far fa-calendar-alt fa-fw"></i> <time datetime="{{ . }}">{{ . }}</time>
|
||||
{{- end -}}
|
||||
<i class="fas fa-pencil-alt fa-fw"></i> {{ T "wordCount" .WordCount }}
|
||||
<i class="far fa-clock fa-fw"></i> {{ T "readingTime" .ReadingTime }}
|
||||
{{- $comment := .Scratch.Get "comment" | default dict -}}
|
||||
{{- if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
|
||||
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
|
||||
<i class="far fa-eye fa-fw"></i> <span class=leancloud-visitors-count></span> {{ T "views" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{- /* Featured image */ -}}
|
||||
{{- $image := $params.featuredimage -}}
|
||||
{{- with .Resources.GetMatch "featured-image" -}}
|
||||
{{- $image = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- with $image -}}
|
||||
<div class="featured-image">
|
||||
{{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if ne $toc.enable false -}}
|
||||
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
|
||||
<div class="details-summary toc-title">
|
||||
<span>{{ T "contents" }}</span>
|
||||
<span><i class="details-icon fas fa-angle-right"></i></span>
|
||||
</div>
|
||||
<div class="details-content toc-content" id="toc-content-static">
|
||||
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
|
||||
{{- /* Footer */ -}}
|
||||
{{- partial "single/footer.html" . -}}
|
||||
|
||||
{{- /* Comment */ -}}
|
||||
{{- partial "comment.html" . -}}
|
||||
</article>
|
||||
{{- /* Comment */ -}}
|
||||
{{- partial "comment.html" . -}}
|
||||
</article>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user