Welcome to mirror list, hosted at ThFree Co, Russian Federation.

single.html « posts « layouts - github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6470edcbed8b8fee72bf998894ef8b32ba03e8e (plain)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{{- define "title" }}{{ .Title }} | {{ .Site.Params.Title }}{{ end -}}

{{- define "dnsPrefetch" -}}
{{- $params := .Scratch.Get "params" -}}
{{- with $params.Seo.dnsPrefetch -}}
{{- range $index, $value := . -}}
<link rel="dns-prefetch" href="{{ $value }}">
{{- end -}}
{{- end -}}
{{- with $.Site.Params.Seo.dnsPrefetch -}}
{{- range $index, $value := . -}}
<link rel="dns-prefetch" href="{{ $value }}">
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "twitter-card" -}}
{{- $params := .Scratch.Get "params" -}}
{{ $twitterImage := ""}}
{{- with .Resources.GetMatch "featured-image" -}}
{{- if lt 4095 .Width -}}
{{- $twitterImage = (.Resize "4095x q100").Permalink -}}
{{- else -}}
{{- $twitterImage = .Permalink -}}
{{- end -}}
{{- end -}}
{{- with $params.Images -}}
{{- $twitterImage = index . 0 -}}
{{- end -}}
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="{{ $twitterImage }}"/>
<meta name="twitter:title" content="{{ $params.Title }}"/>
<meta name="twitter:description" content="{{ $params.Description }}"/>
{{- with ($params.twitter | default .Site.Params.Social.Twitter ) -}}
<meta name="twitter:creator" content="@{{ . }}"/>
{{- end -}}
{{- end -}}

{{- define "no-content" -}}

{{- $params := .Scratch.Get "params" -}}

{{ $viewCounter := .Site.Params.ViewCounter }}

{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false -}}
{{- end -}}

{{- $pageTheme := $params.Theme | default .Site.Params.Page.theme | default "classic" -}}
{{ $params.UniqueId }}
<div class="container content-article {{ if eq $toc.keepStatic false }}page-toc{{ end }} theme-{{ $pageTheme }}">

    {{- /* Auto TOC */ -}}
    {{- if ne $toc.enable false -}}
        <div class="toc" id="toc-auto">
            <div class="toc-title">{{ T "contents" }}</div>
            <div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
        </div>
    {{- end -}}

    {{- /* Featured image */ -}}
    {{- $image := $params.featuredimage -}}
    {{- $pageImageHidden := $params.hiddenFeaturedImage -}}
    {{- with .Resources.GetMatch "featured-image" -}}
    {{- $image = .Permalink -}}
    {{- end -}}

    {{- $authorName := $params.author | default .Site.Author.name | default " " -}}
    {{ $author := "" }}
    {{- $authorPath := print "data/authors/" $authorName ".json" -}}
    {{ if (fileExists $authorPath) -}}
    {{ $author = index .Site.Data.authors $authorName }}
    {{ end }}

    {{ $postArticle := $params.seo.postArticle | default true }}
    {{ if $postArticle }}
    <article>
    {{ end }}

        <header class="header-post">

            {{ if eq $pageTheme "hero" }}

            {{- $heroImage := "" -}}
            {{- with .Resources.GetMatch "featured-image" -}}
            {{- if lt 2000 .Width -}}
            {{- $heroImage = (.Resize "2000x q100").Permalink -}}
            {{- else -}}
            {{- $heroImage = .Permalink -}}
            {{- end -}}
            {{- end -}}

            <div class="post-hero-grid">
                <div class="post-hero-info">
                    <div class="hero-text-container">

                        <h1>{{ $.Title }}</h1>
                        <p class="hero-text-description">{{ $params.subtitle }}</p>
                    </div>

                    {{ with $author }}
                    <div class="hero-author">

                        {{ with .link }}<a href=" {{- . | safeHTML -}}" class="hero-author-profile">{{ end }}
                            <img class="hero-author-avatar" src="{{ with .avatar }} {{- . | safeHTML -}}{{ end }}" alt="{{ .full_name }}">
                            <div class="profile-text-wrapper">
                                <span class="hero-author-profile-name">{{ .full_name }}</span>
                                <span class="hero-author-profile-title">{{ $params.customAuthor.short_about | default .short_about }}</span>
                            </div>
                        {{ with .link }}</a>{{ end }}

                    </div>
                    {{ end }}

                </div>

                <div class="post-hero-logo">

                    <figure class="hero-img">
                        {{- dict "Src" $heroImage "Title" .Title "Resources" .Resources | partial "plugin/image.html" -}}
                    </figure>

                </div>

            </div>

            <div class="hero-tags">
                {{ if ne $viewCounter nil}}
                <span class="rendered tag-none-display" id="views_container">
                    <span class="svg-icon icon-eye-big"></span><span id="views_value" style="margin-right: 0">{{ if ne $params.Views nil}} {{ $params.Views }} {{ else }} Нет просмотров {{ end }}</span>
                </span>
                {{- end -}}

                {{- with $.Site.Params.dateformat | default "2006-01-02" | $.PublishDate.Format -}}
                {{- $timeAgoDate:= $.Site.Params.TimeAgo.DateFormat | default "2006-01-02" | $.PublishDate.Format -}}
                <span id="post-date" class="rendered">
                    <span class="svg-icon icon-clock-big"></span><time class="timeago" datetime="{{ $timeAgoDate }}">{{ . }}</time>
                </span>
                {{- end -}}

                <span class="rendered">
                    <span class="svg-icon icon-pencil-big"></span>{{ T "wordCount" $.WordCount }}
                </span>
                <span class="rendered">
                    <span class="svg-icon icon-stopwatch-big"></span>{{ T "readingTime" $.ReadingTime }}
                </span>
            </div>
            {{ end }}

            {{ if not (eq $pageTheme "hero") }}
            {{ if or (eq $pageTheme "full") (eq $pageTheme "mega-full") }}
            {{- with $image -}}

            {{- $fullImage := $image -}}
            {{- if eq $pageTheme "full" -}}
            {{- with $.Resources.GetMatch "featured-image" -}}
            {{- if lt 2000 .Width -}}
                {{- $fullImage = (.Resize "2000x q100").Permalink -}}
            {{- else -}}
                {{- $fullImage = .Permalink -}}
            {{- end -}}
            {{- end -}}
            {{- end -}}

            <div class="featured-image" style="background-image: url('{{ $fullImage }}');">
                {{- end -}}
                {{- end -}}
                <div class="post-title">

                    <div class="post-all-meta">
                        {{ partial "breadcrumbs.html" . | safeHTML }}
                        <h1 class="single-title flipInX">{{ $.Title }}</h1>
                        {{- /* Subtitle */ -}}
                        {{- with $params.subtitle -}}
                        <h2 class="single-subtitle">{{ . }}</h2>
                        {{- end -}}
                        {{- /* Meta */ -}}

                        <div class="post-meta summary-post-meta">
                            {{- $categories := slice -}}
                            {{- range $.Params.categories -}}
                            {{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
                            {{- $categories = $categories | append (printf `<a href="%v"><span class="svg-icon icon-folder"></span>%v</a>` $category.RelPermalink $category.Title) -}}
                            {{- end -}}
                            {{- with delimit $categories "&nbsp;" -}}
                            <span class="post-category meta-item">
                                {{ . }}
                            </span>
                            {{- end -}}
                            {{ if ne $viewCounter nil}}
                            <span class="post-meta-views meta-item tag-none-display" id="views_container">
                                <span class="svg-icon icon-eye"></span><span id="views_value" style="margin-right: 0">Нет</span> просмотров
                            </span>
                            {{- end -}}
                            {{- with $.Site.Params.dateformat | default "2006-01-02" | $.PublishDate.Format -}}
                            {{- $timeAgoDate:= $.Site.Params.TimeAgo.DateFormat | default "2006-01-02" | $.PublishDate.Format -}}
                            <span class="post-meta-date meta-item">
                                <span class="svg-icon icon-clock"></span><time class="timeago" datetime="{{ $timeAgoDate }}">{{ . }}</time>
                            </span>
                            {{- end -}}
                            <span class="post-meta-words meta-item">
                                <span class="svg-icon icon-pencil"></span>{{ T "wordCount" $.WordCount }}
                            </span>
                            <span class="post-meta-reading meta-item">
                                <span class="svg-icon icon-stopwatch"></span>{{ T "readingTime" $.ReadingTime }}
                            </span>
                        </div>

                    </div>

                </div>

                {{ if or (eq $pageTheme "full") (eq $pageTheme "mega-full") }}
                {{- with $image -}}
            </div>
            {{- end -}}
            {{- end -}}
            {{- end -}}

        </header>

        <div class="article-post toc-start">

            <div class="content-block content-block-first content-block-position">

                <div class="post single">

                    {{- if and (or (eq $pageTheme "classic") (eq $pageTheme "wide")) (not $pageImageHidden) -}}
                    {{- with $image -}}
                    <div class="image-theme-{{ $pageTheme }}">
                        <img src="{{ $image }}" style="width: 100%">
                    </div>
                    {{- end -}}
                    {{- end -}}

                    {{ if and (eq ($params.Page.hiddenAuthor | default .Site.Params.Page.hiddenAuthor | default false) false) (eq ($params.Page.authorFooter | default .Site.Params.Page.authorFooter | default true) false) (ne $pageTheme "hero")  }}
                    {{- $authorName := $params.author | default .Site.Author.name | default " " -}}
                    {{- partial "block/author.html" $authorName -}}
                    {{ end }}

                    {{- /* Static TOC */ -}}
                    {{- if ne $toc.enable false -}}
                    <div class="details toc" id="toc-static"  data-kept="{{ if $toc.keepStatic }}true{{ end }}">
                        <div class="details-summary toc-title">
                            <span>{{ T "contents" }}</span>
                        </div>
                        <div class="details-content toc-content" id="toc-content-static">
                            {{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction | partial "function/content.html" | safeHTML -}}
                        </div>
                    </div>
                    {{- end -}}

                    {{- /* Content */ -}}

                    {{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
                    {{- $updateDate := . -}}
                    {{- if not (eq  . ($.Site.Params.dateformat | default "2006-01-02" | $.PublishDate.Format)) -}}
                    {{- with $params.upd -}}
                    <p class="is-style-explanation">
                        <span class="s">{{- dict "Date" $updateDate | T "updatedOnDate" -}}:</span> {{ $params.upd }}
                    </p>
                    {{- else -}}
                    <div style="margin: 20px 0 20px 0;">
                        <span class="post-update">
                            <span class="s">{{- dict "Date" . | T "updatedOnDate" -}}</span>
                        </span>
                    </div>
                    {{- end -}}
                    {{- end -}}
                    {{- end -}}

                    {{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction | partial "function/content.html" | safeHTML -}}

                </div>

                {{- if not $params.Page.hiddenFooter -}}
                <footer>
                        <div class="post">
                            {{- /* Footer Post */ -}}
                            {{- partial "single/footer.html" . -}}
                        </div>
                </footer>
                {{- end -}}
            </div>

        <div id="toc-final"></div>
        </div>

    {{ if $postArticle }}
    </article>
    {{ end }}

    {{- if not $params.Page.hiddenUnderPost -}}
        {{- partial "under-post.html" . -}}
    {{- end -}}

    {{- $comment := .Site.Params.Comment  -}}
    {{- if ($params.comment.enable | default $comment.enable) -}}
    <section class="page single comments content-block-position">
        <h1 class="display-hidden">Комментарии</h1>
        {{- $authorComment := $params.authorComment -}}
        {{- if $authorComment -}}
        {{- with $author -}}
        <div class="author-comment">
            <div class="author-avatar author-avatar-comment" style="float: left"><a href="{{ with .link }} {{- . | safeHTML -}}{{ end }}" target="_blank"><img alt="{{ .full_name }}" src="{{ with .avatar }} {{- . | safeHTML -}}{{ end }}"></a></div>
            <div class="name">{{ .full_name }}</div>
            <div class="author-comment-text">{{ $authorComment }}</div>
        </div>
        {{- end -}}
        {{- end -}}
        {{- /* Comment */ -}}
        {{- partial "comment.html" . -}}
    </section>
    {{- end -}}
</div>

{{ if ne $viewCounter nil }}
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const host = '{{ $viewCounter.url }}';
        const pathName = window.location.pathname.replaceAll('/', '_')
        const url = host + '/hit/{{ $viewCounter.key }}/' + pathName.substring(1).slice(0, -1);
        const request = new XMLHttpRequest();
        request.open('GET', url, true);
        request.onload = function () {
            if (this.status >= 200 && this.status < 400) {
                const response = JSON.parse(this.response);
                const views = response.value;
                if (views >= 1 && document.querySelector("#views_value") != null) {
                    document.querySelector("#views_value").textContent = response.value.toLocaleString(undefined, {minimumFractionDigits: 0});
                    document.querySelector("#views_container").style.display = '';
                }
            } else {
                console.log("Call to " + url + " failed with status code " + this.status + ".");
            }
        };
        request.onerror = function () {
            console.log("Call to " + url + " failed with a connection error of some sort.");
        };
        request.send();
    });
</script>
{{- end -}}

{{- end -}}