commit aef95980b41703beffc5569aba92f89055252074
parent f819123d28f3eb07c78de48969897e202bdf6b7a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 14:43:54 +0200
parent f819123d28f3eb07c78de48969897e202bdf6b7a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 14:43:54 +0200
write{header,footer} refactor html output
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/stagit.c b/stagit.c @@ -545,75 +545,75 @@ static const char void writeheader(FILE *fp, const char *title, const char *mode) { - fputs("<!DOCTYPE html>\n" - "<html>\n<head>\n" - "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" - "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" + fputs("<!DOCTYPE html>\n<html><head>" + "<meta charset=\"utf-8\">" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" + "<link href=\"/style.css\" rel=\"stylesheet\">" "<title>", fp); - xmlencode(fp, title, strlen(title)); - if (title[0] && strippedname[0]) - fputs(" - ", fp); - xmlencode(fp, strippedname, strlen(strippedname)); - if (description[0]) + + xmlencodeline(fp, title, strlen(title)); + + if (title[0] && strippedname[0]) { fputs(" - ", fp); - xmlencode(fp, description, strlen(description)); - fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/svg+xml\" href=\"../%slogo.svg\" />\n", relpath); - fprintf(fp, "<link rel=\"alternate icon\" href=\"../%sfavicon.ico\" />\n", relpath); - fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"../%sstyle.css\" />\n", relpath); - fputs("</head>\n<body>\n<div id=\"head\"><table><tr><td>", fp); - fprintf(fp, "<a class=\"logo\" href=\"../%s\"><img src=\"../%slogo.svg\" alt=\"\" width=\"32\" height=\"32\" /></a>", - relpath, relpath); - fputs("</td><td><strong>", fp); - xmlencode(fp, strippedname, strlen(strippedname)); - fputs("</strong><span class=\"desc\"> - ", fp); - xmlencode(fp, description, strlen(description)); - fputs("</span>\n", fp); - fputs("</td></tr></table>\n<p>", fp); + xmlencodeline(fp, strippedname, strlen(strippedname)); + } + + fputs("</title></head><body>\n<header><h1>", fp); + + if (pagename[0]) fprintf(fp, "<a href=\"../%s\">%s</a>: ", relpath, pagename); + + xmlencodeline(fp, strippedname, strlen(strippedname)); + fputs("</h1>", fp); + + if (description[0]) { + fputs("<p>", fp); + xmlencodeline(fp, description, strlen(description)); + fputs("</p>", fp); + } + + fputs("</header>\n<nav>", fp); if (readme) { if (!strcmp(mode, "about")) { - fprintf(fp, "<a class=\"active\" href=\"%sabout.html\">About</a> | ", relpath); + fprintf(fp, "<a class=\"active\" href=\"%sabout.html\">about</a>", relpath); } else { - fprintf(fp, "<a href=\"%sabout.html\">About</a> | ", relpath); + fprintf(fp, "<a href=\"%sabout.html\">about</a>", relpath); } } if (!strcmp(mode, "log")) { - fprintf(fp, "<a class=\"active\" href=\"%slog.html\">Log</a> | ", relpath); + fprintf(fp, "<a class=\"active\" href=\"%slog.html\">log</a>", relpath); } else { - fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath); + fprintf(fp, "<a href=\"%slog.html\">log</a>", relpath); } if (!strcmp(mode, "tree")) { - fprintf(fp, "<a class=\"active\" href=\"%stree.html\">Files</a> | ", relpath); + fprintf(fp, "<a class=\"active\" href=\"%stree.html\">tree</a>", relpath); } else { - fprintf(fp, "<a href=\"%stree.html\">Files</a> | ", relpath); + fprintf(fp, "<a href=\"%stree.html\">tree</a>", relpath); } if (!strcmp(mode, "refs")) { - fprintf(fp, "<a class=\"active\" href=\"%srefs.html\">Refs</a>", relpath); + fprintf(fp, "<a class=\"active\" href=\"%srefs.html\">refs</a>", relpath); } else { - fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath); + fprintf(fp, "<a href=\"%srefs.html\">refs</a>", relpath); } - if (submodules) - fprintf(fp, " | <a href=\"%stree/%s.html\">Submodules</a>", - relpath, submodules); if (license) - fprintf(fp, " | <a href=\"%stree/%s.html\">License</a>", + fprintf(fp, "<a href=\"%stree/%s.html\">license</a>", relpath, license); if (contribute) - fprintf(fp, " | <a href=\"%stree/%s.html\">Contribute</a>", + fprintf(fp, "<a href=\"%stree/%s.html\">contribute</a>", relpath, contribute); else - fprintf(fp, " | <a href=\"../%s#contribute\">Contribute</a>", relpath); - fputs("</p>\n</div>\n<hr/>\n<div id=\"content\">\n", fp); + fprintf(fp, "<a href=\"../%s#contribute\">contribute</a>", relpath); + fputs("</nav>\n<main>\n", fp); } void writefooter(FILE *fp) { - fprintf(fp, "</div><br><p>Generated on %s (UTC)</p>\n</body>\n</html>\n", gen_time); + fprintf(fp, "\n</main><footer><p>Generated on %s (UTC)</p></footer></body></html>", gen_time); } void