aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/video-container.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/video-container.html')
-rw-r--r--themes/default/layouts/partials/video-container.html64
1 files changed, 45 insertions, 19 deletions
diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html
index 79df910..9e28e3d 100644
--- a/themes/default/layouts/partials/video-container.html
+++ b/themes/default/layouts/partials/video-container.html
@@ -1,48 +1,74 @@
{{- $cache := "" -}}
+{{- $source := "" -}}
+{{- $timestamp := "" -}}
{{- $caption := .Caption -}}
+{{- $remote := .Remote -}}
{{- $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 -}}
+{{- $storage := print $.Author "/media/" $immutable $extension -}}
+{{- $cached := fileExists (path.Join "public/" $storage) -}}
-{{- if not (fileExists (path.Join "public/" $fileCache)) -}}
- {{- with $remote := resources.GetRemote .Source -}}
+{{- 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 -}}
- {{- if fileExists $public -}}
- {{- else -}}
+ {{- 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 -}}
- {{- $cache = . | resources.Copy $fileCache -}}
- {{- $cache = $cache.RelPermalink -}}
{{- else -}}
- {{- $caption = "No remote video data found for source" -}}
+ {{- $caption = "Unable to load remote source data" -}}
{{- end -}}
{{- else -}}
- {{- $cache = resources.Get (path.Join "public/" $fileCache) -}}
- {{- $cache = $cache.Content | resources.FromString $fileCache -}}
- {{- $cache = $cache.RelPermalink -}}
+ {{- 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 -}}
- {{ .Options | 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>
+ {{- 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>
+ <br />
Index: {{ with $cache }} {{ print "[Cache](" . ")" | markdownify }} &middot; {{ end }}
{{ print "[Source](" .Source ")" | markdownify }}
</footer>