stagit

My personal fork of stagit https://codemadness.org/stagit.html
git clone https://git.grace.moe/stagit
Log | Files | Refs | README | LICENSE

commit 24aaa757627f678f20fa1dd6ca676d5598f1d841
parent 293e00857a1605229efa888988392d1c16f67e63
Author: gracefu <81774659+gracefuu@users.noreply.github.com>
Date:   Sat, 19 Apr 2025 22:05:24 +0800

Patched with inline css and svg logo

Diffstat:
A.gitignore | 3+++
Mstagit-index.c | 172+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mstagit.c | 173+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 341 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,3 @@ +*.o +stagit +stagit-index diff --git a/stagit-index.c b/stagit-index.c @@ -101,10 +101,176 @@ writeheader(FILE *fp) "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" "<title>", fp); xmlencode(fp, description, strlen(description)); - fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath); - fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath); + fprintf(fp, + "</title>\n" + "<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/icons/apple-touch-icon.png\">\n" + "<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/icons/favicon-32x32.png\">\n" + "<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/icons/favicon-16x16.png\">\n" + "<link rel=\"manifest\" href=\"/icons/site.webmanifest\">\n" + "<link rel=\"mask-icon\" href=\"/icons/safari-pinned-tab.svg\" color=\"#ffb6c1\">\n" + "<link rel=\"shortcut icon\" href=\"/icons/favicon.ico\">\n" + "<meta name=\"msapplication-TileColor\" content=\"#603cba\">\n" + "<meta name=\"msapplication-config\" content=\"/icons/browserconfig.xml\">\n" + "<meta name=\"theme-color\" content=\"#ffffff\">\n"); + fprintf(fp, + "<style>\n" + "body {\n" + " color: #000;\n" + " background-color: #fff;\n" + " font-family: monospace;\n" + "}\n" + "\n" + "h1, h2, h3, h4, h5, h6 {\n" + " font-size: 1em;\n" + " margin: 0;\n" + "}\n" + "\n" + "img, svg, h1, h2 {\n" + " vertical-align: middle;\n" + "}\n" + "\n" + "img {\n" + " border: 0;\n" + "}\n" + "\n" + "a:target {\n" + " background-color: #ccc;\n" + "}\n" + "\n" + "a.d,\n" + "a.h,\n" + "a.i,\n" + "a.line {\n" + " text-decoration: none;\n" + "}\n" + "\n" + "#blob a {\n" + " color: #555;\n" + "}\n" + " \n" + "#blob a:hover {\n" + " color: blue;\n" + " text-decoration: none;\n" + "}\n" + " \n" + "table thead td {\n" + " font-weight: bold;\n" + "}\n" + "\n" + "table td {\n" + " padding: 0 0.4em;\n" + "}\n" + "\n" + "#content table td {\n" + " vertical-align: top;\n" + " white-space: nowrap;\n" + "}\n" + " \n" + "#branches tr:hover td,\n" + "#tags tr:hover td,\n" + "#index tr:hover td,\n" + "#log tr:hover td,\n" + "#files tr:hover td {\n" + " background-color: #eee;\n" + "}\n" + " \n" + "#index tr td:nth-child(2),\n" + "#tags tr td:nth-child(3),\n" + "#branches tr td:nth-child(3),\n" + "#log tr td:nth-child(2) {\n" + " white-space: normal;\n" + "}\n" + " \n" + "td.num {\n" + " text-align: right;\n" + "}\n" + " \n" + ".desc {\n" + " color: #555;\n" + "}\n" + "\n" + "hr {\n" + " border: 0;\n" + " border-top: 1px solid #555;\n" + " height: 1px;\n" + "}\n" + "\n" + "pre {\n" + " font-family: monospace;\n" + "}\n" + "\n" + "pre a.h {\n" + " color: #00a;\n" + "}\n" + "\n" + ".A,\n" + "span.i,\n" + "pre a.i {\n" + " color: #070;\n" + "}\n" + "\n" + ".D,\n" + "span.d,\n" + "pre a.d {\n" + " color: #e00;\n" + "}\n" + "\n" + "pre a.h:hover,\n" + "pre a.i:hover,\n" + "pre a.d:hover {\n" + " text-decoration: none;\n" + "}\n" + "\n" + "@media (prefers-color-scheme: dark) {\n" + " body {\n" + " background-color: #000;\n" + " color: #bdbdbd;\n" + " }\n" + " hr {\n" + " border-color: #222;\n" + " }\n" + " a {\n" + " color: #56c8ff;\n" + " }\n" + " a:target {\n" + " background-color: #222;\n" + " }\n" + " .desc {\n" + " color: #aaa;\n" + " }\n" + " #blob a {\n" + " color: #555;\n" + " }\n" + " #blob a:target {\n" + " color: #eee;\n" + " }\n" + " #blob a:hover {\n" + " color: #56c8ff;\n" + " }\n" + " pre a.h {\n" + " color: #00cdcd;\n" + " }\n" + " .A,\n" + " span.i,\n" + " pre a.i {\n" + " color: #00cd00;\n" + " }\n" + " .D,\n" + " span.d,\n" + " pre a.d {\n" + " color: #cd0000;\n" + " }\n" + " #branches tr:hover td,\n" + " #tags tr:hover td,\n" + " #index tr:hover td,\n" + " #log tr:hover td,\n" + " #files tr:hover td {\n" + " background-color: #111;\n" + " }\n" + "}\n" + "</style>\n"); fputs("</head>\n<body>\n", fp); - fprintf(fp, "<table>\n<tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></td>\n" + fprintf(fp, "<table>\n<tr><td><svg height=\"32px\" width=\"32px\" xmlns=\"http://www.w3.org/2000/svg\"><circle r=\"16\" cx=\"16\" cy=\"16\" fill=\"lightpink\"></circle></svg></td>\n" "<td><span class=\"desc\">", relpath); xmlencode(fp, description, strlen(description)); fputs("</span></td></tr><tr><td></td><td>\n" diff --git a/stagit.c b/stagit.c @@ -511,17 +511,182 @@ writeheader(FILE *fp, const char *title) if (description[0]) fputs(" - ", fp); xmlencode(fp, description, strlen(description)); - fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath); + fprintf(fp, + "</title>\n" + "<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/icons/apple-touch-icon.png\">\n" + "<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/icons/favicon-32x32.png\">\n" + "<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/icons/favicon-16x16.png\">\n" + "<link rel=\"manifest\" href=\"/icons/site.webmanifest\">\n" + "<link rel=\"mask-icon\" href=\"/icons/safari-pinned-tab.svg\" color=\"#ffb6c1\">\n" + "<link rel=\"shortcut icon\" href=\"/icons/favicon.ico\">\n" + "<meta name=\"msapplication-TileColor\" content=\"#603cba\">\n" + "<meta name=\"msapplication-config\" content=\"/icons/browserconfig.xml\">\n" + "<meta name=\"theme-color\" content=\"#ffffff\">\n"); fputs("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"", fp); xmlencode(fp, name, strlen(name)); fprintf(fp, " Atom Feed\" href=\"%satom.xml\" />\n", relpath); fputs("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"", fp); xmlencode(fp, name, strlen(name)); fprintf(fp, " Atom Feed (tags)\" href=\"%stags.xml\" />\n", relpath); - fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath); + fprintf(fp, + "<style>\n" + "body {\n" + " color: #000;\n" + " background-color: #fff;\n" + " font-family: monospace;\n" + "}\n" + "\n" + "h1, h2, h3, h4, h5, h6 {\n" + " font-size: 1em;\n" + " margin: 0;\n" + "}\n" + "\n" + "img, svg, h1, h2 {\n" + " vertical-align: middle;\n" + "}\n" + "\n" + "img {\n" + " border: 0;\n" + "}\n" + "\n" + "a:target {\n" + " background-color: #ccc;\n" + "}\n" + "\n" + "a.d,\n" + "a.h,\n" + "a.i,\n" + "a.line {\n" + " text-decoration: none;\n" + "}\n" + "\n" + "#blob a {\n" + " color: #555;\n" + "}\n" + " \n" + "#blob a:hover {\n" + " color: blue;\n" + " text-decoration: none;\n" + "}\n" + " \n" + "table thead td {\n" + " font-weight: bold;\n" + "}\n" + "\n" + "table td {\n" + " padding: 0 0.4em;\n" + "}\n" + "\n" + "#content table td {\n" + " vertical-align: top;\n" + " white-space: nowrap;\n" + "}\n" + " \n" + "#branches tr:hover td,\n" + "#tags tr:hover td,\n" + "#index tr:hover td,\n" + "#log tr:hover td,\n" + "#files tr:hover td {\n" + " background-color: #eee;\n" + "}\n" + " \n" + "#index tr td:nth-child(2),\n" + "#tags tr td:nth-child(3),\n" + "#branches tr td:nth-child(3),\n" + "#log tr td:nth-child(2) {\n" + " white-space: normal;\n" + "}\n" + " \n" + "td.num {\n" + " text-align: right;\n" + "}\n" + " \n" + ".desc {\n" + " color: #555;\n" + "}\n" + "\n" + "hr {\n" + " border: 0;\n" + " border-top: 1px solid #555;\n" + " height: 1px;\n" + "}\n" + "\n" + "pre {\n" + " font-family: monospace;\n" + "}\n" + "\n" + "pre a.h {\n" + " color: #00a;\n" + "}\n" + "\n" + ".A,\n" + "span.i,\n" + "pre a.i {\n" + " color: #070;\n" + "}\n" + "\n" + ".D,\n" + "span.d,\n" + "pre a.d {\n" + " color: #e00;\n" + "}\n" + "\n" + "pre a.h:hover,\n" + "pre a.i:hover,\n" + "pre a.d:hover {\n" + " text-decoration: none;\n" + "}\n" + "\n" + "@media (prefers-color-scheme: dark) {\n" + " body {\n" + " background-color: #000;\n" + " color: #bdbdbd;\n" + " }\n" + " hr {\n" + " border-color: #222;\n" + " }\n" + " a {\n" + " color: #56c8ff;\n" + " }\n" + " a:target {\n" + " background-color: #222;\n" + " }\n" + " .desc {\n" + " color: #aaa;\n" + " }\n" + " #blob a {\n" + " color: #555;\n" + " }\n" + " #blob a:target {\n" + " color: #eee;\n" + " }\n" + " #blob a:hover {\n" + " color: #56c8ff;\n" + " }\n" + " pre a.h {\n" + " color: #00cdcd;\n" + " }\n" + " .A,\n" + " span.i,\n" + " pre a.i {\n" + " color: #00cd00;\n" + " }\n" + " .D,\n" + " span.d,\n" + " pre a.d {\n" + " color: #cd0000;\n" + " }\n" + " #branches tr:hover td,\n" + " #tags tr:hover td,\n" + " #index tr:hover td,\n" + " #log tr:hover td,\n" + " #files tr:hover td {\n" + " background-color: #111;\n" + " }\n" + "}\n" + "</style>\n"); fputs("</head>\n<body>\n<table><tr><td>", fp); - fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>", - relpath, relpath); + fprintf(fp, "<a href=\"../%s\"><svg height=\"32px\" width=\"32px\" xmlns=\"http://www.w3.org/2000/svg\"><circle r=\"16\" cx=\"16\" cy=\"16\" fill=\"lightpink\"></circle></svg></a>", relpath); fputs("</td><td><h1>", fp); xmlencode(fp, strippedname, strlen(strippedname)); fputs("</h1><span class=\"desc\">", fp);