commit aedc9b95747807bea36fca5effe8a01b9ff37cec
parent 1becf8119516c60c4f6a2dd73133889d5b54e87f
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 23 May 2022 23:38:32 +0200
parent 1becf8119516c60c4f6a2dd73133889d5b54e87f
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 23 May 2022 23:38:32 +0200
writeheader: use the 'mode' argument to add 'active' class to current active page in the menu
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/stagit.c b/stagit.c @@ -574,11 +574,33 @@ writeheader(FILE *fp, const char *title, const char *mode) fputs("</a></p>\n", fp); } fputs("</td></tr></table>\n<p>", fp); - if (readme) - fprintf(fp, "<a href=\"%sabout.html\">About</a> | ", relpath); - fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath); - fprintf(fp, "<a href=\"%stree.html\">Files</a> | ", relpath); - fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath); + + if (readme) { + if (!strcmp(mode, "about")) { + fprintf(fp, "<a class=\"active\" href=\"%sabout.html\">About</a> | ", relpath); + } else { + fprintf(fp, "<a href=\"%sabout.html\">About</a> | ", relpath); + } + } + + if (!strcmp(mode, "log")) { + fprintf(fp, "<a class=\"active\" href=\"%slog.html\">Log</a> | ", relpath); + } else { + fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath); + } + + if (!strcmp(mode, "tree")) { + fprintf(fp, "<a class=\"active\" href=\"%stree.html\">Files</a> | ", relpath); + } else { + fprintf(fp, "<a href=\"%stree.html\">Files</a> | ", relpath); + } + + if (!strcmp(mode, "refs")) { + fprintf(fp, "<a class=\"active\" href=\"%srefs.html\">Refs</a>", relpath); + } else { + fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath); + } + if (submodules) fprintf(fp, " | <a href=\"%stree/%s.html\">Submodules</a>", relpath, submodules);