style(*): google js style & trim whitespace

This commit is contained in:
olOwOlo 2018-07-10 01:41:34 +08:00
parent d3a1ab071c
commit 5e356c5f63
No known key found for this signature in database
GPG key ID: 456394B6E7A15EA6
17 changed files with 362 additions and 357 deletions

View file

@ -1,6 +1,6 @@
{{ define "title" }}404 page not found - {{ .Site.Title }}{{ end }}
{{- define "title" }}404 page not found - {{ .Site.Title }}{{ end -}}
{{ define "content" }}
{{- define "content" -}}
<div class="not-found">
<h1 class="error-emoji"></h1>
<p class="error-text">/* 404 page not found. */</p>
@ -15,4 +15,4 @@
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
</script>
{{ end }}
{{- end -}}

View file

@ -1,5 +1,5 @@
{{ if ne .Site.Params.version "3.x" -}}
{{ errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/olOwOlo/hugo-theme-even#installation \n 2. You have an incompatible update. See https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#300 \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/README-zh.md#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#300 \n" -}}
{{ errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/olOwOlo/hugo-theme-even#installation \n 2. You have an incompatible update. See https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#300 \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/README-zh.md#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#300 \n" -}}
{{ end -}}
<!DOCTYPE html>
<html lang="{{ .Site.Language }}">

View file

@ -1,6 +1,6 @@
{{ define "title" }}{{ T "archive" }} - {{ .Site.Title }}{{ end }}
{{- define "title" }}{{ T "archive" }} - {{ .Site.Title }}{{ end -}}
{{ define "content"}}
{{- define "content" }}
{{- $paginator := .Paginate .Data.Pages.ByDate.Reverse .Site.Params.archivePaginate }}
<section id="archive" class="archive">
{{- if and (not $paginator.HasPrev) .Site.Params.showArchiveCount }}
@ -14,7 +14,7 @@
{{- range $index, $element := $paginator.Pages -}}
{{- $thisYear := $element.Date.Format "2006" }}
{{- $lastElement := $index | add -1 | index $paginator.Pages }}
{{ if or (eq $index 0) ( ne ($lastElement.Date.Format "2006") $thisYear ) }}
{{- if or (eq $index 0) ( ne ($lastElement.Date.Format "2006") $thisYear ) }}
<div class="collection-title">
<h2 class="archive-year">{{ $thisYear }}</h2>
</div>
@ -47,4 +47,4 @@
</a>
{{- end }}
</nav>
{{ end }}
{{- end }}

View file

@ -1,7 +1,7 @@
{{ define "content" -}}
<article class="post">
<div class="post-content">
{{ .Content }}
{{ .Content }}
</div>
</article>
{{- end }}

View file

@ -1,21 +1,21 @@
{{ define "title" }}{{ .Title }} · {{ .Site.Title }}{{ end }}
{{- define "title" }}{{ .Title }} · {{ .Site.Title }}{{ end -}}
{{ define "content"}}
{{ $paginator := .Paginate .Data.Pages.ByDate.Reverse .Site.Params.archivePaginate }}
{{- define "content" }}
{{- $paginator := .Paginate .Data.Pages.ByDate.Reverse .Site.Params.archivePaginate -}}
<section id="archive" class="archive">
{{ if not $paginator.HasPrev }}
{{ if eq .Data.Plural "tags" }}
{{ if not $paginator.HasPrev -}}
{{ if eq .Data.Plural "tags" -}}
<div class="archive-title tag">
<h2 class="archive-name">{{ .Title }}</h2>
</div>
{{ else if eq .Data.Plural "categories" }}
{{- else if eq .Data.Plural "categories" -}}
<div class="archive-title category">
<h2 class="archive-name">{{ .Title }}</h2>
</div>
{{ end }}
{{ end }}
{{- end }}
{{- end }}
{{ range $paginator.Pages }}
{{ range $paginator.Pages -}}
<div class="archive-post">
<span class="archive-post-time">
{{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
@ -26,21 +26,21 @@
</a>
</span>
</div>
{{ end }}
{{- end }}
</section>
<!-- pagination -->
<nav class="pagination">
{{ with $paginator.Prev }}
{{ with $paginator.Prev -}}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text">{{ T "prevPage" }}</span>
</a>
{{- end }}
{{ with $paginator.Next }}
{{ with $paginator.Next -}}
<a class="next" href="{{ .URL }}">
<span class="next-text">{{ T "nextPage" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}
</nav>
{{ end }}
{{- end }}

View file

@ -1,44 +1,44 @@
{{ define "title" }}{{ T .Data.Plural }} - {{ .Site.Title }}{{ end }}
{{- define "title" }}{{ T .Data.Plural }} - {{ .Site.Title }}{{ end -}}
{{ define "content" }}
{{- define "content" -}}
{{ $name := .Data.Plural -}}
{{ $terms := .Data.Terms.ByCount -}}
{{ $length := len $terms -}}
{{ if eq $name "categories" }}
{{ if eq $name "categories" -}}
<div class="categories">
<div class="categories-title">
{{ if eq $length 0 }}
{{ if eq $length 0 -}}
{{ T "zeroCategoryCounter" }}
{{ else }}
{{- else -}}
{{ T "categoryCounter" $length }}
{{ end }}
{{- end }}
</div>
<div class="categories-tags">
{{ range $key, $value := $terms }}
{{ range $key, $value := $terms -}}
<a class="category-link" href="{{ $name | relLangURL }}/{{ $value.Term | urlize }}/">
{{ $value.Term }}
<span class="category-count">{{ len $value.Pages }}</span>
</a>
{{ end }}
{{ end -}}
</div>
</div>
{{ else if eq $name "tags" }}
{{- else if eq $name "tags" -}}
<div class="tag-cloud">
<div class="tag-cloud-title">
{{ if eq $length 0 }}
{{ if eq $length 0 -}}
{{ T "zeroTagCounter" }}
{{ else }}
{{- else -}}
{{ T "tagCounter" $length }}
{{ end }}
{{- end }}
</div>
<div class="tag-cloud-tags">
{{ range $key, $value := $terms }}
{{- range $key, $value := $terms }}
<a href="{{ $name | relLangURL }}/{{ $value.Term | urlize }}/">
{{ $value.Term }}
<span class="tag-count">{{ len $value.Pages }}</span>
</a>
{{ end }}
{{ end -}}
</div>
</div>
{{ end }}
{{ end }}
{{- end }}
{{- end }}

View file

@ -1,24 +1,24 @@
{{ define "content" }}
{{- define "content" -}}
<section id="posts" class="posts">
{{/* (index .Site.Paginate) */}}
{{ $paginator := .Paginate (where (where .Data.Pages "Type" "post") ".Params.hiddenfromhomepage" "!=" true) }}
{{ range $paginator.Pages }}
{{- $paginator := .Paginate (where (where .Data.Pages "Type" "post") ".Params.hiddenfromhomepage" "!=" true) }}
{{- range $paginator.Pages -}}
{{ .Render "summary" }}
{{ end }}
{{ end -}}
</section>
<!-- pagination -->
<nav class="pagination">
{{ with $paginator.Prev }}
{{ with $paginator.Prev -}}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text">{{ T "prevPage" }}</span>
</a>
{{- end }}
{{ with $paginator.Next }}
{{ with $paginator.Next -}}
<a class="next" href="{{ .URL }}">
<span class="next-text">{{ T "nextPage" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}
</nav>
{{ end }}
{{- end -}}

View file

@ -1,4 +1,4 @@
{{ if and .IsPage (ne .Params.comment false) }}
{{ if and .IsPage (ne .Params.comment false) -}}
<!-- Disqus -->
{{- if .Site.DisqusShortname -}}
<div id="disqus_thread"></div>
@ -34,76 +34,76 @@
<!-- 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];
<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; }
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
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>
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 -}}
<!-- gitment -->
{{- if .Site.Params.gitment.owner -}}
<div id="comments-gitment"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitmentCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitmentJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitment/gitment-0.0.3.min.css" | relURL }}">
<script src="{{ "lib/gitment/gitment-0.0.3.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
const gitment = new Gitment({
id: '{{ .Date }}',
title: '{{ .Title }}',
link: decodeURI(location.href),
desc: '{{ .Summary }}',
owner: '{{ .Site.Params.gitment.owner }}',
repo: '{{ .Site.Params.gitment.repo }}',
oauth: {
client_id: '{{ .Site.Params.gitment.clientId }}',
client_secret: '{{ .Site.Params.gitment.clientSecret }}'
}
})
gitment.render('comments-gitment')
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/imsun/gitment">comments powered by gitment.</a></noscript>
{{- end }}
<div id="comments-gitment"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitmentCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitmentJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitment/gitment-0.0.3.min.css" | relURL }}">
<script src="{{ "lib/gitment/gitment-0.0.3.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
var gitment = new Gitment({
id: '{{ .Date }}',
title: '{{ .Title }}',
link: decodeURI(location.href),
desc: '{{ .Summary }}',
owner: '{{ .Site.Params.gitment.owner }}',
repo: '{{ .Site.Params.gitment.repo }}',
oauth: {
client_id: '{{ .Site.Params.gitment.clientId }}',
client_secret: '{{ .Site.Params.gitment.clientSecret }}'
}
});
gitment.render('comments-gitment');
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/imsun/gitment">comments powered by gitment.</a></noscript>
{{- end -}}
<!-- gitalk -->
{{- if .Site.Params.gitalk.owner -}}
<div id="gitalk-container"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitalkCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitalkJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitalk/gitalk-1.2.2.min.css" | relURL }}">
<script src="{{ "lib/gitalk/gitalk-1.2.2.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
var gitalk = new Gitalk({
id: '{{ .Date }}',
title: '{{ .Title }}',
clientID: '{{ .Site.Params.gitalk.clientId }}',
clientSecret: '{{ .Site.Params.gitalk.clientSecret }}',
repo: '{{ .Site.Params.gitalk.repo }}',
owner: '{{ .Site.Params.gitalk.owner }}',
admin: ['{{ .Site.Params.gitalk.owner }}'],
body: decodeURI(location.href)
});
gitalk.render('gitalk-container');
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript>
<div id="gitalk-container"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitalkCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitalkJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitalk/gitalk-1.2.2.min.css" | relURL }}">
<script src="{{ "lib/gitalk/gitalk-1.2.2.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
var gitalk = new Gitalk({
id: '{{ .Date }}',
title: '{{ .Title }}',
clientID: '{{ .Site.Params.gitalk.clientId }}',
clientSecret: '{{ .Site.Params.gitalk.clientSecret }}',
repo: '{{ .Site.Params.gitalk.repo }}',
owner: '{{ .Site.Params.gitalk.owner }}',
admin: ['{{ .Site.Params.gitalk.owner }}'],
body: decodeURI(location.href)
});
gitalk.render('gitalk-container');
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript>
{{- end }}
{{- end }}

View file

@ -26,13 +26,13 @@
<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 (T "sitePV") $valueSpan | safeHTML }} </span>
{{ if .Site.Params.busuanzi.siteUV }}<span class="division">|</span>{{ end }}
{{ $valueSpan := printf `<span id="busuanzi_value_site_pv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_pv"> {{ printf (T "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 (T "siteUV") $valueSpan | safeHTML }} </span>
{{ $valueSpan := printf `<span id="busuanzi_value_site_uv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_uv"> {{ printf (T "siteUV") $valueSpan | safeHTML }} </span>
{{- end }}
</div>
{{- end }}
@ -40,7 +40,7 @@
<span class="copyright-year">
{{- $current := now.Format "2006" }}
&copy;
{{ if ne .Site.Params.since $current }}
{{ if ne .Site.Params.since $current -}}
{{ .Site.Params.since }} -
{{ end }}
{{- $current }}

View file

@ -14,16 +14,16 @@
{{- if .Description -}}
<meta name="description" content="{{ .Description | safeHTML }}" />
{{ else if .IsPage }}
{{- else if .IsPage -}}
<meta name="description" content="{{ .Summary | plainify }}" />
{{ else if .Site.Params.description }}
{{- else if .Site.Params.description -}}
<meta name="description" content="{{ .Site.Params.description | safeHTML }}" />
{{- end -}}
{{- if .Keywords -}}
{{ $length := len .Keywords | add -1 -}}
<meta name="keywords" content="{{ range $index, $element := .Keywords }}{{ $element | safeHTML }}{{if ne $index $length }}, {{ end }}{{ end }}" />
{{ else if .Site.Params.keywords }}
{{- else if .Site.Params.keywords -}}
{{ $length := len .Site.Params.keywords | add -1 -}}
<meta name="keywords" content="{{ range $index, $element := .Site.Params.keywords }}{{ $element | safeHTML }}{{if ne $index $length }}, {{ end }}{{ end }}" />
{{- end }}
@ -37,10 +37,10 @@
<!-- Permalink & RSSlink -->
<link rel="canonical" href="{{ .Permalink }}" />
{{ if .RSSLink -}}
{{- if .RSSLink }}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
<link href="{{ .RSSLink }}" rel="feed" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ end -}}
{{- end -}}
<!-- Favicon and Touch icons -->
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}">
@ -50,15 +50,15 @@
<link rel="mask-icon" href="{{ "safari-pinned-tab.svg" | relURL }}" color="#5bbad5">
<!-- debug -->
{{- if .Site.Params.debug }}
{{- if .Site.Params.debug -}}
<script src="https://cdn.jsdelivr.net/npm/eruda@1.2.6/eruda.min.js" integrity="sha256-Jmz4bc3kp+rRrXX2tGadNBKFLwtzMapr8kHABxSAAP8=" crossorigin="anonymous"></script>
<script>eruda.init();</script>
{{- end }}
{{- end -}}
<!-- busuanzi -->
{{ if .Site.Params.busuanzi.enable -}}
{{- if .Site.Params.busuanzi.enable -}}
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{{- end }}
{{- end -}}
<!-- Styles -->
<link href="{{ print "dist/" .Site.Data.even.assets.even.css | relURL }}" rel="stylesheet">
@ -66,10 +66,10 @@
{{ if .Site.Params.fancybox }}{{ .Site.Params.publicCDN.fancyboxCSS | safeHTML }}{{ end }}
{{- else -}}
{{ if .Site.Params.fancybox }}<link href="{{ "lib/fancybox/jquery.fancybox-3.1.20.min.css" | relURL }}" rel="stylesheet">{{ end }}
{{- end }}
{{- end -}}
<!-- custom css -->
{{ range .Site.Params.customCSS }}
{{ range .Site.Params.customCSS -}}
<link rel="stylesheet" href="{{ "/css/" | relURL }}{{ . }}">
{{ end }}

View file

@ -1,16 +1,16 @@
{{ if or .Params.reward (and .Site.Params.reward.enable (ne .Params.reward false)) }}
{{ if or .Params.reward (and .Site.Params.reward.enable (ne .Params.reward false)) -}}
<div class="post-reward">
<input type="checkbox" name="reward" id="reward" hidden />
<label class="reward-button" for="reward">{{ T "reward" }}</label>
<div class="qr-code">
{{ $qrCode := .Site.Params.reward }}
{{ with $qrCode.wechat }}
{{ with $qrCode.wechat -}}
<label class="qr-code-image" for="reward">
<img class="image" src="{{ . }}">
<span>{{ T "rewardWechat" }}</span>
</label>
{{- end }}
{{ with $qrCode.alipay }}
{{ with $qrCode.alipay -}}
<label class="qr-code-image" for="reward">
<img class="image" src="{{ . }}">
<span>{{ T "rewardAlipay" }}</span>

View file

@ -1,7 +1,7 @@
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }}
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2>
{{ $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default false }}
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default false }}
<div class="post-toc-content{{ if not (or .Params.autoCollapseToc (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false))) }} always-active{{ end }}">
{{.TableOfContents}}
</div>

View file

@ -17,55 +17,55 @@
<!-- timeago.JS -->
{{- if and (or .Params.enableOutdatedInfoWarning (and .Site.Params.outdatedInfoWarning.enable (ne .Params.enableOutdatedInfoWarning false))) (or .IsPage .IsHome) }}
{{- if .Site.Params.publicCDN.enable }}
{{ .Site.Params.publicCDN.timeagoJS | safeHTML }}
{{ .Site.Params.publicCDN.timeagoLocalesJS | safeHTML }}
{{ .Site.Params.publicCDN.timeagoJS | safeHTML }}
{{ .Site.Params.publicCDN.timeagoLocalesJS | safeHTML }}
{{- else }}
<script type="text/javascript" src="{{ "lib/timeago/timeago-3.0.2.min.js" | relURL }}"></script>
<script type="text/javascript" src="{{ "lib/timeago/timeago.locales-3.0.2.min.js" | relURL }}"></script>
<script type="text/javascript" src="{{ "lib/timeago/timeago-3.0.2.min.js" | relURL }}"></script>
<script type="text/javascript" src="{{ "lib/timeago/timeago.locales-3.0.2.min.js" | relURL }}"></script>
{{- end }}
<script> // NOTE: timeago.js uses the language code format like "zh_CN" (underscore and case sensitive)
var languageCode = {{ .Site.LanguageCode }}.replace(/-/g, '_').replace(/_(.*)/, function ($0, $1) {return $0.replace($1, $1.toUpperCase());});
timeago().render(document.querySelectorAll('.timeago'), languageCode);
timeago.cancel(); // stop update
</script>
{{- end }}
<script><!-- NOTE: timeago.js uses the language code format like "zh_CN" (underscore and case sensitive) -->
var languageCode = {{ .Site.LanguageCode }}.replace(/-/g, '_').replace(/_(.*)/, function ($0, $1) {return $0.replace($1, $1.toUpperCase());});
timeago().render(document.querySelectorAll('.timeago'), languageCode);
timeago.cancel(); // stop update
</script>
{{- end -}}
<!-- flowchart -->
{{- if and (or .Params.flowchartDiagrams.enable (and .Site.Params.flowchartDiagrams.enable (ne .Params.flowchartDiagrams.enable false))) (or .IsPage .IsHome) -}}
<script>
{{- if .Params.flowchartDiagrams.options -}}
window.flowchartDiagramsOptions = {{ .Params.flowchartDiagrams.options | safeJS }};
{{- else if .Site.Params.flowchartDiagrams.options -}}
window.flowchartDiagramsOptions = {{ .Site.Params.flowchartDiagrams.options | safeJS }};
<script>
{{- if .Params.flowchartDiagrams.options -}}
window.flowchartDiagramsOptions = {{ .Params.flowchartDiagrams.options | safeJS }};
{{- else if .Site.Params.flowchartDiagrams.options -}}
window.flowchartDiagramsOptions = {{ .Site.Params.flowchartDiagrams.options | safeJS }};
{{- end -}}
</script>
{{- if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.flowchartDiagramsJS | safeHTML }}
{{- else -}}
<script src="{{ "lib/flowchartDiagrams/raphael-2.2.7.min.js" | relURL }}" integrity="sha256-67By+NpOtm9ka1R6xpUefeGOY8kWWHHRAKlvaTJ7ONI=" crossorigin="anonymous"></script>
<script src="{{ "lib/flowchartDiagrams/flowchart-1.8.0.min.js" | relURL }}" integrity="sha256-zNGWjubXoY6rb5MnmpBNefO0RgoVYfle9p0tvOQM+6k=" crossorigin="anonymous"></script>
{{- end -}}
</script>
{{- if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.flowchartDiagramsJS | safeHTML }}
{{- else -}}
<script src="{{ "lib/flowchartDiagrams/raphael-2.2.7.min.js" | relURL }}" integrity="sha256-67By+NpOtm9ka1R6xpUefeGOY8kWWHHRAKlvaTJ7ONI=" crossorigin="anonymous"></script>
<script src="{{ "lib/flowchartDiagrams/flowchart-1.8.0.min.js" | relURL }}" integrity="sha256-zNGWjubXoY6rb5MnmpBNefO0RgoVYfle9p0tvOQM+6k=" crossorigin="anonymous"></script>
{{- end -}}
{{- end -}}
<!-- js-sequence-diagrams -->
{{- if and (or .Params.sequenceDiagrams.enable (and .Site.Params.sequenceDiagrams.enable (ne .Params.sequenceDiagrams.enable false))) (or .IsPage .IsHome) -}}
<script>
{{- if .Params.sequenceDiagrams.options -}}
window.sequenceDiagramsOptions = {{ .Params.sequenceDiagrams.options | safeJS }};
{{- else if .Site.Params.sequenceDiagrams.options -}}
window.sequenceDiagramsOptions = {{ .Site.Params.sequenceDiagrams.options | safeJS }};
<script>
{{- if .Params.sequenceDiagrams.options -}}
window.sequenceDiagramsOptions = {{ .Params.sequenceDiagrams.options | safeJS }};
{{- else if .Site.Params.sequenceDiagrams.options -}}
window.sequenceDiagramsOptions = {{ .Site.Params.sequenceDiagrams.options | safeJS }};
{{- end -}}
</script>
{{- if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.sequenceDiagramsJS | safeHTML }}
{{ .Site.Params.publicCDN.sequenceDiagramsCSS | safeHTML }}
{{- else -}}
<script src="{{ "lib/js-sequence-diagrams/webfontloader-1.6.28.js" | relURL }}" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/snap.svg-0.5.1.min.js" | relURL }}" integrity="sha256-oI+elz+sIm+jpn8F/qEspKoKveTc5uKeFHNNVexe6d8=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/underscore-1.8.3.min.js" | relURL }}" integrity="sha256-obZACiHd7gkOk9iIL/pimWMTJ4W/pBsKu+oZnSeBIek=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.js" | relURL }}" integrity="sha384-8748Vn52gHJYJI0XEuPB2QlPVNUkJlJn9tHqKec6J3q2r9l8fvRxrgn/E5ZHV0sP" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.css" | relURL }}" integrity="sha384-6QbLKJMz5dS3adWSeINZe74uSydBGFbnzaAYmp+tKyq60S7H2p6V7g1TysM5lAaF" crossorigin="anonymous">
{{- end -}}
</script>
{{- if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.sequenceDiagramsJS | safeHTML }}
{{ .Site.Params.publicCDN.sequenceDiagramsCSS | safeHTML }}
{{- else -}}
<script src="{{ "lib/js-sequence-diagrams/webfontloader-1.6.28.js" | relURL }}" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/snap.svg-0.5.1.min.js" | relURL }}" integrity="sha256-oI+elz+sIm+jpn8F/qEspKoKveTc5uKeFHNNVexe6d8=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/underscore-1.8.3.min.js" | relURL }}" integrity="sha256-obZACiHd7gkOk9iIL/pimWMTJ4W/pBsKu+oZnSeBIek=" crossorigin="anonymous"></script>
<script src="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.js" | relURL }}" integrity="sha384-8748Vn52gHJYJI0XEuPB2QlPVNUkJlJn9tHqKec6J3q2r9l8fvRxrgn/E5ZHV0sP" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.css" | relURL }}" integrity="sha384-6QbLKJMz5dS3adWSeINZe74uSydBGFbnzaAYmp+tKyq60S7H2p6V7g1TysM5lAaF" crossorigin="anonymous">
{{- end -}}
{{- end }}
<script type="text/javascript" src="{{ print "dist/" .Site.Data.even.assets.even.js | relURL }}"></script>
@ -128,5 +128,5 @@
<!-- custom js -->
{{ range .Site.Params.customJS -}}
<script src="{{ "/js/" | relURL }}{{ . }}"></script>
<script src="{{ "/js/" | relURL }}{{ . }}"></script>
{{ end }}

View file

@ -8,27 +8,27 @@
<span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span>
{{ with .Params.categories -}}
<div class="post-category">
{{ range . }}
{{ range . -}}
<a href="{{ "categories" | relLangURL }}/{{ . | urlize }}/"> {{ . }} </a>
{{ end }}
{{ end -}}
</div>
{{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span>
{{- if .Site.Params.moreMeta }}
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "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 (T "pagePV") $valueSpan | safeHTML }} </span>
{{ $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 (T "pagePV") $valueSpan | safeHTML }} </span>
{{- end }}
</div>
</header>
<!-- TOC -->
{{ partial "post/toc.html" . }}
{{- partial "post/toc.html" . -}}
<!-- Outdated Info Warning -->
{{ partial "post/outdated-info-warning.html" . }}
{{- partial "post/outdated-info-warning.html" . -}}
<!-- Content -->
<div class="post-content">
@ -36,30 +36,30 @@
</div>
<!-- Copyright -->
{{ partial "post/copyright.html" . }}
{{- partial "post/copyright.html" . -}}
<!-- Reward -->
{{ partial "post/reward.html" . }}
{{- partial "post/reward.html" . -}}
<footer class="post-footer">
{{ with .Params.tags -}}
<div class="post-tags">
{{ range . }}
<a href="{{ "tags" | relLangURL }}/{{ . | urlize }}/">{{ . }}</a>
{{ end }}
{{ range . -}}
<a href="{{ "tags" | relLangURL }}/{{ . | urlize }}/">{{ . }}</a>
{{ end -}}
</div>
{{- end }}
{{- end -}}
<!-- Post Pagination -->
<nav class="post-nav">
{{ with .NextInSection }}
{{ with .NextInSection -}}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text nav-default">{{ .Title }}</span>
<span class="prev-text nav-mobile">{{ T "prevPost" }}</span>
</a>
{{- end }}
{{ with .PrevInSection }}
{{ with .PrevInSection -}}
<a class="next" href="{{ .URL }}">
<span class="next-text nav-default">{{ .Title }}</span>
<span class="next-text nav-mobile">{{ T "nextPost" }}</span>

View file

@ -5,14 +5,14 @@
<span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span>
{{ with .Params.categories -}}
<div class="post-category">
{{ range . }}
{{ range . -}}
<a href="{{ "categories" | relLangURL }}/{{ . | urlize }}/"> {{ . }} </a>
{{ end }}
{{ end -}}
</div>
{{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span>
{{- if .Site.Params.moreMeta }}
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span>
{{- end }}
</div>
</header>

View file

@ -1,264 +1,269 @@
'use strict'
'use strict';
const Even = {}
const Even = {};
Even.backToTop = function () {
const $backToTop = $('#back-to-top')
Even.backToTop = function() {
const $backToTop = $('#back-to-top');
$(window).scroll(function () {
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$backToTop.fadeIn(1000)
$backToTop.fadeIn(1000);
} else {
$backToTop.fadeOut(1000)
$backToTop.fadeOut(1000);
}
})
});
$backToTop.click(function () {
$('body,html').animate({ scrollTop: 0 })
})
}
$backToTop.click(function() {
$('body,html').animate({scrollTop: 0});
});
};
Even.mobileNavbar = function () {
const $mobileNav = $('#mobile-navbar')
const $mobileNavIcon = $('.mobile-navbar-icon')
Even.mobileNavbar = function() {
const $mobileNav = $('#mobile-navbar');
const $mobileNavIcon = $('.mobile-navbar-icon');
const slideout = new Slideout({
'panel': document.getElementById('mobile-panel'),
'menu': document.getElementById('mobile-menu'),
'padding': 180,
'tolerance': 70
})
slideout.disableTouch()
'tolerance': 70,
});
slideout.disableTouch();
$mobileNavIcon.click(function () {
slideout.toggle()
})
$mobileNavIcon.click(function() {
slideout.toggle();
});
slideout.on('beforeopen', function () {
$mobileNav.addClass('fixed-open')
$mobileNavIcon.addClass('icon-click').removeClass('icon-out')
})
slideout.on('beforeopen', function() {
$mobileNav.addClass('fixed-open');
$mobileNavIcon.addClass('icon-click').removeClass('icon-out');
});
slideout.on('beforeclose', function () {
$mobileNav.removeClass('fixed-open')
$mobileNavIcon.addClass('icon-out').removeClass('icon-click')
})
slideout.on('beforeclose', function() {
$mobileNav.removeClass('fixed-open');
$mobileNavIcon.addClass('icon-out').removeClass('icon-click');
});
$('#mobile-panel').on('touchend', function () {
slideout.isOpen() && $mobileNavIcon.click()
})
}
$('#mobile-panel').on('touchend', function() {
slideout.isOpen() && $mobileNavIcon.click();
});
};
Even._initToc = function () {
const SPACING = 20
const $toc = $('.post-toc')
const $footer = $('.post-footer')
Even._initToc = function() {
const SPACING = 20;
const $toc = $('.post-toc');
const $footer = $('.post-footer');
if ($toc.length) {
const minScrollTop = $toc.offset().top - SPACING
const maxScrollTop = $footer.offset().top - $toc.height() - SPACING
const minScrollTop = $toc.offset().top - SPACING;
const maxScrollTop = $footer.offset().top - $toc.height() - SPACING;
const tocState = {
start: {
'position': 'absolute',
'top': minScrollTop
'top': minScrollTop,
},
process: {
'position': 'fixed',
'top': SPACING
'top': SPACING,
},
end: {
'position': 'absolute',
'top': maxScrollTop
}
}
'top': maxScrollTop,
},
};
$(window).scroll(function () {
const scrollTop = $(window).scrollTop()
$(window).scroll(function() {
const scrollTop = $(window).scrollTop();
if (scrollTop < minScrollTop) {
$toc.css(tocState.start)
$toc.css(tocState.start);
} else if (scrollTop > maxScrollTop) {
$toc.css(tocState.end)
$toc.css(tocState.end);
} else {
$toc.css(tocState.process)
$toc.css(tocState.process);
}
})
});
}
const HEADERFIX = 30
const $toclink = $('.toc-link')
const $headerlink = $('.headerlink')
const $tocLinkLis = $('.post-toc-content li')
const HEADERFIX = 30;
const $toclink = $('.toc-link');
const $headerlink = $('.headerlink');
const $tocLinkLis = $('.post-toc-content li');
const headerlinkTop = $.map($headerlink, function (link) {
return $(link).offset().top
})
const headerlinkTop = $.map($headerlink, function(link) {
return $(link).offset().top;
});
const headerLinksOffsetForSearch = $.map(headerlinkTop, function (offset) {
return offset - HEADERFIX
})
const headerLinksOffsetForSearch = $.map(headerlinkTop, function(offset) {
return offset - HEADERFIX;
});
const searchActiveTocIndex = function (array, target) {
const searchActiveTocIndex = function(array, target) {
for (let i = 0; i < array.length - 1; i++) {
if (target > array[i] && target <= array[i + 1]) return i
if (target > array[i] && target <= array[i + 1]) return i;
}
if (target > array[array.length - 1]) return array.length - 1
return -1
}
if (target > array[array.length - 1]) return array.length - 1;
return -1;
};
$(window).scroll(function () {
const scrollTop = $(window).scrollTop()
const activeTocIndex = searchActiveTocIndex(headerLinksOffsetForSearch, scrollTop)
$(window).scroll(function() {
const scrollTop = $(window).scrollTop();
const activeTocIndex = searchActiveTocIndex(headerLinksOffsetForSearch, scrollTop);
$($toclink).removeClass('active')
$($tocLinkLis).removeClass('has-active')
$($toclink).removeClass('active');
$($tocLinkLis).removeClass('has-active');
if (activeTocIndex !== -1) {
$($toclink[activeTocIndex]).addClass('active')
let ancestor = $toclink[activeTocIndex].parentNode
$($toclink[activeTocIndex]).addClass('active');
let ancestor = $toclink[activeTocIndex].parentNode;
while (ancestor.tagName !== 'NAV') {
$(ancestor).addClass('has-active')
ancestor = ancestor.parentNode.parentNode
$(ancestor).addClass('has-active');
ancestor = ancestor.parentNode.parentNode;
}
}
})
}
});
};
Even.fancybox = function () {
Even.fancybox = function() {
if ($.fancybox) {
$('.post-content').each(function () {
$(this).find('img').each(function () {
$(this).wrap(`<a class="fancybox" href="${this.src}" data-fancybox="gallery" data-caption="${this.title}"></a>`)
})
})
$('.post-content').each(function() {
$(this).find('img').each(function() {
$(this).wrap(`<a class="fancybox" href="${this.src}" data-fancybox="gallery" data-caption="${this.title}"></a>`);
});
});
$('.fancybox').fancybox({
selector: '.fancybox',
protect: true
})
protect: true,
});
}
}
};
Even.highlight = function () {
const blocks = document.querySelectorAll('pre code')
Even.highlight = function() {
const blocks = document.querySelectorAll('pre code');
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i]
const rootElement = block.parentElement
const lineCodes = block.innerHTML.split(/\n/)
if (lineCodes[lineCodes.length - 1] === '') lineCodes.pop()
const lineLength = lineCodes.length
const block = blocks[i];
const rootElement = block.parentElement;
const lineCodes = block.innerHTML.split(/\n/);
if (lineCodes[lineCodes.length - 1] === '') lineCodes.pop();
const lineLength = lineCodes.length;
let codeLineHtml = ''
let codeLineHtml = '';
for (let i = 0; i < lineLength; i++) {
codeLineHtml += `<div class="line">${i + 1}</div>`
codeLineHtml += `<div class="line">${i + 1}</div>`;
}
let codeHtml = ''
let codeHtml = '';
for (let i = 0; i < lineLength; i++) {
codeHtml += `<div class="line">${lineCodes[i]}</div>`
codeHtml += `<div class="line">${lineCodes[i]}</div>`;
}
block.className += ' highlight'
const figure = document.createElement('figure')
figure.className = block.className
figure.innerHTML = `<table><tbody><tr><td class="gutter"><pre>${codeLineHtml}</pre></td><td class="code"><pre>${codeHtml}</pre></td></tr></tbody></table>`
block.className += ' highlight';
const figure = document.createElement('figure');
figure.className = block.className;
figure.innerHTML = `<table><tbody><tr><td class="gutter"><pre>${codeLineHtml}</pre></td><td class="code"><pre>${codeHtml}</pre></td></tr></tbody></table>`;
rootElement.parentElement.replaceChild(figure, rootElement)
rootElement.parentElement.replaceChild(figure, rootElement);
}
}
};
Even.chroma = function() {
const blocks = document.querySelectorAll('.highlight > .chroma')
const blocks = document.querySelectorAll('.highlight > .chroma');
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i]
const afterHighLight = block.querySelector('pre.chroma > code')
const lang = afterHighLight ? afterHighLight.className : ''
block.className += ' ' + lang
const block = blocks[i];
const afterHighLight = block.querySelector('pre.chroma > code');
const lang = afterHighLight ? afterHighLight.className : '';
block.className += ' ' + lang;
}
}
};
Even.toc = function () {
const tocContainer = document.getElementById('post-toc')
Even.toc = function() {
const tocContainer = document.getElementById('post-toc');
if (tocContainer !== null) {
const toc = document.getElementById('TableOfContents')
const toc = document.getElementById('TableOfContents');
if (toc === null) {
// toc = true, but there are no headings
tocContainer.parentNode.removeChild(tocContainer)
tocContainer.parentNode.removeChild(tocContainer);
} else {
this._refactorToc(toc)
this._linkToc()
this._initToc()
this._refactorToc(toc);
this._linkToc();
this._initToc();
}
}
}
};
Even._refactorToc = function (toc) {
Even._refactorToc = function(toc) {
// when headings do not start with `h1`
const oldTocList = toc.children[0]
let newTocList = oldTocList
let temp
while (newTocList.children.length === 1 && (temp = newTocList.children[0].children[0]).tagName === 'UL') newTocList = temp
const oldTocList = toc.children[0];
let newTocList = oldTocList;
let temp;
while (newTocList.children.length === 1
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') {
newTocList = temp;
}
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList)
}
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
};
Even._linkToc = function () {
const links = document.querySelectorAll('#TableOfContents a:first-child')
for (let i = 0; i < links.length; i++) links[i].className += ' toc-link'
Even._linkToc = function() {
const links = document.querySelectorAll('#TableOfContents a:first-child');
for (let i = 0; i < links.length; i++) links[i].className += ' toc-link';
for (let num = 1; num <= 6; num++) {
const headers = document.querySelectorAll('.post-content>h' + num)
const headers = document.querySelectorAll('.post-content>h' + num);
for (let i = 0; i < headers.length; i++) {
const header = headers[i]
header.innerHTML = `<a href="#${header.id}" class="headerlink"></a>${header.innerHTML}`
const header = headers[i];
header.innerHTML = `<a href="#${header.id}" class="headerlink"></a>${header.innerHTML}`;
}
}
}
};
Even.flowchart = function () {
if (!window.flowchart) return
Even.flowchart = function() {
if (!window.flowchart) return;
const blocks = document.querySelectorAll('pre code.language-flowchart')
const blocks = document.querySelectorAll('pre code.language-flowchart');
for (let i = 0; i < blocks.length; i++) {
if (!window.hljs && i % 2 === 0) continue
if (!window.hljs && i % 2 === 0) continue;
const block = blocks[i]
const block = blocks[i];
const rootElement = window.hljs
? block.parentElement
: block.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement
: block.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
const container = document.createElement('div')
const id = `js-flowchart-diagrams-${i}`
container.id = id
container.className = 'align-center'
rootElement.parentElement.replaceChild(container, rootElement)
const container = document.createElement('div');
const id = `js-flowchart-diagrams-${i}`;
container.id = id;
container.className = 'align-center';
rootElement.parentElement.replaceChild(container, rootElement);
const diagram = flowchart.parse(block.childNodes[0].nodeValue)
diagram.drawSVG(id, window.flowchartDiagramsOptions ? window.flowchartDiagramsOptions : {})
const diagram = flowchart.parse(block.childNodes[0].nodeValue);
diagram.drawSVG(id, window.flowchartDiagramsOptions ? window.flowchartDiagramsOptions : {});
}
}
};
Even.sequence = function () {
if (!window.Diagram) return
Even.sequence = function() {
if (!window.Diagram) return;
const blocks = document.querySelectorAll('pre code.language-sequence')
const blocks = document.querySelectorAll('pre code.language-sequence');
for (let i = 0; i < blocks.length; i++) {
if (!window.hljs && i % 2 === 0) continue
if (!window.hljs && i % 2 === 0) continue;
const block = blocks[i]
const block = blocks[i];
const rootElement = window.hljs
? block.parentElement
: block.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement
: block.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
const container = document.createElement('div')
const id = `js-sequence-diagrams-${i}`
container.id = id
container.className = 'align-center'
rootElement.parentElement.replaceChild(container, rootElement)
const container = document.createElement('div');
const id = `js-sequence-diagrams-${i}`;
container.id = id;
container.className = 'align-center';
rootElement.parentElement.replaceChild(container, rootElement);
const diagram = Diagram.parse(block.childNodes[0].nodeValue)
diagram.drawSVG(id, window.sequenceDiagramsOptions ? window.sequenceDiagramsOptions : {theme: 'simple'})
const diagram = Diagram.parse(block.childNodes[0].nodeValue);
diagram.drawSVG(id, window.sequenceDiagramsOptions
? window.sequenceDiagramsOptions
: {theme: 'simple'});
}
}
};
export {Even}

View file

@ -3,19 +3,19 @@ import {Even} from './even.js'
import '../css/style.scss'
$(document).ready(function () {
Even.backToTop()
Even.mobileNavbar()
Even.toc()
Even.fancybox()
})
Even.backToTop();
Even.mobileNavbar();
Even.toc();
Even.fancybox();
});
Even.flowchart()
Even.sequence()
Even.flowchart();
Even.sequence();
if (window.hljs) {
hljs.initHighlighting()
Even.highlight()
hljs.initHighlighting();
Even.highlight();
} else {
Even.chroma()
Even.chroma();
}