aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/video-container.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-12 03:50:28 -0400
committertdro <tdro@noreply.example.com>2022-06-12 03:50:28 -0400
commit878408fb5c8cfc17e695ae846fa0a13c5f0bb848 (patch)
treec38a579d2f8a9f44abb83e040fb778178ef9b66f /themes/default/layouts/partials/video-container.html
parent55abba4c9703d0e5f0ec3c3770d723c22d40a161 (diff)
downloadcanory-878408fb5c8cfc17e695ae846fa0a13c5f0bb848.tar.gz
canory-878408fb5c8cfc17e695ae846fa0a13c5f0bb848.tar.bz2
canory-878408fb5c8cfc17e695ae846fa0a13c5f0bb848.zip
themes/default/layouts/partials/video-container: Source of truth for video embeds
Static videos with cached copy. Convert imgur short code into a video short code helper. Replace dynamic embed with static.
Diffstat (limited to 'themes/default/layouts/partials/video-container.html')
-rw-r--r--themes/default/layouts/partials/video-container.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html
new file mode 100644
index 0000000..8292f12
--- /dev/null
+++ b/themes/default/layouts/partials/video-container.html
@@ -0,0 +1,39 @@
+{{- $cache := "" -}}
+{{- $public := print "public/" .Source -}}
+{{- $timestamp := print "#t=" .Start "," .End -}}
+
+{{- with $remote := resources.GetRemote .Source -}}
+ {{- with .Err -}}
+ {{- if fileExists $public -}}
+ {{- else -}}
+ {{ $caption = "No local video data found for source" }}
+ {{- end -}}
+ {{- else -}}
+ {{ end }}
+ {{- $cache = .Content | resources.FromString (print $.Author "/media/" (. | urlize)) -}}
+ {{- $cache = $cache.RelPermalink }}
+{{ else }}
+ {{ $caption = "No remote video data found for source" }}
+{{- end -}}
+
+<video-container>
+ <video
+ title="{{ .Title }}"
+ preload="{{ .Preload }}"
+ {{ with .Poster }} poster="{{ . }}" {{ end -}}
+ {{ with .Width }} width="{{ . }}" {{ end -}}
+ {{ with .Height }} height="{{ . }}" {{ end -}}
+ {{ .Controls | safeHTMLAttr }}>
+ <source src="{{ or .Source .Cache }}{{ $timestamp }}">
+ <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 }} &middot; {{ end }}
+ {{ print "[Source](" .Source ")" | markdownify }}
+ </footer>
+</video-container>