1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 12:52:10 +00:00

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 <article> h-entry.
This commit is contained in:
Rohan Kumar 2022-11-20 13:26:57 -08:00
parent 5037e399d1
commit 36c049d0ef
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
8 changed files with 137 additions and 106 deletions

View file

@ -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" (<abbr>DRY</abbr>) principle is my main motivation for adding content to my site---especially to [my "notes" section]({{<relref "/notes">}}). I've gone as far as linking my own website in online class discussions (not as a citation; just for <abbr>DRY</abbr>).
This also combines really well with the [Publish on your Own Site, Syndicate Elsewhere](https://indieweb.org/POSSE) (<abbr>POSSE</abbr>) 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.

View file

@ -2,7 +2,9 @@
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<main
itemprop="mainEntity" itemscope="" itemtype="https://schema.org/Article" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<article class="h-entry hentry">
{{ partial "full-article.html" . }}
{{ partial "webmentions.html" . }}
{{ partial "interact.html" . }}
</article>
</main>
{{ end }}

View file

@ -2,9 +2,11 @@
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<main
itemprop="hasPart" itemscope="" itemtype="https://schema.org/SocialMediaPosting" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" />
<link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" />
<article class="h-entry hentry">
{{ partial "full-article.html" . }}
{{ partial "webmentions.html" . }}
{{ partial "interact.html" . }}
</article>
</main>
{{ partial "prev-next.html" . -}}
{{- end }}

View file

@ -1,4 +1,3 @@
<article class="h-entry hentry"><!--Once WAI-ARIA 1.3 gains traction, I'll add aria-details for webmentions.-->
<header>
<h1 itemprop="name headline" class="p-name entry-title" id="h1" tabindex="-1">{{ .Title }}</h1>
{{- if not .Params.disableMeta -}}
@ -14,4 +13,3 @@
{{- end -}}
{{- partial "processed-content" . -}}
</div>
</article>

View file

@ -0,0 +1,7 @@
<hr />
<footer aria-labelledby="interact">
<h2 id="interact" tabindex="-1">Interact</h2>
<p>You can interact by <a href="#webmentions">sending webmentions</a> or by visiting a syndicated copy of this post.</p>
{{- partial "syndication.html" . -}}
{{- partial "webmentions.html" . -}}
</footer>

View file

@ -0,0 +1,15 @@
{{ with .Params.syndicatedCopies }}
<h3>Syndication</h3>
<p>This post has been syndicated to:</p>
<ul>
{{- range . -}}
{{- $type := "SocialMediaPosting" -}}
{{- with ".type" -}}
{{- $type = . -}}
{{- end }}
<li>
<a itemprop="discussionUrl" class="u-syndication" rel="syndication" href="{{ .url }}">{{ .title }}</a>
</li>
{{- end -}}
</ul>
{{- end -}}

View file

@ -4,103 +4,100 @@
{{- range $i, $r := (getCSV "," "/csv/rewrites.csv") -}}
{{- $rewritesDict = merge $rewritesDict (dict (index $r 0) (index $r 1)) -}}
{{- end -}}
<hr />
<section aria-labelledby="webmentions" data-nosnippet=""><!--data-nosnippet means this content shouldn't be used for url summaries in search engines.-->
<h2 id="webmentions" tabindex="-1">Web&#173;mentions</h2>
<p>This site supports <a href="https://indieweb.org/webmention">Webmentions</a>, a backlink-based alternative to traditional comment forms.</p>
{{ 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 -}}
<p>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 dont support them. I auto-replace broken links with <a href="https://web.archive.org/">Wayback Machine</a> snapshots, if they exist.</p>
<details>
<summary>Toggle Webmentions</summary>
<dl>
{{ 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") -}}
<div itemprop="potentialAction" itemscope="" itemtype="https://schema.org/LikeAction" class="u-like h-cite">
{{- else -}}
<div itemprop="comment" itemscope="" itemtype="https://schema.org/Comment" class="u-comment h-cite">
{{- end -}}
<!--Will eventually add role="comment" once WAI-ARIA 1.3 starts seeing some adoption.-->
<dt>
<time
class="dt-published"
itemprop="{{ if (eq $webmention.type "like") -}}startTime{{ else }}datePublished{{ end }}"
datetime="{{ dateFormat "2006-01-02 15:04:05Z07:00" $webmention.created_at }}">
{{ dateFormat "2006-01-02" $webmention.created_at }}
</time>
</dt>
<dd>
{{ if (eq $webmention.type "like") -}}
{{ if $webmention.author_name -}}
<span itemprop="agent" itemscope="" itemtype="https://schema.org/Person" class="h-card p-author vcard"><span itemprop="name" class="p-name fn n">{{ $webmention.author_name }}</span></span>
{{ else if $webmention.title -}}
<span itemprop="name" class="p-name">{{ $webmention.title | replaceRE ` \n` `
` -}}</span>
{{ else -}}
{{ $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
{{ end -}}
<a class="u-url" itemprop="url" href="{{ $src }}" rel="nofollow ugc">liked</a> this
{{ else -}}
<a class="u-url" itemprop="url" href="{{ $src }}" rel="nofollow ugc">
<span itemprop="name" class="p-name">
{{ if $webmention.title -}}
{{ $title | truncate 200 | replaceRE ` \n` `
` | safeHTML -}}
{{ else -}}
{{- $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
{{ end -}}
</span
></a>
{{- if $webmention.author_name }}
by <span itemprop="author" itemscope="" itemtype="https://schema.org/Person" class="h-card p-author vcard"><span itemprop="name" class="p-name fn n">{{ $webmention.author_name }}</span></span>
{{- end -}}
{{- if $hasContent -}}
{{- if findRE `^https://brid.gy/[^/]*/mastodon` $webmention.source -}}
<p role="doc-tip" itemprop="accessibilitySummary">This comment may have major formatting errors that could impact screen reader comprehension.</p>
{{- end -}}
<p><q itemprop="text" class="p-content">{{ $webmention.content | replaceRE `^@Seirdy(@pleroma.envs.net)? ?` "" | replaceRE ` \n` `
`}}</q></p>
{{- end -}}
{{- end }}
</dd>
</div>
<h3 id="webmentions" tabindex="-1">Web&#173;mentions</h3>
<p>This site supports <a href="https://indieweb.org/webmention">Webmentions</a>, a backlink-based alternative to traditional comment forms.</p>
{{ 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 -}}
<p>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 dont support them. I auto-replace broken links with <a href="https://web.archive.org/">Wayback Machine</a> snapshots, if they exist.</p>
<details>
<summary>Toggle Webmentions</summary>
<dl>
{{ 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 -}}
</dl>
</details>
{{ else -}}
<p>This post does not have any approved Webmentions yet.</p>
{{- end }}
<p>Feel free to contact me directly with feedback; <a href="{{ .Site.BaseURL }}about/#location-seirdy-online">heres my contact info</a></p>
</section>
{{- 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") -}}
<div itemprop="potentialAction" itemscope="" itemtype="https://schema.org/LikeAction" class="u-like h-cite">
{{- else -}}
<div itemprop="comment" itemscope="" itemtype="https://schema.org/Comment" class="u-comment h-cite">
{{- end -}}
<!--Will eventually add role="comment" once WAI-ARIA 1.3 starts seeing some adoption.-->
<dt>
<time
class="dt-published"
itemprop="{{ if (eq $webmention.type "like") -}}startTime{{ else }}datePublished{{ end }}"
datetime="{{ dateFormat "2006-01-02 15:04:05Z07:00" $webmention.created_at }}">
{{ dateFormat "2006-01-02" $webmention.created_at }}
</time>
</dt>
<dd>
{{ if (eq $webmention.type "like") -}}
{{ if $webmention.author_name -}}
<span itemprop="agent" itemscope="" itemtype="https://schema.org/Person" class="h-card p-author vcard"><span itemprop="name" class="p-name fn n">{{ $webmention.author_name }}</span></span>
{{ else if $webmention.title -}}
<span itemprop="name" class="p-name">{{ $webmention.title | replaceRE ` \n` `
` -}}</span>
{{ else -}}
{{ $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
{{ end -}}
<a class="u-url" itemprop="url" href="{{ $src }}" rel="nofollow ugc">liked</a> this
{{ else -}}
<a class="u-url" itemprop="url" href="{{ $src }}" rel="nofollow ugc">
<span itemprop="name" class="p-name">
{{ if $webmention.title -}}
{{ $title | truncate 200 | replaceRE ` \n` `
` | safeHTML -}}
{{ else -}}
{{- $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
{{ end -}}
</span
></a>
{{- if $webmention.author_name }}
by <span itemprop="author" itemscope="" itemtype="https://schema.org/Person" class="h-card p-author vcard"><span itemprop="name" class="p-name fn n">{{ $webmention.author_name }}</span></span>
{{- end -}}
{{- if $hasContent -}}
{{- if findRE `^https://brid.gy/[^/]*/mastodon` $webmention.source -}}
<p role="doc-tip" itemprop="accessibilitySummary">This comment may have major formatting errors that could impact screen reader comprehension.</p>
{{- end -}}
<p><q itemprop="text" class="p-content">{{ $webmention.content | replaceRE `^@Seirdy(@pleroma.envs.net)? ?` "" | replaceRE ` \n` `
`}}</q></p>
{{- end -}}
{{- end }}
</dd>
</div>
{{- end -}}
</dl>
</details>
{{ else -}}
<p>This post does not have any approved Webmentions yet.</p>
{{- end }}
<p>Feel free to contact me directly with feedback; <a href="{{ .Site.BaseURL }}about/#location-seirdy-online">heres my contact info</a></p>

View file

@ -3,9 +3,11 @@
{{- .Scratch.Set "codeIndex" 1 -}}
<main
itemprop="mainEntity" itemscope="" itemtype="https://schema.org/BlogPosting{{ with .Params.articleType }} https://schema.org/{{ . }}{{ end }}" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" />
<link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" />
<article class="h-entry hentry">
{{ partial "full-article.html" . }}
{{ partial "webmentions.html" . }}
{{ partial "interact.html" . }}
</article>
</main>
{{ partial "prev-next.html" . -}}
{{- end }}