1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-14 09:42:09 +00:00

POSH: replace some divs with <section>s, add <p>

- Put webmention list items in <p>
- make doc-endnotes a section again
- make doc-preface a section with a heading apart from the TOC.
This commit is contained in:
Rohan Kumar 2022-05-03 21:30:20 -07:00
parent 1863c65dce
commit 781f910f99
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
4 changed files with 54 additions and 39 deletions

View file

@ -17,7 +17,8 @@ sitemap:
featured: true featured: true
title: Best practices for inclusive textual websites title: Best practices for inclusive textual websites
--- ---
<div role="doc-preface"> <section role="doc-preface">
<h2 id="before-you-begin">Before you begin</h2>
The following applies to minimal websites that focus primarily on text. It does not apply to websites that have a lot of non-textual content. It also does not apply to websites that focus more on generating revenue or pleasing investors than being inclusive. The following applies to minimal websites that focus primarily on text. It does not apply to websites that have a lot of non-textual content. It also does not apply to websites that focus more on generating revenue or pleasing investors than being inclusive.
@ -25,7 +26,7 @@ This is a "living document" that I add to as I receive feedback. See the updated
<p role="doc-tip">If you find the article too long, just read the introduction and conclusion. The table of contents should help you skim.</p> <p role="doc-tip">If you find the article too long, just read the introduction and conclusion. The table of contents should help you skim.</p>
</div> </section>
{{<toc>}} {{<toc>}}

View file

@ -1,10 +1,10 @@
<article class="h-entry hentry"> <article class="h-entry hentry">
<header> <header>
<h1 itemprop="name headline" class="p-name entry-title">{{ .Title }}</h1> <h1 itemprop="name headline" class="p-name entry-title">{{ .Title }}</h1>
{{ partial "post-meta.html" . }} {{ partial "post-meta.html" . }}
<hr> <hr>
</header> </header>
<div class="e-content entry-content" itemprop="articleBody"> <div class="e-content entry-content" itemprop="articleBody">
{{ partial "processed-content" . -}} {{ partial "processed-content" . -}}
</div> </div>
</article> </article>

View file

@ -10,9 +10,19 @@
--> -->
{{- $referencesWithoutHeading := `(<div class="footnotes" role="doc-endnotes"> {{- $referencesWithoutHeading := `(<div class="footnotes" role="doc-endnotes">
<hr>)` -}} <hr>)` -}}
{{- $referencesWithHeading := printf `<div role="doc-endnotes" aria-labelledby="note-hd"> {{- $referencesWithHeading := printf `<section role="doc-endnotes" aria-labelledby="note-hd">
<h2 id="note-hd">%s</h2>` ($footnote_heading) -}} <h2 id="note-hd">%s</h2>` ($footnote_heading) -}}
{{- $endnotesClosingDiv := `</a></p>
</li>
</ol>
</div>` -}}
{{- $endnotesClosingSection := printf `</a></p>
</li>
</ol>
</section>` -}}
<!--Remove deprecated DPUB-ARIA role and unused classes--> <!--Remove deprecated DPUB-ARIA role and unused classes-->
{{- $endnote := `(role="doc-endnote"|class="footnote-(back)?ref")` -}} {{- $endnote := `(role="doc-endnote"|class="footnote-(back)?ref")` -}}
{{- $noEndnote := printf "" -}} {{- $noEndnote := printf "" -}}
@ -28,4 +38,4 @@
{{- $repeatedFootnoteBacklinksBad := `<a href="#fnref([0-9]):([0-9]*)"(.*role="doc-backlink"(?:.*)?)>` -}} {{- $repeatedFootnoteBacklinksBad := `<a href="#fnref([0-9]):([0-9]*)"(.*role="doc-backlink"(?:.*)?)>` -}}
{{- $repeatedFootnoteBacklinksGood := `<a href="#fnref${1}:${2}" title="back to reference ${2}, repeated instance ${1}" aria-label="back to reference ${2}, repeated instance ${1}"${3}>` -}} {{- $repeatedFootnoteBacklinksGood := `<a href="#fnref${1}:${2}" title="back to reference ${2}, repeated instance ${1}" aria-label="back to reference ${2}, repeated instance ${1}"${3}>` -}}
{{- .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $endnote $noEndnote | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | replaceRE $repeatedFootnoteBacklinksBad $repeatedFootnoteBacklinksGood | safeHTML -}} {{- .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $endnotesClosingDiv $endnotesClosingSection | replaceRE $endnote $noEndnote | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | replaceRE $repeatedFootnoteBacklinksBad $repeatedFootnoteBacklinksGood | safeHTML -}}

View file

@ -12,29 +12,33 @@
{{- else -}} {{- else -}}
<li itemprop="comment" itemscope itemtype="https://schema.org/Comment" class="u-comment h-cite"> <li itemprop="comment" itemscope itemtype="https://schema.org/Comment" class="u-comment h-cite">
{{- end }} {{- end }}
<p>
<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 }}" title="{{ dateFormat "2006-01-02 15:04:05Z07:00" $webmention.created_at }}">{{ dateFormat "2006-01-02" $webmention.created_at }}</time> <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 }}" title="{{ dateFormat "2006-01-02 15:04:05Z07:00" $webmention.created_at }}">{{ dateFormat "2006-01-02" $webmention.created_at }}</time>
<br> <br>
{{ if (eq $webmention.type "like") -}} {{ if (eq $webmention.type "like") -}}
{{- if $webmention.author_name -}} {{ 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> <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 -}} {{ else if $webmention.title -}}
<span itemprop="name" class="p-name">{{ $webmention.title -}}</span> <span itemprop="name" class="p-name">{{ $webmention.title -}}</span>
{{- else -}} {{ else -}}
{{ $webmention.source -}} {{ $webmention.source -}}
{{- end }} {{ end -}}
<a class="u-url" href="{{ $webmention.source }}" rel="nofollow ugc">liked</a> this <a class="u-url" href="{{ $webmention.source }}" rel="nofollow ugc">liked</a> this
{{- else -}} {{ else -}}
<a class="u-url" href="{{ $webmention.source }}" rel="nofollow ugc"><span itemprop="name" class="p-content p-name"> <a class="u-url" href="{{ $webmention.source }}" rel="nofollow ugc">
{{- if $webmention.title -}} <span itemprop="name" class="p-content p-name">
{{- $webmention.title | truncate 200 -}} {{ if $webmention.title -}}
{{- else -}} {{ $webmention.title | truncate 200 -}}
{{ else -}}
{{- $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}} {{- $webmention.source | strings.TrimPrefix "https://" | strings.TrimPrefix "www." | strings.TrimRight "/" | truncate 35 -}}
{{- end -}} {{ end }}
</span></a> </span>
</a>
{{- if $webmention.author_name }} {{- 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> 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 -}} {{- end -}}
{{- end }} {{- end }}
</p>
</li> </li>
{{ else -}} {{ else -}}
<li><p>This post doesn't have any approved Webmentions yet.</p></li> <li><p>This post doesn't have any approved Webmentions yet.</p></li>