File size: 11,260 Bytes
bc8bf33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
{{- define "partials/page/title.html" -}}
    {{- "<!-- title.html -->" | safeHTML }}
    {{- $subtitle := .Params.Subtitle | default .Description }}
    {{- $isPost := eq (lower .Params.type) (or "post" "articles") }}
    {{- if $subtitle }}
        <hgroup data-bionRead-safe>
            <h1 id="title"
                {{- if $isPost }}
                    data-pagefind-meta="title"
                {{- end }}
                >{{ .Title }}</h1>
            <p  class="subtitle"
                role="doc-subtitle">{{ $subtitle }}</p>
        </hgroup>
    {{- else }}
        <h1 id="title"
            {{- if $isPost }}
                data-pagefind-meta="title"
            {{- end }}
            data-bionRead-safe
            >{{ .Title }}</h1>
    {{- end }}
{{- end }}

{{- define "partials/page/timestamp.html" -}}
    {{- "<!-- timestamp.html-->" | safeHTML }}
    {{- $dateMachine := "2006-01-02T15:04:05-07:00" }}
    {{- $minVersion := index ( split hugo.Version "." ) 1 }}
    {{- $datePublished := cond (lt $minVersion 87) (.PublishDate.Format ( i18n "date_long" )) (.PublishDate | time.Format ":date_long") }}
    {{- $dateModified := cond (lt $minVersion 87) (.Lastmod.Format ( i18n "date_long" )) (.Lastmod | time.Format ":date_long") }}
    {{- $dateOnly := "2006-01-02" }}
    {{- $hasMod := ne (.PublishDate.Format $dateOnly) (.Lastmod.Format  $dateOnly) }}
    <div {{ if $hasMod }}class="date-has-label"{{ end }}>
        <time class="doc-publish-date" datetime="{{ .PublishDate.Format $dateMachine }}" data-time-label="{{ i18n "published" }} {{ i18n "on" | lower }}">
            {{- $datePublished -}}
        </time>
        {{- if $hasMod }}
            <time class="doc-lastmod-date" datetime="{{ .Lastmod.Format $dateMachine }}" data-time-label="{{ i18n "modified" }} {{ i18n "on" | lower }}">
                {{- $dateModified -}}
            </time>
        {{- end }}
    </div>
{{- end }}

{{- define "partials/page/cover.html" -}}
    {{- "<!-- cover.html -->" | safeHTML }}
    {{- $page := .page }}
    {{- $src := or .page.Params.cover .page.Params.image }}
    {{- with .page.Resources.GetMatch "cover.*" }}
        {{- $src = .Permalink }}
    {{- end }}
    {{- return $src }}
{{- end }}

{{- define "partials/flowlines.html" -}}
    {{ "<!-- flowlines -->" | safeHTML }}
    {{- $flowlinesCount := site.Params.Feed.FlowlinesLimit | default 42 }}
    {{- $flowlinesDir := "https://raw.githubusercontent.com/foxihd/hugo-et-hd/master/static/svg/flowlines/" }}
    {{- $src := printf "%s%d.svg" $flowlinesDir (index (seq $flowlinesCount | shuffle) 1) }}
    {{- return $src }}
{{- end }}

{{- define "partials/page/audio.html" -}}
    {{- "<!-- audio.html -->" | safeHTML }}
    {{- $audioFormats := dict
        "aac"  "audio/aac"
        "flac" "audio/flac"
        "mp3"  "audio/mpeg"
        "oga"  "audio/ogg"
        "ogg"  "audio/ogg"
        "opus" "audio/opus"
        "wav"  "audio/wav"
        "weba" "audio/webm"
        "webm" "audio/webm"
    }}
    {{- $audioFiles := dict }}
    {{- range $format, $type := $audioFormats }}
        {{- $file := $.Resources.GetMatch (printf "audio.%s" $format) }}
        {{- if $file }}
            {{- $audioFiles = merge $audioFiles (dict $format $file) }}
        {{- end }}
    {{- end }}
    {{- $audio := .Params.Audio }}
    {{- if or $audio $audioFiles }}
    <audio controls preload="metadata" aria-label="{{ i18n "audio" }} : {{- .Title }}" data-pagefind-ignore="all">
        {{- $ext := index ( split $audio "." ) ( sub ( len ( split $audio "." ) ) 1 ) }}
        {{- with $audio }}
            <source src="{{ . }}"
                {{- range $format, $type := $audioFormats }}
                    {{ if eq $ext $format }}
                        type="{{ $type }}"
                    {{- end }}
                {{- end }}>
        {{- end }}
        {{ with $audioFiles }}
            {{ range $fileExt, $file := $audioFiles }}
            <source src="{{ $file.Permalink }}"
                    {{- range $format, $type := $audioFormats }}
                        {{ if eq $fileExt $format }}
                            type="{{ $type }}"
                        {{- end }}
                    {{- end }}>
            {{ end }}
        {{ end }}
        {{- "<!-- article audio download -->" | safeHTML }}
        <center>
            <p role="contentinfo">{{ i18n "ifNoAudioSupport" }}</p>
            <ul role="presentation">
            {{- $fileName := print site.Title " - " .Title }}
            {{- with $audio }}
                <li>
                    <a href="{{ . }}" download="{{ $fileName }}.{{ $ext }}">
                        <span>{{ $ext }}</span>
                    </a>
                </li>
            {{- end }}
            {{ with $audioFiles }}
                {{ range $fileExt, $file := $audioFiles }}
                <li>
                    <a href="{{ $file.Permalink }}" download="{{ $fileName }}.{{ $fileExt }}">
                        <span>{{ $fileExt }}</span>
                    </a>
                </li>
                {{ end }}
            {{ end }}
            </ul>
        </center>
    </audio>
    {{- end }}
{{- end }}

{{- define "partials/post/tagged.html" -}}
    {{- with .Params.tags }}
    <div id="keywords">
        <span>{{ printf "%s:" (i18n "tags" (len . ))}}&nbsp;</span>
        {{ $class := cond (eq (len .) 1) "inline" "delimiter" }}
        {{ partial "terms.html" (dict "taxonomy" "tags" "class" $class "page" $) }}
    </div>
    {{- end }}
{{- end }}

{{- define "partials/post/colophon.html" -}}
    {{ "<!-- colophon.html -->" | safeHTML }}
    <div id="colophon" style="display: none;" aria-live="polite">
        <strong class="section-title">{{ i18n "colophon" }}</strong>
        <div class="f">
            <div id="qr" role="img" aria-label="QR code"></div>
            <div class="verbose">
                <div class="has-aria-label-top" aria-label="{{ .Title }}"><span>{{- .Permalink }}</span></div>
                <div><span>{{ i18n "accessTime" }}: </span><time id="time-stamp"></time></div>
                {{- $buildTime := now.Format "2006-01-02T15:04:05-07:00" }}
                {{- with $buildTime }}
                <div><span>{{ i18n "buildTime" }}: </span><time datetime="{{ . }}">{{ . }}</time></div>
                {{- end }}
                {{/*  <div class="sf">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreferrer"> Hugo</a></div>  */}}
            </div>
        </div>
    </div>
{{- end }}

{{- define "partials/post/history.html" -}}
    {{- "<!-- history.html -->" | safeHTML }}
    {{- $dateMachine := "2006-01-02T15:04:05-07:00" }}
    {{- $minVersion := index ( split hugo.Version "." ) 1 }}
    {{- $datePublished := cond (lt $minVersion 87) (.PublishDate.Format ( i18n "date_long" )) (.PublishDate | time.Format ":date_long") }}
    {{- $dateModified := cond (lt $minVersion 87) (.Lastmod.Format ( i18n "date_long" )) (.Lastmod | time.Format ":date_long") }}
    {{- $dateOnly := "2006-01-02" }}
    {{- $hasMod := ne (.PublishDate.Format $dateOnly) (.Lastmod.Format  $dateOnly) }}
    {{- if or .Params.History $hasMod }}
        {{- $author := .Params.author | default site.Params.Author.Name }}
        <div id="has-timeline">
            <strong class="section-title">{{ i18n "redactionHistory" }}</strong>
            <ol>
            {{- if .Params.History }}
                {{- range sort .Params.History "date" "asc" }}
                    <li>
                        <details class="presentation js-details" name="redaction-history">
                            <summary>
                                <time datetime="{{ .date | time.Format $dateMachine }}">
                                    {{- .date | time.Format "2006-01-02" -}}
                                </time>
                            </summary>
                            {{- $writtenAuthor := .author | default $author }}
                            {{- with $writtenAuthor }}
                                <div class="has-aria-label-top" aria-label="{{ i18n "author" }}:">{{ . }}</div>
                            {{- end }}
                            {{- with .editor }}
                                <div class="has-aria-label-top" aria-label="{{ i18n "editedBy" }}:">{{ . }}</div>
                            {{- end }}
                            {{- with .reviewer }}
                                <div class="has-aria-label-top" aria-label="{{ i18n "reviewedBy" }}:">{{ . }}</div>
                            {{- end }}
                            {{- with .note }}
                                <div class="has-aria-label-top" aria-label="{{ i18n "note" }}:">{{ . }}</div>
                            {{- end }}
                        </details>
                    </li>
                {{- end }}
            {{- else }}
                <li>
                    <time datetime="{{ .PublishDate.Format $dateMachine }}">{{- $datePublished -}}</time>
                    <span>{{ printf "(%s)" (i18n "published") }}</span>
                </li>
                <li>
                    <time datetime="{{ .Lastmod.Format $dateMachine }}">{{- $dateModified -}}</time>
                    <span>{{ printf "(%s)" (i18n "modified") }}</span>
                </li>
            {{- end }}
            </ol>
            <p>{{ i18n "redactionNotes" }}</p>
        </div>
    {{- end }}
{{- end }}

{{- define "partials/post/contribute.html" -}}
    {{- if index site.Menus "contrib" }}
    <div id="contribute">
        <strong class="section-title">{{ i18n "contribAskReader" }}</strong>
        <br>
        <span>
            {{ i18n "contribAskReaderResponse" }}
            {{- with .Params.Coffee }}
            {{ i18n "contribCoffeeStat" }} {{ printf "%d %s" . (i18n "cup" . | lower) }} {{ i18n "contribCoffeeStatPost" }}
            {{- end }}
            {{ i18n "contribAskReaderToContribute" }}
        </span>
        {{ partial "menu.html" (dict "menuID" "contrib" "open" "open" "page" .)}}
    </div>
    {{- end }}
{{- end }}

{{- define "partials/post/related.html" -}}
    {{- "<!-- related.html -->" | safeHTML }}
    {{- $related := site.RegularPages.Related . | first 5 }}
    {{- $series := .GetTerms "series" }}
    {{- if or $related $series }}
    <nav id="related">
        <strong class="section-title">{{ i18n "related" }}</strong>
        {{- if $series }}
            {{- range $series | first 1 -}}
                <ol>
                {{- range .Pages | first 5 }}
                    {{ if ne $ . -}}
                        <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
                    {{- end }}
                {{- end }}
                {{- if gt (len .Pages) 5 }}
                    <li class="see-more"><a href="{{ .Permalink }}">{{ i18n "series" }}: {{ .Title }}</a></li>
                {{- end }}
                </ol>
            {{- end }}
        {{- else if $related }}
            {{- with $related -}}
                <ol>
                    {{- range . }}
                    <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
                    {{- end }}
                </ol>
            {{- end }}
        {{- end }}
    </nav>
    {{- end }}
{{- end }}