From bc2f34e733a95d697ec301eddfaca55c9f0e1cca Mon Sep 17 00:00:00 2001 From: eltrac Date: Thu, 2 Apr 2026 09:10:53 +0800 Subject: fix: temporary fix about microformats --- layouts/_partials/posts/webmention-mentions.html | 38 ++++++++++++++++++--- layouts/_partials/posts/webmention-replies.html | 35 ++++++++++++++++---- layouts/_partials/posts/webmention-summary.html | 42 ++++++++++++++++-------- 3 files changed, 90 insertions(+), 25 deletions(-) (limited to 'layouts/_partials/posts') diff --git a/layouts/_partials/posts/webmention-mentions.html b/layouts/_partials/posts/webmention-mentions.html index ab6642a8..e4744bf7 100644 --- a/layouts/_partials/posts/webmention-mentions.html +++ b/layouts/_partials/posts/webmention-mentions.html @@ -4,15 +4,43 @@ {{ range . }} {{ if index . "microformats" }} {{ $mf := index . "microformats" "properties" }} - {{ $author := (index (index ($mf.author) 0) "properties") }} + {{ $author := dict }} + {{ if $mf.author }} + {{ if reflect.IsSlice $mf.author }} + {{ $authorElem := index $mf.author 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ else }} + {{ $author = $mf.author }} + {{ end }} + {{ end }} {{ if eq (index .microformats.type 0) "h-card" }} {{ $author = $mf }} {{ end }} - {{ $photo := or (index . "extra" "proxied-photo") - (index $author.photo 0) }} + {{ $photo := "" }} + {{ $authorName := "" }} + {{ $authorUrl := "" }} + + {{ if reflect.IsMap $author }} + {{ $photo = or (index . "extra" "proxied-photo") (index $author.photo 0) }} + {{ $authorName = index $author.name 0 }} + {{ $authorUrl = index $author.url 0 }} + {{ else }} + {{ $photo = index . "extra" "proxied-photo" }} + {{ $authorName = $author }} + {{ $authorUrl = .webmention.source }} + {{ end }} +
  • - - {{ index $author.name 0 }} + {{ if $photo }} + + {{ else }} +
    + {{ end }} + {{ $authorName }} {{ T "webmention.mentionedThisPost" . }}
  • {{ else }} diff --git a/layouts/_partials/posts/webmention-replies.html b/layouts/_partials/posts/webmention-replies.html index e3f9658e..66b64ef9 100644 --- a/layouts/_partials/posts/webmention-replies.html +++ b/layouts/_partials/posts/webmention-replies.html @@ -2,20 +2,41 @@
    {{ range . }} {{ $reply := index . "microformats" "properties" }} - {{ $author := index (index $reply "author") 0 }} - {{ $author = index $author "properties" }} - {{ $photo := or (index $author.photo 0) (index $reply.photo 0) }} + {{ $author := dict }} + {{ $photo := "" }} + + {{ if $reply.author }} + {{ if reflect.IsSlice $reply.author }} + {{ $authorElem := index $reply.author 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ $photo = or (index $author.photo 0) (index $reply.photo 0) }} + {{ else }} + {{ $author = $reply.author }} + {{ $photo = index $reply.photo 0 }} + {{ end }} + {{ end }}
    Profile Picture -
    +

    - - {{ replaceRE ":.*?:" "" (index $author.name 0) }} + + {{ if reflect.IsMap $author }} + {{ replaceRE ":.*?:" "" (index $author.name 0) }} + {{ else }} + {{ $author }} + {{ end }}

    {{ $time := (index $reply.published 0) }} diff --git a/layouts/_partials/posts/webmention-summary.html b/layouts/_partials/posts/webmention-summary.html index a3a7265d..18be7344 100644 --- a/layouts/_partials/posts/webmention-summary.html +++ b/layouts/_partials/posts/webmention-summary.html @@ -13,19 +13,35 @@ - {{ range $likes }} - {{ $authors := index . "microformats" "properties" "author" }} - {{ $author := index (index $authors 0) "properties" }} - {{ $photo := or (index . "extra" "proxied-photo") - (index $author.photo 0) }} - - {{ $value := math.Floor (mul math.Rand 80) }} - {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} - Profile Picture - + {{ range $likes }} + {{ $authors := index . "microformats" "properties" "author" }} + {{ $author := dict }} + {{ $photo := "" }} + {{ if $authors }} + {{ if reflect.IsSlice $authors }} + {{ $authorElem := index $authors 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ else }} + {{ $author = $authors }} + {{ end }} + {{ end }} + {{ $photo = or (index . "extra" "proxied-photo") (index $author.photo 0) }} + + {{ $value := math.Floor (mul math.Rand 80) }} + {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} + {{ if $photo }} + Profile Picture + {{ else }} +
    + {{ end }} +
    {{ end }}
    {{ printf (T "webmention.likedBy") (len $likes ) }} -- cgit v1.2.3