From 36c049d0efd5036e2f776952da07a34b27760c96 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Sun, 20 Nov 2022 13:26:57 -0800 Subject: [PATCH] Add u-syndication, clean up interactions Add a new "Interactions" section to my pages that contain both Syndication and Webmentions. Make the Syndication links u-syndication. Make both these things children of the
h-entry. --- content/notes/blogging-as-dry.md | 8 ++ layouts/_default/single.html | 4 +- layouts/notes/single.html | 6 +- layouts/partials/full-article.html | 2 - layouts/partials/interact.html | 7 ++ layouts/partials/syndication.html | 15 +++ layouts/partials/webmentions.html | 195 ++++++++++++++--------------- layouts/posts/single.html | 6 +- 8 files changed, 137 insertions(+), 106 deletions(-) create mode 100644 layouts/partials/interact.html create mode 100644 layouts/partials/syndication.html diff --git a/content/notes/blogging-as-dry.md b/content/notes/blogging-as-dry.md index 900408e..1471cad 100644 --- a/content/notes/blogging-as-dry.md +++ b/content/notes/blogging-as-dry.md @@ -6,7 +6,15 @@ replyTitle: "Maintaining a blog is probably the best method I have found to hono replyType: "SocialMediaPosting" replyAuthor: "Adrian Rosell" replyAuthorURI: "https://adrianroselli.com/" +syndicatedCopies: + - title: 'The Fediverse' + url: 'https://pleroma.envs.net/notice/APnxPeFcKz4HvBrckS' + - title: 'IndieNews' + url: 'https://news.indieweb.org/en' + - title: 'IndieForums' + url: 'https://www.indieforums.net' --- The "Don't Repeat Yourself" (DRY) principle is my main motivation for adding content to my site---especially to [my "notes" section]({{}}). I've gone as far as linking my own website in online class discussions (not as a citation; just for DRY). This also combines really well with the [Publish on your Own Site, Syndicate Elsewhere](https://indieweb.org/POSSE) (POSSE) principle. Often, a post of mine syndicates well to multiple destinations. I might reply to a forum on my site and syndicate it to both that forum and to the Fediverse. People reply in both places, and Webmentions aggregate them together on my site (though I often have to send myself those mentions). I only have to write something once. + diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 5f19958..bd6cdeb 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -2,7 +2,9 @@ {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
+
{{ partial "full-article.html" . }} - {{ partial "webmentions.html" . }} + {{ partial "interact.html" . }} +
{{ end }} diff --git a/layouts/notes/single.html b/layouts/notes/single.html index d5f60bd..4edef90 100644 --- a/layouts/notes/single.html +++ b/layouts/notes/single.html @@ -2,9 +2,11 @@ {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
- + +
{{ partial "full-article.html" . }} - {{ partial "webmentions.html" . }} + {{ partial "interact.html" . }} +
{{ partial "prev-next.html" . -}} {{- end }} diff --git a/layouts/partials/full-article.html b/layouts/partials/full-article.html index ff0f212..324d384 100644 --- a/layouts/partials/full-article.html +++ b/layouts/partials/full-article.html @@ -1,4 +1,3 @@ -

{{ .Title }}

{{- if not .Params.disableMeta -}} @@ -14,4 +13,3 @@ {{- end -}} {{- partial "processed-content" . -}} -
diff --git a/layouts/partials/interact.html b/layouts/partials/interact.html new file mode 100644 index 0000000..d774d2a --- /dev/null +++ b/layouts/partials/interact.html @@ -0,0 +1,7 @@ +
+
+

Interact

+

You can interact by sending webmentions or by visiting a syndicated copy of this post.

+{{- partial "syndication.html" . -}} +{{- partial "webmentions.html" . -}} +
diff --git a/layouts/partials/syndication.html b/layouts/partials/syndication.html new file mode 100644 index 0000000..a9a499e --- /dev/null +++ b/layouts/partials/syndication.html @@ -0,0 +1,15 @@ +{{ with .Params.syndicatedCopies }} +

Syndication

+

This post has been syndicated to:

+
    + {{- range . -}} + {{- $type := "SocialMediaPosting" -}} + {{- with ".type" -}} + {{- $type = . -}} + {{- end }} +
  • + {{ .title }} +
  • +{{- end -}} +
+{{- end -}} diff --git a/layouts/partials/webmentions.html b/layouts/partials/webmentions.html index fefa9b0..bc87755 100644 --- a/layouts/partials/webmentions.html +++ b/layouts/partials/webmentions.html @@ -4,103 +4,100 @@ {{- range $i, $r := (getCSV "," "/csv/rewrites.csv") -}} {{- $rewritesDict = merge $rewritesDict (dict (index $r 0) (index $r 1)) -}} {{- end -}} -
-
-

Web­mentions

-

This site supports Webmentions, a backlink-based alternative to traditional comment forms.

- {{ partial "webmention-form.html" . }} - {{- $target := .RelPermalink | replaceRE "^/~seirdy/" "/" }} - {{ $url1 := printf "https://seirdy.one/webmentions/get?status=approved&target=https://seirdy.one%s" $target -}} - {{ $webmentions := (getJSON $url1) -}} - {{- if lt .Date.Unix 1653616670 -}}{{- /* commit c84c8d4 changed my URL schemes, so fetch menchies for the legacy scheme on old posts. */ -}} - {{- $oldTarget := $target | replaceRE "/posts" "" | replaceRE "/$" ".html" -}} - {{- $url2 := printf "https://seirdy.one/webmentions/get?status=approved&target=https://seirdy.one%s" $oldTarget -}} - {{- $webmentions = $webmentions | append (getJSON $url2) -}} - {{- end -}} - {{- if gt (len $webmentions) 0 -}} -

Webmentions received for this post appear in the following list after I approve them. I sometimes send Webmentions to myself on behalf of linking sites that don’t support them. I auto-replace broken links with Wayback Machine snapshots, if they exist.

-
- Toggle Webmentions -
- {{ range sort $webmentions "created_at" -}} - {{ $webmention := . -}} - {{- /* Boolean: should we should handle this webmention like a comment or a linkback? */ -}} - {{- $hasContent := and (isset $webmention "content") (gt (countrunes $webmention.content) 50) -}} - {{- $title := $webmention.title -}} - {{- /* Remove extraneous crap from Fediverse webmentions */ -}} - {{- if findRE "@Seirdy" $webmention.title -}} - {{- $title = $title | replaceRE `^@Seirdy@pleroma.envs.net(\n| )?` "" -}} - {{- /* Mastodon webmentions may include the author in the title followed by a colon; this is redundant. */ -}} - {{- if and (isset $webmention "author_name") (findRE `@` $webmention.source) (not (findRE "^https://bridg.gy" $webmention.source)) -}} - {{ $title = $title | replaceRE `^[^:]{0,20}: ?` "" | replaceRE `^"@Seirdy@pleroma.envs.net ?` `"` }} - {{- end -}} - {{- end -}} - {{- if and ($hasContent) (gt (countrunes $webmention.title) 128) -}} - {{- $title = $webmention.title | strings.TrimSuffix "…" | truncate 128 -}} - {{- end -}} - {{- $src := $webmention.source -}} - {{- with index $rewritesDict $src -}} - {{- $src = . -}} - {{- end -}} - {{- if in $wbmLinks $src -}} - {{- $src = printf "https://web.archive.org/web/0/%s" $src -}} - {{- else if in $archivetodayLinks $src -}} - {{- $src = printf "https://archive.today/oldest/%s" $src -}} - {{- end -}} - {{ if (eq $webmention.type "like") -}} -
- {{- else -}} -
- {{- end -}} - -
- -
-
- {{ if (eq $webmention.type "like") -}} - {{ if $webmention.author_name -}} - {{ $webmention.author_name }} - {{ else if $webmention.title -}} - {{ $webmention.title | replaceRE ` \n` ` -` -}} - {{ else -}} - {{ $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}} - {{ end -}} - this - {{ else -}} - - {{- if $webmention.author_name }} - by - {{- end -}} - {{- if $hasContent -}} - {{- if findRE `^https://brid.gy/[^/]*/mastodon` $webmention.source -}} -

This comment may have major formatting errors that could impact screen reader comprehension.

- {{- end -}} -

{{ $webmention.content | replaceRE `^@Seirdy(@pleroma.envs.net)? ?` "" | replaceRE ` \n` ` -`}}

- {{- end -}} - {{- end }} -
-
+

Web­mentions

+

This site supports Webmentions, a backlink-based alternative to traditional comment forms.

+{{ partial "webmention-form.html" . }} +{{- $target := .RelPermalink | replaceRE "^/~seirdy/" "/" }} +{{ $url1 := printf "https://seirdy.one/webmentions/get?status=approved&target=https://seirdy.one%s" $target -}} +{{ $webmentions := (getJSON $url1) -}} +{{- if lt .Date.Unix 1653616670 -}}{{- /* commit c84c8d4 changed my URL schemes, so fetch menchies for the legacy scheme on old posts. */ -}} + {{- $oldTarget := $target | replaceRE "/posts" "" | replaceRE "/$" ".html" -}} + {{- $url2 := printf "https://seirdy.one/webmentions/get?status=approved&target=https://seirdy.one%s" $oldTarget -}} + {{- $webmentions = $webmentions | append (getJSON $url2) -}} +{{- end -}} +{{- if gt (len $webmentions) 0 -}} +

Webmentions received for this post appear in the following list after I approve them. I sometimes send Webmentions to myself on behalf of linking sites that don’t support them. I auto-replace broken links with Wayback Machine snapshots, if they exist.

+
+ Toggle Webmentions +
+ {{ range sort $webmentions "created_at" -}} + {{ $webmention := . -}} + {{- /* Boolean: should we should handle this webmention like a comment or a linkback? */ -}} + {{- $hasContent := and (isset $webmention "content") (gt (countrunes $webmention.content) 50) -}} + {{- $title := $webmention.title -}} + {{- /* Remove extraneous crap from Fediverse webmentions */ -}} + {{- if findRE "@Seirdy" $webmention.title -}} + {{- $title = $title | replaceRE `^@Seirdy@pleroma.envs.net(\n| )?` "" -}} + {{- /* Mastodon webmentions may include the author in the title followed by a colon; this is redundant. */ -}} + {{- if and (isset $webmention "author_name") (findRE `@` $webmention.source) (not (findRE "^https://bridg.gy" $webmention.source)) -}} + {{ $title = $title | replaceRE `^[^:]{0,20}: ?` "" | replaceRE `^"@Seirdy@pleroma.envs.net ?` `"` }} {{- end -}} -
-
- {{ else -}} -

This post does not have any approved Webmentions yet.

- {{- end }} -

Feel free to contact me directly with feedback; here’s my contact info

-
+ {{- end -}} + {{- if and ($hasContent) (gt (countrunes $webmention.title) 128) -}} + {{- $title = $webmention.title | strings.TrimSuffix "…" | truncate 128 -}} + {{- end -}} + {{- $src := $webmention.source -}} + {{- with index $rewritesDict $src -}} + {{- $src = . -}} + {{- end -}} + {{- if in $wbmLinks $src -}} + {{- $src = printf "https://web.archive.org/web/0/%s" $src -}} + {{- else if in $archivetodayLinks $src -}} + {{- $src = printf "https://archive.today/oldest/%s" $src -}} + {{- end -}} + {{ if (eq $webmention.type "like") -}} +
+ {{- else -}} +
+ {{- end -}} + +
+ +
+
+ {{ if (eq $webmention.type "like") -}} + {{ if $webmention.author_name -}} + {{ $webmention.author_name }} + {{ else if $webmention.title -}} + {{ $webmention.title | replaceRE ` \n` ` +` -}} + {{ else -}} + {{ $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}} + {{ end -}} + this + {{ else -}} + + {{- if $webmention.author_name }} + by + {{- end -}} + {{- if $hasContent -}} + {{- if findRE `^https://brid.gy/[^/]*/mastodon` $webmention.source -}} +

This comment may have major formatting errors that could impact screen reader comprehension.

+ {{- end -}} +

{{ $webmention.content | replaceRE `^@Seirdy(@pleroma.envs.net)? ?` "" | replaceRE ` \n` ` +`}}

+ {{- end -}} + {{- end }} +
+
+ {{- end -}} + + +{{ else -}} +

This post does not have any approved Webmentions yet.

+{{- end }} +

Feel free to contact me directly with feedback; here’s my contact info

diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 72c9f4c..26006da 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -3,9 +3,11 @@ {{- .Scratch.Set "codeIndex" 1 -}}
- + +
{{ partial "full-article.html" . }} - {{ partial "webmentions.html" . }} + {{ partial "interact.html" . }} +
{{ partial "prev-next.html" . -}} {{- end }}