blob: 9e28e3d3f4ea10fbd83564133efcb2a59c9e3d23 (
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
|
{{- $cache := "" -}}
{{- $source := "" -}}
{{- $timestamp := "" -}}
{{- $caption := .Caption -}}
{{- $remote := .Remote -}}
{{- $public := print "public/" .Source -}}
{{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}}
{{- $extension := path.Ext .Source -}}
{{- $storage := print $.Author "/media/" $immutable $extension -}}
{{- $cached := fileExists (path.Join "public/" $storage) -}}
{{- if .Start -}}
{{- $timestamp = print "#t=" .Start -}}
{{- end -}}
{{- if .End -}}
{{- $timestamp = print "#t=," .End -}}
{{- end -}}
{{- if and .Start .End -}}
{{- $timestamp = print "#t=" .Start "," .End -}}
{{- end -}}
{{- if not $cached -}}
{{- with $remote := cond (default true $.Context.Site.Params.site.offline) false (resources.GetRemote .Source) -}}
{{- with .Err -}}
{{- warnf "Video fetch %s" . -}}
{{- if not (fileExists $public) -}}
{{- $caption = "No local video data found for source" -}}
{{- end -}}
{{- else -}}
{{- $cache = $remote | resources.Copy $storage -}}
{{- $cache = $cache.Permalink -}}
{{- end -}}
{{- else -}}
{{- $caption = "Unable to load remote source data" -}}
{{- end -}}
{{- else -}}
{{- with $cache = resources.Get (path.Join "public/" $storage) -}}
{{- $cache = print ("" | absURL) (strings.TrimLeft "public" $cache) -}}
{{- end -}}
{{- end -}}
{{- $source = $cache -}}
{{- if .Remote -}}
{{- $source = .Source -}}
{{- end -}}
<video-container>
<video
title="{{ .Title }}"
preload="{{ .Preload }}"
data-orientation="{{ .Orientation }}"
{{ with .Poster }} poster="{{ . }}" {{ end -}}
{{ with .Width }} width="{{ . }}" {{ end -}}
{{ with .Height }} height="{{ . }}" {{ end -}}
{{- range $value := (split .Options " ") }}
{{- printf `%s=""` $value | safeHTMLAttr }}
{{ end -}}
>
<source src="{{ $source }}{{ $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>
|