[feature] add microformat support (#3848)

Related: #2959

Signed-off-by: Luca Matei Pintilie <luca@lucamatei.com>
This commit is contained in:
Luca Matei Pintilie 2025-03-01 13:06:08 +01:00 committed by GitHub
parent a7485ae251
commit e78e817057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 20 deletions

View file

@ -106,7 +106,7 @@
/> />
{{- end }} {{- end }}
<img <img
class="avatar" class="avatar u-photo"
src="{{- .account.Avatar -}}" src="{{- .account.Avatar -}}"
alt="{{- template "avatarAlt" . -}}" alt="{{- template "avatarAlt" . -}}"
title="{{- template "avatarAlt" . -}}" title="{{- template "avatarAlt" . -}}"
@ -120,7 +120,7 @@
{{- end -}} {{- end -}}
{{- with . }} {{- with . }}
<main class="profile"> <main class="profile h-card">
<h2 class="sr-only">Profile for {{ .account.Username -}}</h2> <h2 class="sr-only">Profile for {{ .account.Username -}}</h2>
<section class="profile-header" role="region" aria-label="Basic info"> <section class="profile-header" role="region" aria-label="Basic info">
{{- if .account.Moved }} {{- if .account.Moved }}
@ -148,7 +148,7 @@
{{- end }} {{- end }}
<dl class="namerole"> <dl class="namerole">
<dt class="sr-only">Display name</dt> <dt class="sr-only">Display name</dt>
<dd class="displayname text-cutoff"> <dd class="displayname text-cutoff p-name">
{{- if .account.DisplayName -}} {{- if .account.DisplayName -}}
{{- emojify .account.Emojis (escape .account.DisplayName) -}} {{- emojify .account.Emojis (escape .account.DisplayName) -}}
{{- else -}} {{- else -}}
@ -171,7 +171,7 @@
</dd> </dd>
{{- end }} {{- end }}
<dt class="sr-only">Username</dt> <dt class="sr-only">Username</dt>
<dd class="username text-cutoff">@{{- .account.Username -}}@{{- .instance.AccountDomain -}}</dd> <dd class="username text-cutoff p-nickname">@{{- .account.Username -}}@{{- .instance.AccountDomain -}}</dd>
</div> </div>
{{- if .account.Roles }} {{- if .account.Roles }}
<dt class="sr-only">Role</dt> <dt class="sr-only">Role</dt>
@ -180,6 +180,7 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
</dl> </dl>
<a class="u-url u-uid" rel="me" href="/@{{- .account.Username -}}" class="hidden"></a>
</div> </div>
</section> </section>
<div class="column-split"> <div class="column-split">
@ -191,7 +192,7 @@
{{- include "profile_fields.tmpl" . | indent 3 }} {{- include "profile_fields.tmpl" . | indent 3 }}
{{- end }} {{- end }}
<h4 class="sr-only">Bio</h4> <h4 class="sr-only">Bio</h4>
<div class="bio"> <div class="bio p-note">
{{- if .account.Note }} {{- if .account.Note }}
{{ emojify .account.Emojis (noescape .account.Note) }} {{ emojify .account.Emojis (noescape .account.Note) }}
{{- else }} {{- else }}
@ -212,15 +213,15 @@
</section> </section>
<div class="statuses-wrapper" role="region" aria-label="Posts by {{ .account.Username -}}"> <div class="statuses-wrapper" role="region" aria-label="Posts by {{ .account.Username -}}">
{{- if .pinned_statuses }} {{- if .pinned_statuses }}
<section class="pinned statuses" aria-labelledby="pinned"> <section class="pinned statuses h-feed" aria-labelledby="pinned">
<div class="col-header"> <div class="col-header">
<h3 id="pinned">Pinned posts</h3> <h3 class="p-name" id="pinned">Pinned posts</h3>
<a href="#recent">jump to recent</a> <a href="#recent">jump to recent</a>
</div> </div>
<div class="thread"> <div class="thread">
{{- range .pinned_statuses }} {{- range .pinned_statuses }}
<article <article
class="status expanded" class="status expanded h-entry"
{{- includeAttr "status_attributes.tmpl" . | indentAttr 6 }} {{- includeAttr "status_attributes.tmpl" . | indentAttr 6 }}
> >
{{- include "status.tmpl" . | indent 6 }} {{- include "status.tmpl" . | indent 6 }}
@ -229,9 +230,9 @@
</div> </div>
</section> </section>
{{- end }} {{- end }}
<section class="recent statuses" aria-labelledby="recent"> <section class="recent statuses h-feed" aria-labelledby="recent">
<div class="col-header"> <div class="col-header">
<h3 id="recent" tabindex="-1">Recent posts</h3> <h3 id="recent p-name" tabindex="-1">Recent posts</h3>
{{- if .rssFeed }} {{- if .rssFeed }}
<a href="{{- .rssFeed -}}" class="rss-icon" aria-label="RSS feed"> <a href="{{- .rssFeed -}}" class="rss-icon" aria-label="RSS feed">
<i class="fa fa-rss-square" aria-hidden="true"></i> <i class="fa fa-rss-square" aria-hidden="true"></i>
@ -244,7 +245,7 @@
{{- else }} {{- else }}
{{- range .statuses }} {{- range .statuses }}
<article <article
class="status expanded" class="status expanded h-entry"
{{- includeAttr "status_attributes.tmpl" . | indentAttr 6 }} {{- includeAttr "status_attributes.tmpl" . | indentAttr 6 }}
> >
{{- include "status.tmpl" . | indent 6 }} {{- include "status.tmpl" . | indent 6 }}

View file

@ -19,7 +19,7 @@
{{- define "statusContent" -}} {{- define "statusContent" -}}
{{- with .Content }} {{- with .Content }}
<div class="content" lang="{{- $.LanguageTag.TagStr -}}"> <div class="content e-content" lang="{{- $.LanguageTag.TagStr -}}">
{{ noescape . | emojify $.Emojis }} {{ noescape . | emojify $.Emojis }}
</div> </div>
{{- end }} {{- end }}
@ -38,7 +38,7 @@
{{- if .SpoilerText }} {{- if .SpoilerText }}
<details class="text-spoiler"> <details class="text-spoiler">
<summary> <summary>
<span class="spoiler-text" lang="{{- .LanguageTag.TagStr -}}">{{- emojify .Emojis (escape .SpoilerText) -}}</span> <span class="spoiler-text p-summary" lang="{{- .LanguageTag.TagStr -}}">{{- emojify .Emojis (escape .SpoilerText) -}}</span>
<span class="button" role="button" tabindex="0">Toggle visibility</span> <span class="button" role="button" tabindex="0">Toggle visibility</span>
</summary> </summary>
<div class="text"> <div class="text">
@ -70,7 +70,7 @@
{{- if .Local }} {{- if .Local }}
<a <a
href="{{- .URL -}}" href="{{- .URL -}}"
class="status-link" class="status-link u-url"
data-nosnippet data-nosnippet
title="Open thread at this post" title="Open thread at this post"
> >
@ -79,7 +79,7 @@
{{- else }} {{- else }}
<a <a
href="{{- .URL -}}" href="{{- .URL -}}"
class="status-link" class="status-link u-url"
data-nosnippet data-nosnippet
rel="nofollow noreferrer noopener" target="_blank" rel="nofollow noreferrer noopener" target="_blank"
title="Open remote post (opens in a new window)" title="Open remote post (opens in a new window)"

View file

@ -52,4 +52,5 @@
id="{{- .ID -}}{{- if .Pinned -}}-pinned{{- end -}}" id="{{- .ID -}}{{- if .Pinned -}}-pinned{{- end -}}"
role="region" role="region"
aria-label="{{- template "ariaLabel" . -}}" aria-label="{{- template "ariaLabel" . -}}"
class="status expanded h-entry"
{{- end }} {{- end }}

View file

@ -18,18 +18,20 @@
*/ -}} */ -}}
{{- with .Account }} {{- with .Account }}
<address> <address class="p-author h-card">
{{- if $.Local }} {{- if $.Local }}
<a <a
href="{{- .URL -}}" href="{{- .URL -}}"
rel="author" rel="author"
title="Open profile" title="Open profile"
class="u-url u-uid"
> >
{{- else }} {{- else }}
<a <a
href="{{- .URL -}}" href="{{- .URL -}}"
rel="author nofollow noreferrer noopener" target="_blank" rel="author nofollow noreferrer noopener" target="_blank"
title="Open remote profile (opens in a new window)" title="Open remote profile (opens in a new window)"
class="u-url u-uid"
> >
{{- end }} {{- end }}
<picture <picture
@ -47,10 +49,11 @@
src="{{- .Avatar -}}" src="{{- .Avatar -}}"
alt="Avatar for {{ .Username -}}" alt="Avatar for {{ .Username -}}"
title="Avatar for {{ .Username -}}" title="Avatar for {{ .Username -}}"
class="u-photo"
> >
</picture> </picture>
<div class="author-strap"> <div class="author-strap">
<span class="displayname text-cutoff"> <span class="displayname text-cutoff p-name">
{{- if .DisplayName -}} {{- if .DisplayName -}}
{{- emojify .Emojis (escape .DisplayName) -}} {{- emojify .Emojis (escape .DisplayName) -}}
{{- else -}} {{- else -}}
@ -58,7 +61,7 @@
{{- end -}} {{- end -}}
</span> </span>
<span class="sr-only">,</span> <span class="sr-only">,</span>
<span class="username text-cutoff">@{{- .Acct -}}</span> <span class="username text-cutoff p-nickname">@{{- .Acct -}}</span>
</div> </div>
<span class="sr-only">(open profile)</span> <span class="sr-only">(open profile)</span>
</a> </a>

View file

@ -23,14 +23,14 @@
<div class="stats-item published-at text-cutoff"> <div class="stats-item published-at text-cutoff">
<dt class="sr-only">Published</dt> <dt class="sr-only">Published</dt>
<dd> <dd>
<time datetime="{{- .CreatedAt -}}">{{- .CreatedAt -}}</time> <time class="dt-published" datetime="{{- .CreatedAt -}}">{{- .CreatedAt -}}</time>
</dd> </dd>
</div> </div>
{{- if .EditedAt -}} {{- if .EditedAt -}}
<div class="stats-item edited-at text-cutoff"> <div class="stats-item edited-at text-cutoff">
<dt class="sr-only">Edited</dt> <dt class="sr-only">Edited</dt>
<dd> <dd>
(edited <time datetime="{{- .EditedAt -}}">{{- .EditedAt -}}</time>) (edited <time class="dt-updated" datetime="{{- .EditedAt -}}">{{- .EditedAt -}}</time>)
</dd> </dd>
</div> </div>
{{ end }} {{ end }}