mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-23 21:02:09 +00:00
Webmentions: display reply content + a11y issues
- Display reply content in webmentions, when it's available - Truncate titles and redundant content from webmentions - Add note on a11y issues regarding badly-formatted webmentions from brid.gy's mastodon integration.
This commit is contained in:
parent
8f29201ae3
commit
cd82ce39ec
3 changed files with 33 additions and 4 deletions
|
@ -132,6 +132,12 @@ html {
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
/* <dt> should not be closer to the previous <dd> than the following <dd>.
|
||||
* That can happen in webmentions. */
|
||||
dd {
|
||||
padding-bottom: .25em;
|
||||
}
|
||||
|
||||
header > nav {
|
||||
margin-bottom: -1em;
|
||||
}
|
||||
|
@ -254,8 +260,11 @@ kbd {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* <ins> should not be mistaken for hyperlinks. */
|
||||
ins {
|
||||
/* <ins> should not be mistaken for hyperlinks.
|
||||
* "note" roles should look distinct. */
|
||||
ins,
|
||||
[role="note"],
|
||||
[role="doc-tip"] {
|
||||
font-style: italic;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,19 @@
|
|||
{{ $webmentions := (getJSON $url1) | append (getJSON $url2) -}}
|
||||
{{ 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@pleroma.envs.net" $webmention.title -}}
|
||||
{{- $title = $title | replaceRE `@Seirdy@pleroma.envs.net(\n| )?` "" -}}
|
||||
{{- if and (isset $webmention "author_name") (findRE `@` $webmention.source) (not (findRE "^https://bridg.gy" $webmention.source)) -}}
|
||||
{{ $title = $title | replaceRE `^[^:]{0,20}: ?` "" }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if and ($hasContent) (gt (countrunes $webmention.title) 128) -}}
|
||||
{{- $title = $webmention.title | strings.TrimSuffix "…" | truncate 128 -}}
|
||||
{{- end -}}
|
||||
{{- $src := $webmention.source -}}
|
||||
{{- if in $wbmLinks $src -}}
|
||||
{{- $src = printf "https://web.archive.org/web/0/%s" $src -}}
|
||||
|
@ -45,9 +58,9 @@
|
|||
<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-content p-name">
|
||||
<span itemprop="name" class="p-name">
|
||||
{{ if $webmention.title -}}
|
||||
{{ $webmention.title | truncate 200 -}}
|
||||
{{ $title | truncate 200 -}}
|
||||
{{ else -}}
|
||||
{{- $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
|
||||
{{ end -}}
|
||||
|
@ -56,6 +69,12 @@
|
|||
{{- 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 itemprop="articleBody" class="p-content">{{ $webmention.content | replaceRE `^@Seirdy(@pleroma.envs.net)? ?` ""}}</p>
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
</dd>
|
||||
</div>
|
||||
|
|
|
@ -37,6 +37,7 @@ sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | sd '^\t' '' >"
|
|||
| sd '</span>.span itemprop="familyName"' '</span> <span itemprop="familyName"' \
|
||||
| sd '(</picture>|src="[^"]*" ?/>)<span itemprop="name" class="p-name fn n">' '$1 <span itemprop="name" class="p-name fn n">' \
|
||||
| sd '([a-z])<(data|time)' '$1 <$2' \
|
||||
| sd '</span>(<a[^>]*rel="(?:nofollow ugc|ugc nofollow)"(?:[^>]*)?>liked</a>)' '</span> $1' \
|
||||
| sd -s '/>' ' />'
|
||||
} >>"$xhtml_file"
|
||||
|
||||
|
|
Loading…
Reference in a new issue