Compare commits
3 Commits
fix/604
...
fix/554-a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 0833f43d97 | |||
| 98dec486fb | |||
| 286d6251d8 |
21
deploy/gitea-a11y/README.md
Normal file
21
deploy/gitea-a11y/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Gitea Accessibility Fix - R4: Time Elements
|
||||
|
||||
WCAG 1.3.1: Relative timestamps lack machine-readable fallbacks.
|
||||
|
||||
## Fix
|
||||
|
||||
Wrap relative timestamps in `<time datetime="...">` elements.
|
||||
|
||||
## Files
|
||||
|
||||
- `custom/templates/custom/time_relative.tmpl` - Reusable `<time>` helper
|
||||
- `custom/templates/repo/list_a11y.tmpl` - Explore/Repos list override
|
||||
|
||||
## Deploy
|
||||
|
||||
```bash
|
||||
cp -r custom/templates/* /path/to/gitea/custom/templates/
|
||||
systemctl restart gitea
|
||||
```
|
||||
|
||||
Closes #554
|
||||
27
deploy/gitea-a11y/custom/templates/custom/time_relative.tmpl
Normal file
27
deploy/gitea-a11y/custom/templates/custom/time_relative.tmpl
Normal file
@@ -0,0 +1,27 @@
|
||||
{{/*
|
||||
Gitea a11y fix: R4 <time> elements for relative timestamps
|
||||
Deploy to: custom/templates/custom/time_relative.tmpl
|
||||
*/}}
|
||||
|
||||
{{define "custom/time_relative"}}
|
||||
{{if and .Time .Relative}}
|
||||
<time datetime="{{.Time.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.Time.Format "Jan 02, 2006 15:04"}}">
|
||||
{{.Relative}}
|
||||
</time>
|
||||
{{else if .Relative}}
|
||||
<span>{{.Relative}}</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{define "custom/time_from_unix"}}
|
||||
{{if .Relative}}
|
||||
<time datetime="" data-unix="{{.Unix}}" title="">{{.Relative}}</time>
|
||||
<script>
|
||||
(function() {
|
||||
var el = document.currentScript.previousElementSibling;
|
||||
var unix = parseInt(el.getAttribute('data-unix'));
|
||||
if (unix) { el.setAttribute('datetime', new Date(unix * 1000).toISOString()); el.setAttribute('title', new Date(unix * 1000).toLocaleString()); }
|
||||
})();
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
27
deploy/gitea-a11y/custom/templates/repo/list_a11y.tmpl
Normal file
27
deploy/gitea-a11y/custom/templates/repo/list_a11y.tmpl
Normal file
@@ -0,0 +1,27 @@
|
||||
{{/*
|
||||
Gitea a11y fix: R4 <time> elements for relative timestamps on repo list
|
||||
Deploy to: custom/templates/repo/list_a11y.tmpl
|
||||
*/}}
|
||||
|
||||
{{/* Star count link with aria-label */}}
|
||||
<a class="repo-card-star" href="{{.RepoLink}}/stars" aria-label="{{.NumStars}} stars" title="{{.NumStars}} stars">
|
||||
<svg class="octicon octicon-star" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
||||
<path d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"/>
|
||||
</svg>
|
||||
<span>{{.NumStars}}</span>
|
||||
</a>
|
||||
|
||||
{{/* Fork count link with aria-label */}}
|
||||
<a class="repo-card-fork" href="{{.RepoLink}}/forks" aria-label="{{.NumForks}} forks" title="{{.NumForks}} forks">
|
||||
<svg class="octicon octicon-repo-forked" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
||||
<path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75v-.878a2.25 2.25 0 111.5 0v.878a2.25 2.25 0 01-2.25 2.25h-1.5v2.128a2.251 2.251 0 11-1.5 0V8.5h-1.5A2.25 2.25 0 013.5 6.25v-.878a2.25 2.25 0 111.5 0zM5 3.25a.75.75 0 10-1.5 0 .75.75 0 001.5 0zm6.75.75a.75.75 0 100-1.5.75.75 0 000 1.5zm-3 8.75a.75.75 0 10-1.5 0 .75.75 0 001.5 0z"/>
|
||||
</svg>
|
||||
<span>{{.NumForks}}</span>
|
||||
</a>
|
||||
|
||||
{{/* Relative timestamp with <time> element for a11y */}}
|
||||
{{if .UpdatedUnix}}
|
||||
<time datetime="{{.UpdatedUnix | TimeSinceISO}}" title="{{.UpdatedUnix | DateFmtLong}}" class="text-light">
|
||||
{{.UpdatedUnix | TimeSince}}
|
||||
</time>
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user