From 310a425acb95f1bc222820f72576a7c4e0885d16 Mon Sep 17 00:00:00 2001 From: eltrac Date: Mon, 30 Mar 2026 16:52:56 +0800 Subject: refactor: rename action-menu -> webmention The name "action menu" was made because it used to be where people hit like button, comment and send webmentions. Now it's only for webmentions. --- layouts/_partials/posts/action-menu.html | 73 ------------------------------- layouts/_partials/posts/webmention.html | 73 +++++++++++++++++++++++++++++++ layouts/_partials/template/post-page.html | 4 +- layouts/fiction/page.html | 4 +- layouts/library/page.html | 2 +- 5 files changed, 78 insertions(+), 78 deletions(-) delete mode 100644 layouts/_partials/posts/action-menu.html create mode 100644 layouts/_partials/posts/webmention.html diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html deleted file mode 100644 index 51dfcc2d..00000000 --- a/layouts/_partials/posts/action-menu.html +++ /dev/null @@ -1,73 +0,0 @@ -{{ $page := . }} -{{ $currentPagePath := .RelPermalink }} -{{ $webmentions_url := .Site.Params.webmention.src }} - -{{ $cacheKey := print $webmentions_url (now.Format "2006-01-02-1504") }} -{{ $opts := dict "key" $cacheKey }} - -{{ with try (resources.GetRemote $webmentions_url $opts) }} - {{ with .Err }} - {{ errorf "%s" . }} - - {{ else with .Value }} - {{ $webmentions := slice }} - {{ $data := . | transform.Unmarshal }} - - {{ range $data }} - {{ $urlObj := urls.Parse .webmention.target }} - {{ $targetPath := $urlObj.Path }} - - {{ if or (strings.Contains $targetPath $currentPagePath) - (strings.Contains $targetPath ($currentPagePath | urlquery)) }} - {{ $webmentions = $webmentions | append . }} - {{ end }} - {{ end }} - - {{ $likes := slice }} - {{ $replies := slice }} - {{ $reposts := slice }} - {{ $mentions := slice }} - - {{ range $webmentions }} - {{ $props := index . "microformats" "properties" }} - {{ $type := index . "microformats" "type" 0 }} - - {{ if eq $type "h-entry" }} - {{ if index $props "like-of" }} - {{ $likes = $likes | append . }} - - - {{ else if index $props "repost-of" }} - {{ $reposts = $mentions | append . }} - - {{ else }} - {{ $replies = $replies | append . }} - - {{ end }} - {{ else }} - {{ $mentions = $mentions | append . }} - {{ end }} - - {{ end }} - - {{ partial "posts/action-area" $page }} -
- - {{ partial "posts/webmention-summary" (dict - "likes" $likes - "page" $page - "othercount" (add (len $replies) (len $mentions)) - ) }} - -
- {{ partial "posts/webmention-replies" $replies }} - {{ partial "posts/webmention-mentions" $mentions }} -
- - - {{ partial "posts/comment" $page }} -
- {{ else }} -

Unable to fetch webmentions. Please contact webmaster.

- {{ end }} -{{ end }} diff --git a/layouts/_partials/posts/webmention.html b/layouts/_partials/posts/webmention.html new file mode 100644 index 00000000..51dfcc2d --- /dev/null +++ b/layouts/_partials/posts/webmention.html @@ -0,0 +1,73 @@ +{{ $page := . }} +{{ $currentPagePath := .RelPermalink }} +{{ $webmentions_url := .Site.Params.webmention.src }} + +{{ $cacheKey := print $webmentions_url (now.Format "2006-01-02-1504") }} +{{ $opts := dict "key" $cacheKey }} + +{{ with try (resources.GetRemote $webmentions_url $opts) }} + {{ with .Err }} + {{ errorf "%s" . }} + + {{ else with .Value }} + {{ $webmentions := slice }} + {{ $data := . | transform.Unmarshal }} + + {{ range $data }} + {{ $urlObj := urls.Parse .webmention.target }} + {{ $targetPath := $urlObj.Path }} + + {{ if or (strings.Contains $targetPath $currentPagePath) + (strings.Contains $targetPath ($currentPagePath | urlquery)) }} + {{ $webmentions = $webmentions | append . }} + {{ end }} + {{ end }} + + {{ $likes := slice }} + {{ $replies := slice }} + {{ $reposts := slice }} + {{ $mentions := slice }} + + {{ range $webmentions }} + {{ $props := index . "microformats" "properties" }} + {{ $type := index . "microformats" "type" 0 }} + + {{ if eq $type "h-entry" }} + {{ if index $props "like-of" }} + {{ $likes = $likes | append . }} + + + {{ else if index $props "repost-of" }} + {{ $reposts = $mentions | append . }} + + {{ else }} + {{ $replies = $replies | append . }} + + {{ end }} + {{ else }} + {{ $mentions = $mentions | append . }} + {{ end }} + + {{ end }} + + {{ partial "posts/action-area" $page }} +
+ + {{ partial "posts/webmention-summary" (dict + "likes" $likes + "page" $page + "othercount" (add (len $replies) (len $mentions)) + ) }} + +
+ {{ partial "posts/webmention-replies" $replies }} + {{ partial "posts/webmention-mentions" $mentions }} +
+ + + {{ partial "posts/comment" $page }} +
+ {{ else }} +

Unable to fetch webmentions. Please contact webmaster.

+ {{ end }} +{{ end }} diff --git a/layouts/_partials/template/post-page.html b/layouts/_partials/template/post-page.html index bf24252c..9e86a5c9 100644 --- a/layouts/_partials/template/post-page.html +++ b/layouts/_partials/template/post-page.html @@ -36,7 +36,7 @@ {{ partial "content" . }} - {{ partial "posts/action-menu.html" . }} - {{ partial "components/back-to-top.html" . }} + {{ partial "posts/webmention" . }} + {{ partial "components/back-to-top" . }} {{ partial "components/microformats" . }} diff --git a/layouts/fiction/page.html b/layouts/fiction/page.html index 22b04cc0..7535de2f 100644 --- a/layouts/fiction/page.html +++ b/layouts/fiction/page.html @@ -16,8 +16,8 @@ {{ partial "content" . }} - {{ partial "posts/action-menu.html" . }} - {{ partial "components/back-to-top.html" . }} + {{ partial "posts/webmention" . }} + {{ partial "components/back-to-top" . }} {{ partial "components/microformats" . }} {{ end }} diff --git a/layouts/library/page.html b/layouts/library/page.html index b6e13f8d..fbc5d15f 100644 --- a/layouts/library/page.html +++ b/layouts/library/page.html @@ -36,7 +36,7 @@ {{ partial "components/backlinks" (dict "filename" .File.BaseFileName "type" "library" "context" .) }} - {{ partial "posts/action-menu.html" . }} + {{ partial "posts/webmention" . }} {{ partial "components/back-to-top.html" . }} {{ partial "components/microformats" . }} -- cgit v1.2.3