aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-12-26 17:01:51 -0500
committertdro <tdro@noreply.example.com>2022-12-27 20:46:15 -0500
commitd27b1096ac6f3f9d5880ecbd97097bfceecefa13 (patch)
tree70a35f7b44121fa0b4cbc9b8a45b62cb8b368fe4 /themes/default/layouts/partials
parent6bed014c0f3b70bbf8739ea2a48520dd154fa091 (diff)
downloadcanory-d27b1096ac6f3f9d5880ecbd97097bfceecefa13.tar.gz
canory-d27b1096ac6f3f9d5880ecbd97097bfceecefa13.tar.bz2
canory-d27b1096ac6f3f9d5880ecbd97097bfceecefa13.zip
themes/default/layouts/partials: Mix down image metadata and expose author.json
Relegate to section and reduce the rate of multiplicative image transformations
Diffstat (limited to 'themes/default/layouts/partials')
-rw-r--r--themes/default/layouts/partials/author-card.html40
-rw-r--r--themes/default/layouts/partials/author-picture.html43
-rw-r--r--themes/default/layouts/partials/author-section-picture.html37
3 files changed, 75 insertions, 45 deletions
diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html
index 3da9ab2..2897e62 100644
--- a/themes/default/layouts/partials/author-card.html
+++ b/themes/default/layouts/partials/author-card.html
@@ -1,5 +1,4 @@
-{{- $profile := .Data.picture.profile -}}
-{{- $file := not (urls.Parse $profile).Host -}}
+{{- $metadata := print "public/" .Data.user "/author.json" -}}
{{- $host := (urls.Parse ("" | absURL)).Host -}}
@@ -7,31 +6,24 @@
{{- $host = "localhost" -}}
{{- end -}}
-{{- if $file -}}
- {{- $profile = print .Data.user "/" $profile -}}
-{{- end -}}
+{{- $alternate := .Data.name -}}
+{{- $width := "" -}}
+{{- $height := "" -}}
+{{- $source := "" -}}
+{{- $sourceset := "" -}}
-{{- $image := partial "function-caches-images.html"
- (dict
- "Source" $profile
- "Fit" "160x160"
- "Target" (print (partial "function-paths.html" "media") "/" .Data.user "/")
- "Copy" (print (partial "function-paths.html" "media") "/" .Data.user "/" (path.Base $profile))
- "AlternateCopy" (print (partial "function-paths.html" "media") "/" .Data.user "/" (path.BaseName $profile) ".webp")
- )
--}}
+{{- $source = print "/" (partial "function-paths.html" "media") "/" .Data.user "/" .Data.user "-profile" (path.Ext .Data.picture.profile) -}}
+{{- $sourceset = print "/" (partial "function-paths.html" "media") "/" .Data.user "/" .Data.user "-profile.webp" -}}
-{{- $width := $image.Width -}}
-{{- $height := $image.Height -}}
-{{- $source := $image.RelPermalink -}}
-{{- $alternate := .Data.name -}}
-{{- $sourceset := $image.AltRelPermalink -}}
+{{- with $metadata := resources.Get $metadata -}}
+ {{- $metadata = $metadata.Content | transform.Unmarshal -}}
+ {{- $width = $metadata.picture.profileWidth -}}
+ {{- $height = $metadata.picture.profileHeight -}}
+{{- end -}}
-{{- with .Params.feed.favicon -}}
- {{- $width = "64" -}}
- {{- $height = "64" -}}
- {{- $source = $.Params.feed.favicon -}}
- {{- $alternate = $.Params.feed.name -}}
+{{- if not (fileExists (print "public/" $source)) -}}
+ {{- $source = "/data/media/404.png" -}}
+ {{- $sourceset = "" -}}
{{- end -}}
<micro-author>
diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html
index d2c3c6f..05d5cf1 100644
--- a/themes/default/layouts/partials/author-picture.html
+++ b/themes/default/layouts/partials/author-picture.html
@@ -1,32 +1,33 @@
{{- $author := partial "function-authors-data.html" . -}}
-{{- $profile := $author.picture.profile -}}
-{{- $file := not (urls.Parse $profile).Host -}}
+{{- $metadata := print "public/" $author.user "/author.json" -}}
-{{- if $file -}}
- {{- $profile = print $author.user "/" $profile -}}
-{{- end -}}
-
-{{- $image := partial "function-caches-images.html"
- (dict
- "Source" $profile
- "Fit" "160x160"
- "Target" (print (partial "function-paths.html" "media") "/" $author.user "/")
- "Copy" (print (partial "function-paths.html" "media") "/" $author.user "/" (path.Base $profile))
- "AlternateCopy" (print (partial "function-paths.html" "media") "/" $author.user "/" (path.BaseName $profile) ".webp")
- )
--}}
-
-{{- $width := $image.Width -}}
-{{- $height := $image.Height -}}
-{{- $source := $image.RelPermalink -}}
{{- $alternate := $author.name -}}
-{{- $sourceset := $image.AltRelPermalink -}}
+{{- $width := "" -}}
+{{- $height := "" -}}
+{{- $source := "" -}}
+{{- $sourceset := "" -}}
{{- with .Params.feed.favicon -}}
+ {{- $alternate = $.Params.feed.name -}}
{{- $width = "64" -}}
{{- $height = "64" -}}
{{- $source = $.Params.feed.favicon -}}
- {{- $alternate = $.Params.feed.name -}}
+ {{- $sourceset = "" -}}
+{{- else -}}
+ {{- $source = print "/" (partial "function-paths.html" "media") "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile) -}}
+ {{- $sourceset = print "/" (partial "function-paths.html" "media") "/" $author.user "/" $author.user "-profile.webp" -}}
+ {{- with $metadata := resources.Get $metadata -}}
+ {{- $metadata = $metadata.Content | transform.Unmarshal -}}
+ {{- $width = $metadata.picture.profileWidth -}}
+ {{- $height = $metadata.picture.profileHeight -}}
+ {{- else -}}
+ {{- $source = "/data/media/404.png" -}}
+ {{- $sourceset = "" -}}
+ {{- end -}}
+{{- end -}}
+
+{{- if not (path.Ext $author.picture.profile) -}}
+ {{- $source = "/data/media/404.png" -}}
{{- $sourceset = "" -}}
{{- end -}}
diff --git a/themes/default/layouts/partials/author-section-picture.html b/themes/default/layouts/partials/author-section-picture.html
new file mode 100644
index 0000000..5b718d4
--- /dev/null
+++ b/themes/default/layouts/partials/author-section-picture.html
@@ -0,0 +1,37 @@
+{{- $author := partial "function-authors-data.html" . -}}
+{{- $profile := $author.picture.profile -}}
+{{- $file := not (urls.Parse $profile).Host -}}
+
+{{- if $file -}}
+ {{- $profile = print $author.user "/" $profile -}}
+{{- end -}}
+
+{{- $image := partial "function-caches-images.html"
+ (dict
+ "Source" $profile
+ "Fit" "160x160"
+ "Target" (print (partial "function-paths.html" "media") "/" $author.user "/")
+ "Copy" (print (partial "function-paths.html" "media") "/" $author.user "/" $author.user "-profile" (path.Ext $profile))
+ "AlternateCopy" (print (partial "function-paths.html" "media") "/" $author.user "/" $author.user "-profile.webp")
+ )
+-}}
+
+{{- $width := $image.Width -}}
+{{- $height := $image.Height -}}
+{{- $source := $image.RelPermalink -}}
+{{- $alternate := $author.name -}}
+{{- $sourceset := $image.AltRelPermalink -}}
+
+{{- $metadata := (dict
+ "picture" (dict
+ "profileWidth" $width
+ "profileHeight" $height
+ "profileSource" $source
+ "profileAlternate" $alternate
+ "profileSourceSet" $sourceset
+ )
+ )
+-}}
+
+{{- $authorMetadata := merge $author $metadata | jsonify | resources.FromString (print .Section "/author.json") -}}
+{{- $writeToFile := $authorMetadata.Permalink -}}