- Commit
- 8c483db75d912d14edb8bc475453ca88b645355c
- Parent
- d2aa621d29e5dd251f766f80d089028756429a99
- Author
- Pablo <pablo-escobar@riseup.net>
- Date
Made the navigation bar more compliant with accessibility guidelines
Nested the <nav> element inside of a <header> to make it easier for assitive technology to find the site map
Also nested the list of links for each repository insede of a <nav> element
See https://www.htmhell.dev/adventcalendar/2022/4/
diff --git a/stagit.c b/stagit.c
@@ -471,20 +471,22 @@ void writeheader(FILE *fp, const char *title)
fputs("</head>\n<body>\n", fp);
// The navigation bar
- fputs("<nav>\n"
+ fputs("<header>\n"
+ "<nav>\n"
"<a href=\"https://git.pablopie.xyz\">\n"
"<img aria-hidden=\"true\" "
"alt=\"Website logo\" "
"src=\"/icons/favicon.svg\">\n"
"git.pablopie.xyz\n"
"</a>\n"
- "</nav>\n", fp);
+ "</nav>\n",
+ "</header>\n", fp);
fputs("<main>\n<h1>", fp);
xmlencode(fp, strippedname, strlen(strippedname));
fputs("</h1>\n<p>", fp);
xmlencode(fp, description, strlen(description));
- fputs("</p>\n<ul>\n", fp);
+ fputs("</p>\n<nav>\n<ul>\n", fp);
if (cloneurl[0]) {
fputs("<li>git clone: <a href=\"", fp);
xmlencode(fp, cloneurl, strlen(cloneurl));
@@ -1024,7 +1026,7 @@ size_t writeblob(git_object *obj, const char *fpath, const char *blobpath, const
fp = efopen(fpath, "w");
writeheader(fp, filename);
fprintf(fp, "<li><a href=\"%s%s\">raw file (blob)</a></li>", relpath, blobpath);
- fputs("</ul>\n", fp);
+ fputs("</ul>\n</nav>\n", fp);
fputs("<h2>", fp);
xmlencode(fp, filename, strlen(filename));
fprintf(fp, " (%zuB)", filesize);
@@ -1272,7 +1274,7 @@ void write_markdown_readme(FILE *fp, git_blob *readme)
char *html = cmark_markdown_to_html(markdown,
strlen(markdown), CMARK_OPT_SAFE);
writeheader(fp, NULL);
- fputs("</ul>\n", fp);
+ fputs("</ul>\n</nav>\n", fp);
fprintf(fp, "<section id=\"readme\">\n");
fprintf(fp, "%s", html);
fprintf(fp, "</section>\n");
@@ -1434,7 +1436,7 @@ int main(int argc, char *argv[])
relpath = "";
mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO);
writeheader(fp, "Log");
- fputs("</ul>\n", fp);
+ fputs("</ul>\n</nav>\n", fp);
fputs("<div class=\"article-list\">\n", fp);
if (cachefile && head) {
@@ -1482,7 +1484,7 @@ int main(int argc, char *argv[])
/* files for HEAD */
fp = efopen("files.html", "w");
writeheader(fp, "Files");
- fputs("</ul>\n", fp);
+ fputs("</ul>\n</nav>\n", fp);
if (head)
writefiles(fp, head);
writefooter(fp);
@@ -1491,7 +1493,7 @@ int main(int argc, char *argv[])
/* summary page with branches and tags */
fp = efopen("refs.html", "w");
writeheader(fp, "Refs");
- fputs("</ul>\n", fp);
+ fputs("</ul>\n</nav>\n", fp);
writerefs(fp);
writefooter(fp);
fclose(fp);