mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-07-19 09:39:39 +02:00
feat(ui): add repository description to og:image:alt (#8325)
Followup to https://codeberg.org/forgejo/forgejo/pulls/6053 Adds the repository description to the "alt" tag of the OpenGraph summary card, improving accessibility when these images are displayed. Fixes #8192. Other summary cards, for issues and releases, are not modified as they already contain the issue title or release title, which seems reasonable. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8325 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
This commit is contained in:
parent
14309837d4
commit
b6c6981c30
3 changed files with 8 additions and 3 deletions
|
@ -102,5 +102,6 @@
|
||||||
"admin.dashboard.cleanup_offline_runners": "Cleanup offline runners",
|
"admin.dashboard.cleanup_offline_runners": "Cleanup offline runners",
|
||||||
"settings.visibility.description": "Profile visibility affects others' ability to access your non-private repositories. <a href=\"%s\" target=\"_blank\">Learn more</a>",
|
"settings.visibility.description": "Profile visibility affects others' ability to access your non-private repositories. <a href=\"%s\" target=\"_blank\">Learn more</a>",
|
||||||
"avatar.constraints_hint": "Custom avatar may not exceed %[1]s in size or be larger than %[2]dx%[3]d pixels",
|
"avatar.constraints_hint": "Custom avatar may not exceed %[1]s in size or be larger than %[2]dx%[3]d pixels",
|
||||||
|
"og.repo.summary_card.alt_description": "Summary card of repository %[1]s, described as: %[2]s",
|
||||||
"meta.last_line": "Thank you for translating Forgejo! This line isn't seen by the users but it serves other purposes in the translation management. You can place a fun fact in the translation instead of translating it."
|
"meta.last_line": "Thank you for translating Forgejo! This line isn't seen by the users but it serves other purposes in the translation management. You can place a fun fact in the translation instead of translating it."
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,7 +644,11 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
|
||||||
ctx.Data["OpenGraphImageURL"] = repo.SummaryCardURL()
|
ctx.Data["OpenGraphImageURL"] = repo.SummaryCardURL()
|
||||||
ctx.Data["OpenGraphImageWidth"] = cardWidth
|
ctx.Data["OpenGraphImageWidth"] = cardWidth
|
||||||
ctx.Data["OpenGraphImageHeight"] = cardHeight
|
ctx.Data["OpenGraphImageHeight"] = cardHeight
|
||||||
|
if util.IsEmptyString(repo.Description) {
|
||||||
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.summary_card_alt", repo.FullName())
|
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.summary_card_alt", repo.FullName())
|
||||||
|
} else {
|
||||||
|
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("og.repo.summary_card.alt_description", repo.FullName(), repo.Description)
|
||||||
|
}
|
||||||
|
|
||||||
if repo.IsFork {
|
if repo.IsFork {
|
||||||
RetrieveBaseRepo(ctx, repo)
|
RetrieveBaseRepo(ctx, repo)
|
||||||
|
|
|
@ -98,7 +98,7 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:url": setting.AppURL + "/user27/repo49/src/branch/master/test/test.txt",
|
"og:url": setting.AppURL + "/user27/repo49/src/branch/master/test/test.txt",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
||||||
"og:image:alt": "Summary card of repository user27/repo49",
|
"og:image:alt": "Summary card of repository user27/repo49, described as: A wonderful repository with more than just a README.md",
|
||||||
"og:image:width": "1200",
|
"og:image:width": "1200",
|
||||||
"og:image:height": "600",
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
|
@ -141,7 +141,7 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:description": "A wonderful repository with more than just a README.md",
|
"og:description": "A wonderful repository with more than just a README.md",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
||||||
"og:image:alt": "Summary card of repository user27/repo49",
|
"og:image:alt": "Summary card of repository user27/repo49, described as: A wonderful repository with more than just a README.md",
|
||||||
"og:image:width": "1200",
|
"og:image:width": "1200",
|
||||||
"og:image:height": "600",
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue