aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2025-01-10 00:00:00 +0000
committertdro <tdro@noreply.example.com>2025-01-10 00:00:00 +0000
commit8afabf38116e255d4b7ab9ef35ac48baf9f54efd (patch)
tree2283553285c7202624c0dc61c1496ba29c3ca493
parent15e9601fb748af75c58a3330272a478656eec9e9 (diff)
downloadcanory-8afabf38116e255d4b7ab9ef35ac48baf9f54efd.tar.gz
canory-8afabf38116e255d4b7ab9ef35ac48baf9f54efd.tar.bz2
canory-8afabf38116e255d4b7ab9ef35ac48baf9f54efd.zip
themes/default/layouts/partials: Fix short circuits
-rw-r--r--themes/default/layouts/_default/_markup/render-image.html9
-rw-r--r--themes/default/layouts/partials/function-caches-images.html9
-rw-r--r--themes/default/layouts/partials/function-generate-feeds.html8
-rw-r--r--themes/default/layouts/partials/video-container.html30
-rw-r--r--themes/default/layouts/shortcodes/attach.html9
5 files changed, 50 insertions, 15 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html
index afccc35..98f5e18 100644
--- a/themes/default/layouts/_default/_markup/render-image.html
+++ b/themes/default/layouts/_default/_markup/render-image.html
@@ -23,7 +23,14 @@
{{- $mimes := slice "image/avif" "image/webp" "image/apng" "image/gif" "image/jpeg" "image/png" "image/svg+xml" -}}
{{- if not $cached -}}
- {{- with $remote := cond (default true $.Page.Site.Params.site.offline) false (resources.GetRemote $fetch) -}}
+
+ {{- $remote := false -}}
+
+ {{- if and (isset site.Params.site "offline") (eq $.Page.Site.Params.site.offline false) -}}
+ {{- $remote = resources.GetRemote $fetch -}}
+ {{- end -}}
+
+ {{- with $remote -}}
{{- with .Err -}}
{{- if fileExists $public -}}
{{- with $local := resources.Get $public -}}
diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html
index c99103b..1685132 100644
--- a/themes/default/layouts/partials/function-caches-images.html
+++ b/themes/default/layouts/partials/function-caches-images.html
@@ -48,7 +48,14 @@
-}}
{{- end -}}
{{- else -}}
- {{- with $image := cond (default true $pageContext.Site.Params.site.offline) false (resources.GetRemote $source) -}}
+
+ {{- $image := false -}}
+
+ {{- if and (isset site.Params.site "offline") (eq $pageContext.Site.Params.site.offline false) -}}
+ {{- $image = resources.GetRemote $source -}}
+ {{- end -}}
+
+ {{- with $image -}}
{{- with .Err -}}
{{- if $localized -}}
{{- $directory := path.Dir $local -}}
diff --git a/themes/default/layouts/partials/function-generate-feeds.html b/themes/default/layouts/partials/function-generate-feeds.html
index 53004b4..757552d 100644
--- a/themes/default/layouts/partials/function-generate-feeds.html
+++ b/themes/default/layouts/partials/function-generate-feeds.html
@@ -10,7 +10,13 @@
{{- $url := delimit (first 1 $data) "" -}}
{{- $retitle := trim (delimit (after 1 $data) " ") " " -}}
- {{- with $fetch := cond (default true $.Site.Params.site.offline) false (resources.GetRemote $url) -}}
+ {{- $fetch := false -}}
+
+ {{- if and (isset site.Params.site "offline") (eq $.Page.Site.Params.site.offline false) -}}
+ {{- $fetch = resources.GetRemote $url -}}
+ {{- end -}}
+
+ {{- with $fetch -}}
{{- with $error := .Err -}}
{{- warnf "Feed fetch %s" $error -}}
diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html
index 4d957bf..070e3cb 100644
--- a/themes/default/layouts/partials/video-container.html
+++ b/themes/default/layouts/partials/video-container.html
@@ -1,13 +1,14 @@
-{{- $cache := "" -}}
-{{- $source := "" -}}
-{{- $timestamp := "" -}}
-{{- $caption := .Caption -}}
-{{- $remote := .Remote -}}
-{{- $public := print "public/" .Source -}}
-{{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}}
-{{- $extension := path.Ext .Source -}}
-{{- $storage := print $.Author "/media/" $immutable $extension -}}
-{{- $cached := fileExists (path.Join "public/" $storage) -}}
+{{- $cache := "" -}}
+{{- $source := "" -}}
+{{- $timestamp := "" -}}
+{{- $remote := .Remote -}}
+{{- $caption := .Caption -}}
+{{- $pageContext := .Context -}}
+{{- $public := print "public/" .Source -}}
+{{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}}
+{{- $extension := path.Ext .Source -}}
+{{- $storage := print $.Author "/media/" $immutable $extension -}}
+{{- $cached := fileExists (path.Join "public/" $storage) -}}
{{- if .Start -}}
{{- $timestamp = print "#t=" .Start -}}
@@ -22,7 +23,14 @@
{{- end -}}
{{- if not $cached -}}
- {{- with $remote := cond (default true $.Context.Site.Params.site.offline) false (resources.GetRemote .Source) -}}
+
+ {{- $remote := false -}}
+
+ {{- if and (isset site.Params.site "offline") (eq $pageContext.Site.Params.site.offline false) -}}
+ {{- $remote = resources.GetRemote .Source -}}
+ {{- end -}}
+
+ {{- with $remote -}}
{{- with .Err -}}
{{- warnf "Video fetch %s" . -}}
{{- if not (fileExists $public) -}}
diff --git a/themes/default/layouts/shortcodes/attach.html b/themes/default/layouts/shortcodes/attach.html
index 6044402..451f8dd 100644
--- a/themes/default/layouts/shortcodes/attach.html
+++ b/themes/default/layouts/shortcodes/attach.html
@@ -14,7 +14,14 @@
{{- $cached := fileExists (path.Join "public/" $storage) -}}
{{- if not $cached -}}
- {{- with $remote := cond (default true $.Page.Site.Params.site.offline) false (resources.GetRemote $url) -}}
+
+ {{- $remote := false -}}
+
+ {{- if and (isset site.Params.site "offline") (eq $.Page.Site.Params.site.offline false) -}}
+ {{- $remote = resources.GetRemote $url -}}
+ {{- end -}}
+
+ {{- with $remote -}}
{{- with .Err -}}
{{- if not (fileExists $localFile) -}}
{{- $caption = "No local attachment data found for source" -}}