From 2fe40c752b4272484972f141e406fbcb7fa0cdb8 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 3 Dec 2022 01:02:40 -0500 Subject: themes/default/layouts/shortcodes/video.html: Default to self always To avoid hotlinking by mistake. Support media start and end fragments (https://www.w3.org/TR/media-frags/) separately. Add remote parameter for offloading to source --- .../default/layouts/partials/video-container.html | 21 ++++++++++++++++++--- themes/default/layouts/shortcodes/imgur.html | 13 ------------- themes/default/layouts/shortcodes/version.html | 2 +- themes/default/layouts/shortcodes/video.html | 5 +++-- 4 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 themes/default/layouts/shortcodes/imgur.html (limited to 'themes') diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index 488d4ec..520a16d 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -1,12 +1,22 @@ {{- $cache := "" -}} +{{- $source := "" -}} {{- $timestamp := "" -}} {{- $caption := .Caption -}} +{{- $remote := .Remote -}} {{- $public := print "public/" .Source -}} {{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}} {{- $extension := path.Ext .Source -}} {{- $fileCache := print $.Author "/media/" $immutable $extension -}} {{- $notCached := not (fileExists (path.Join "public/" $fileCache)) -}} +{{- if .Start -}} + {{- $timestamp = print "#t=" .Start -}} +{{- end -}} + +{{- if .End -}} + {{- $timestamp = print "#t=," .End -}} +{{- end -}} + {{- if and .Start .End -}} {{- $timestamp = print "#t=" .Start "," .End -}} {{- end -}} @@ -14,8 +24,7 @@ {{- if $notCached -}} {{- with $remote := resources.GetRemote .Source -}} {{- with .Err -}} - {{- if fileExists $public -}} - {{- else -}} + {{- if not (fileExists $public) -}} {{- $caption = "No local video data found for source" -}} {{- end -}} {{- else -}} @@ -31,6 +40,12 @@ {{- $cache = $cache.Permalink -}} {{- end -}} +{{- $source = $cache -}} + +{{- if .Remote -}} + {{- $source = .Source -}} +{{- end -}} +