diff options
author | tdro <tdro@noreply.example.com> | 2023-11-02 11:11:08 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-11-02 11:11:08 -0400 |
commit | 8a77cf95f080b06bf95f51e365d955844f08c075 (patch) | |
tree | f8548f5162802f67d5b3c4f74e72ffa434f7cd9e /themes/default/layouts/partials | |
parent | c77a1e4d78f017aac84525e27c510ab56c96ede1 (diff) | |
download | canory-8a77cf95f080b06bf95f51e365d955844f08c075.tar.gz canory-8a77cf95f080b06bf95f51e365d955844f08c075.tar.bz2 canory-8a77cf95f080b06bf95f51e365d955844f08c075.zip |
themes/default/layouts/partials/video-container: Avoid extraneous resource copying
Carefully refer directly to resource
Diffstat (limited to 'themes/default/layouts/partials')
-rw-r--r-- | themes/default/layouts/partials/video-container.html | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index af1a50d..9e28e3d 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -6,8 +6,8 @@ {{- $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)) -}} +{{- $storage := print $.Author "/media/" $immutable $extension -}} +{{- $cached := fileExists (path.Join "public/" $storage) -}} {{- if .Start -}} {{- $timestamp = print "#t=" .Start -}} @@ -21,7 +21,7 @@ {{- $timestamp = print "#t=" .Start "," .End -}} {{- end -}} -{{- if $notCached -}} +{{- if not $cached -}} {{- with $remote := cond (default true $.Context.Site.Params.site.offline) false (resources.GetRemote .Source) -}} {{- with .Err -}} {{- warnf "Video fetch %s" . -}} @@ -29,16 +29,15 @@ {{- $caption = "No local video data found for source" -}} {{- end -}} {{- else -}} - {{- $cache = . | resources.Copy $fileCache -}} + {{- $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/" $fileCache) -}} - {{- $cache = $cache.Content | resources.FromString $fileCache -}} - {{- $cache = $cache.Permalink -}} + {{- with $cache = resources.Get (path.Join "public/" $storage) -}} + {{- $cache = print ("" | absURL) (strings.TrimLeft "public" $cache) -}} {{- end -}} {{- end -}} |