blob: 3f747e7dfb135ccfa51ae1ea68fb280e95faa6ab (
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
|
{{- $cache := "" -}}
{{- $caption := .Caption -}}
{{- $public := print "public/" .Source -}}
{{- $timestamp := print "#t=" .Start "," .End -}}
{{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}}
{{- $extension := path.Ext .Source -}}
{{- $fileCache := print $.Author "/media/" $immutable $extension -}}
{{- if not (fileExists (path.Join "public/" $fileCache)) -}}
{{- with $remote := resources.GetRemote .Source -}}
{{- with .Err -}}
{{- if fileExists $public -}}
{{- else -}}
{{- $caption = "No local video data found for source" -}}
{{- end -}}
{{- else -}}
{{- end -}}
{{- $cache = . | resources.Copy $fileCache -}}
{{- $cache = $cache.RelPermalink -}}
{{- else -}}
{{- $caption = "No remote video data found for source" -}}
{{- end -}}
{{- else -}}
{{- $cache = resources.Get (path.Join "public/" $fileCache) -}}
{{- $cache = $cache.Content | resources.FromString $fileCache -}}
{{- $cache = $cache.RelPermalink -}}
{{- end -}}
<video-container>
<video
title="{{ .Title }}"
preload="{{ .Preload }}"
{{ with .Poster }} poster="{{ . }}" {{ end -}}
{{ with .Width }} width="{{ . }}" {{ end -}}
{{ with .Height }} height="{{ . }}" {{ end -}}
{{ .Options | safeHTMLAttr }}>
<source src="{{ or .Source .Cache }}{{ $timestamp }}">
{{ print "Video: " $caption "." | markdownify }}
<p>
Sorry, your browser does not support embedded videos. Here is a
<a href="{{ .Source }}">link to the video</a> instead.
</p>
</video>
<footer>
{{ $caption | markdownify }}
<br>
Index: {{ with $cache }} {{ print "[Cache](" . ")" | markdownify }} · {{ end }}
{{ print "[Source](" .Source ")" | markdownify }}
</footer>
</video-container>
|