From 19612a2213faa3747829838c0014822c75b3bb4c Mon Sep 17 00:00:00 2001 From: Athanasia Monika Mowinckel Date: Fri, 19 Apr 2024 13:31:38 +0200 Subject: [PATCH 1/3] dont fail on remote r-ladies blog image unavailable --- data/rblogs/test2.org.json | 12 ++++++++++++ data/rblogs/testing.com.json | 6 +++--- .../hugo-rladies/layouts/rladies-blogs/single.html | 14 +++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 data/rblogs/test2.org.json diff --git a/data/rblogs/test2.org.json b/data/rblogs/test2.org.json new file mode 100644 index 000000000..cb46211ec --- /dev/null +++ b/data/rblogs/test2.org.json @@ -0,0 +1,12 @@ +{ + "title": "Google", + "url": "https://google.com", + "photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc43c51f.png", + "description": "", + "authors": [ + { + "name": "The whole world", + "social_media": [{}] + } + ] +} \ No newline at end of file diff --git a/data/rblogs/testing.com.json b/data/rblogs/testing.com.json index cb46211ec..db17b3a6e 100644 --- a/data/rblogs/testing.com.json +++ b/data/rblogs/testing.com.json @@ -1,11 +1,11 @@ { - "title": "Google", + "title": "Google test", "url": "https://google.com", - "photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc43c51f.png", + "photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc4f.png", "description": "", "authors": [ { - "name": "The whole world", + "name": "This should have no image", "social_media": [{}] } ] diff --git a/themes/hugo-rladies/layouts/rladies-blogs/single.html b/themes/hugo-rladies/layouts/rladies-blogs/single.html index 7e46ccb05..67bbc9180 100644 --- a/themes/hugo-rladies/layouts/rladies-blogs/single.html +++ b/themes/hugo-rladies/layouts/rladies-blogs/single.html @@ -23,11 +23,15 @@ {{ $grav := ( md5 $rb.url ) }} {{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" $grav )}} {{ with $rb.photo_url }} - {{ $image := resources.GetRemote . }} - {{ with $image }} - {{ $img := . }} - {{ $img := $img.Fill "300x300" }} - {{ $data.Set "photo" $img.RelPermalink }} + {{ with resources.GetRemote . }} + {{ with .Err }} + {{ else }} + {{ $img := . }} + {{ $img := $img.Fill "300x300" }} + {{ $data.Set "photo" $img.RelPermalink }} + {{ end }} + {{ else }} + {{ errorf "Unable to get remote resource %q" . }} {{ end }} {{ end }} From deba65e01ea72ad81b5f84b43c1b3229bbe5d987 Mon Sep 17 00:00:00 2001 From: Athanasia Monika Mowinckel Date: Fri, 19 Apr 2024 13:46:09 +0200 Subject: [PATCH 2/3] see fulll error --- themes/hugo-rladies/layouts/rladies-blogs/single.html | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/hugo-rladies/layouts/rladies-blogs/single.html b/themes/hugo-rladies/layouts/rladies-blogs/single.html index 67bbc9180..555ccc511 100644 --- a/themes/hugo-rladies/layouts/rladies-blogs/single.html +++ b/themes/hugo-rladies/layouts/rladies-blogs/single.html @@ -25,6 +25,7 @@ {{ with $rb.photo_url }} {{ with resources.GetRemote . }} {{ with .Err }} + {{ errorf "Unable to get remote resource %q: %s" . $rb.photo_url }} {{ else }} {{ $img := . }} {{ $img := $img.Fill "300x300" }} From ddf5a0944bb1a0098d98b59f34363689a75ede64 Mon Sep 17 00:00:00 2001 From: Athanasia Monika Mowinckel Date: Fri, 19 Apr 2024 22:48:13 +0200 Subject: [PATCH 3/3] throw warning rather than error for remote image fail --- themes/hugo-rladies/layouts/rladies-blogs/single.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/themes/hugo-rladies/layouts/rladies-blogs/single.html b/themes/hugo-rladies/layouts/rladies-blogs/single.html index 555ccc511..98fec8867 100644 --- a/themes/hugo-rladies/layouts/rladies-blogs/single.html +++ b/themes/hugo-rladies/layouts/rladies-blogs/single.html @@ -20,19 +20,18 @@ {{ end }} {{ $descr := $data.Get "descr" }} - {{ $grav := ( md5 $rb.url ) }} - {{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" $grav )}} + {{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" ( md5 $rb.url ) ) }} {{ with $rb.photo_url }} {{ with resources.GetRemote . }} {{ with .Err }} - {{ errorf "Unable to get remote resource %q: %s" . $rb.photo_url }} + {{ else }} {{ $img := . }} {{ $img := $img.Fill "300x300" }} {{ $data.Set "photo" $img.RelPermalink }} {{ end }} {{ else }} - {{ errorf "Unable to get remote resource %q" . }} + {{ warnf "Unable to get remote resource %q" . }} {{ end }} {{ end }}