diff options
Diffstat (limited to 'themes/default/layouts/partials/video-container.html')
-rw-r--r-- | themes/default/layouts/partials/video-container.html | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index 44bbf6b..2d782e6 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -2,19 +2,27 @@ {{- $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 -}} -{{- with $remote := resources.GetRemote .Source -}} - {{- with .Err -}} - {{- if fileExists $public -}} +{{- 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 -}} - {{ $caption = "No local video data found for source" }} - {{- end -}} + {{- end }} + {{- $cache = . | resources.Copy $fileCache -}} + {{- $cache = $cache.RelPermalink -}} {{- else -}} - {{ end }} - {{- $cache = .Content | resources.FromString (print $.Author "/media/" (. | urlize)) -}} - {{- $cache = $cache.RelPermalink }} -{{ else }} - {{ $caption = "No remote video data found for source" }} + {{- $caption = "No remote video data found for source" -}} + {{- end -}} +{{- else -}} + {{- $cache = resources.Get (path.Join "public/" $fileCache) -}} + {{- $cache = $cache.RelPermalink -}} {{- end -}} <video-container> |