summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-04-08 23:06:29 +0800
committereltrac <hi@eltr.ac>2026-04-08 23:06:29 +0800
commit3d25caaa3d7d86c95707b79462a2b4cb07538fa5 (patch)
tree18f55080cccec955065af221f1af0a10b1c55936 /layouts
parentb84df59d6486bbc52ffb971bacb81c63b7904315 (diff)
feat: adapt to new Weepinbell microformats data
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_partials/posts/webmention-mentions.html49
-rw-r--r--layouts/_partials/posts/webmention-replies.html99
-rw-r--r--layouts/_partials/posts/webmention-summary.html26
-rw-r--r--layouts/_partials/posts/webmention.html17
4 files changed, 58 insertions, 133 deletions
diff --git a/layouts/_partials/posts/webmention-mentions.html b/layouts/_partials/posts/webmention-mentions.html
index e4744bf..f6e4e51 100644
--- a/layouts/_partials/posts/webmention-mentions.html
+++ b/layouts/_partials/posts/webmention-mentions.html
@@ -2,54 +2,13 @@
<section class="my-4">
<ul class="list-none p-0 m-0">
{{ range . }}
- {{ if index . "microformats" }}
- {{ $mf := index . "microformats" "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 := "" }}
- {{ $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 }}
-
- <li class="flex gap-2">
- {{ if $photo }}
- <img src="{{ $photo }}" class="h-5 w-5 rd-full inline m-0">
- {{ else }}
- <div class="h-5 w-5 rd-full m-0 bg-neutral-300"></div>
- {{ end }}
- <a href="{{ $authorUrl }}" target="_blank">{{ $authorName }}</a>
- <a href="{{ .webmention.source }}" target="_blank">{{ T "webmention.mentionedThisPost" . }}</a>
- </li>
- {{ else }}
<li class="flex gap-2">
+ <div class="h-5 w-5 rd-full m-0 bg-blockBg text-secondary
+ flex items-center justify-center">@</div>
{{ $u := urls.Parse .webmention.source }}
- <div class="h-5 w-5 rd-full m-0 bg-neutral-300"></div>
<span>{{ $u.Hostname }}</span>
- <a href="{{ .webmention.source }}" target="_blank">{{ T "webmention.mentionedThisPost" . }}</a></li>
- {{ end }}
+ <a href="{{ .webmention.source }}" target="_blank">{{ T "webmention.mentionedThisPost" . }}</a>
+ </li>
{{ end }}
</ul>
</section>
diff --git a/layouts/_partials/posts/webmention-replies.html b/layouts/_partials/posts/webmention-replies.html
index 66b64ef..f6e8fea 100644
--- a/layouts/_partials/posts/webmention-replies.html
+++ b/layouts/_partials/posts/webmention-replies.html
@@ -1,69 +1,44 @@
{{ with . }}
<section class="flex flex-col gap-4 bg-[var(--background-color)]">
-{{ range . }}
- {{ $reply := index . "microformats" "properties" }}
- {{ $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 }}
+ {{ range . }}
+ {{ $mf := .microformats }}
+ {{ $author := $mf.author }}
+ <div class="relative">
+ <header class="flex justify-between items-start">
+ <div class="flex items-center gap-3">
+ <img src="{{ or (index .extra "proxied-photo") $author.photo }}" alt="Profile Picture"
+ class="h-8 w-8 rd-full" loading="lazy" />
+ <div class="text-secondary">
+ <p class="font-bold m-0">
+ <a href="{{ $author.url }}">
+ {{ replaceRE ":.*?:" "" ($author.name) }}
+ </a>
+ </p>
+ {{ $time := $mf.published }}
+ {{ $isFormated := strings.Contains $time " " }}
+ {{ if not $isFormated }}
+ {{ $t := time.AsTime $time }}
+ {{ $time = time.Format "2006-1-2 15:04" $t }}
+ {{ end }}
+ <p class="m-0"><time>{{ $time }}</time></p>
+ </div>
+ </div>
+ <div class="flex items-start">
+ <a href="{{ .webmention.source }}" target="_blank"
+ title="{{ T "viewExternalSource" }}"
+ data-tooltip>↗</a>
+ </div>
+ </header>
-<div class="relative">
- <header class="flex justify-between items-start">
- <div class="flex items-center gap-3">
- <img src="{{ $photo }}" alt="Profile Picture"
- class="h-8 w-8 rd-full" loading="lazy" />
- <div class="text-secondary">
- <p class="font-bold m-0">
- <a href="{{ if reflect.IsMap $author }}
- {{ or (index $author.url 0) (index $reply.url 0) }}
- {{ else }}
- {{ index $reply.url 0 }}
- {{ end }}">
- {{ if reflect.IsMap $author }}
- {{ replaceRE ":.*?:" "" (index $author.name 0) }}
- {{ else }}
- {{ $author }}
+ <div class="max-h-[500px] overflow-y-auto overflow-x-hidden">
+ <div class="webmention-body markdown-body leading-relaxed ml-3 pl-4 pr-2 b-l-4 b-l-solid b-neutral-200/50 dark:b-neutral-700/50">
+ {{ $mf.content.html | safeHTML }}
+ {{ if strings.Contains .webmention.source "https://brid.gy" }}
+ <p class="text-xs text-right text-secondary">通过 <a href="https://brid.gy/" target="_blank">Bridgy</a> 发送自联邦宇宙</p>
{{ end }}
- </a>
- </p>
- {{ $time := (index $reply.published 0) }}
- {{ $isFormated := strings.Contains $time " " }}
- {{ if not $isFormated }}
- {{ $t := time.AsTime $time }}
- {{ $time = time.Format "2006-1-2 15:04" $t }}
- {{ end }}
- <p class="m-0"><time>{{ $time }}</time></p>
- </div>
- </div>
- <div class="flex items-start">
- <a href="{{ .webmention.source }}" target="_blank"
- title="{{ T "viewExternalSource" }}"
- data-tooltip>↗</a>
+ </div>
+ </div>
</div>
- </header>
-
- <div class="max-h-[500px] overflow-y-auto overflow-x-hidden">
- <div class="webmention-body markdown-body leading-relaxed ml-3 pl-4 pr-2 b-l-4 b-l-solid b-neutral-200/50 dark:b-neutral-700/50">
- {{ index (index $reply.content 0) "html" | safeHTML }}
- {{ if strings.Contains .webmention.source "https://brid.gy" }}
- <p class="text-xs text-right text-secondary">通过 <a href="https://brid.gy/" target="_blank">Bridgy</a> 发送自联邦宇宙</p>
- {{ end }}
- </div>
- </div>
-</div>
-{{ end }}
+ {{ end }}
</section>
{{ end }}
diff --git a/layouts/_partials/posts/webmention-summary.html b/layouts/_partials/posts/webmention-summary.html
index 18be734..0f0058c 100644
--- a/layouts/_partials/posts/webmention-summary.html
+++ b/layouts/_partials/posts/webmention-summary.html
@@ -14,23 +14,13 @@
<!-- Likes -->
{{ 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) }}
- <a href="{{ if reflect.IsMap $author }}{{ index $author.url 0 }}{{ else }}#{{ end }}" target="_blank" title="{{ if reflect.IsMap $author }}{{ index $author.name 0 }}{{ else }}{{ $author }}{{ end }}" class="box-border hover:no-underline inline-block h-5 w-5 float-left -ml-1 hover:scale-150 transition-transform">
+ {{ $author := .microformats.author }}
+ {{ $photo := or (index .extra "proxied-photo") $author.photo }}
+ <a href="{{ if $author.url }}{{ $author.url }}{{ else }}#{{ end }}"
+ target="_blank"
+ title="{{ $author.name }}"
+ class="box-border hover:no-underline inline-block h-5 w-5 float-left -ml-1 hover:scale-150 transition-transform"
+ >
{{ $value := math.Floor (mul math.Rand 80) }}
{{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }}
{{ if $photo }}
@@ -44,7 +34,7 @@
</a>
{{ end }}
<div class="text-secondary m-0 text-sm inline ml-2">
- {{ printf (T "webmention.likedBy") (len $likes ) }}
+ {{ printf (T "webmention.likedBy") (len $likes) }}
{{ if gt $othercount 0 }}
{{ printf (T "webmention.repliedAndMentionedBy") $othercount }}
{{ end }}
diff --git a/layouts/_partials/posts/webmention.html b/layouts/_partials/posts/webmention.html
index 77b89f2..21da22f 100644
--- a/layouts/_partials/posts/webmention.html
+++ b/layouts/_partials/posts/webmention.html
@@ -26,20 +26,21 @@
{{ $mentions := slice }}
{{ range $webmentions }}
- {{ $props := index . "microformats" "properties" }}
- {{ $type := index . "microformats" "type" 0 }}
-
- {{ if eq $type "h-entry" }}
- {{ if index $props "like-of" }}
+ {{ $mf := index . "microformats" }}
+ {{ if $mf }}
+ {{ $type := index $mf "type" }}
+ {{ if eq $type "like-of" }}
{{ $likes = $likes | append . }}
-
- {{ else if index $props "repost-of" }}
+ {{ else if eq $type "repost-of" }}
{{ $reposts = $mentions | append . }}
- {{ else }}
+ {{ else if eq $type "in-reply-to" }}
{{ $replies = $replies | append . }}
+ {{ else }}
+ {{ $mentions = $mentions | append . }}
+
{{ end }}
{{ else }}
{{ $mentions = $mentions | append . }}