commit af747fbf9d6a7833144e70a3089c69f934dfd0c7
parent 6aa8a5443cec322bf8e7a09a1ff03c34f71d96af
Author: maydayv7 <maydayv7@gmail.com>
Date: Fri, 2 Jan 2026 19:01:23 +0530
feat: Modify header
Diffstat:
7 files changed, 71 insertions(+), 29 deletions(-)
diff --git a/Makefile b/Makefile
@@ -57,7 +57,7 @@ dist:
rm -rf ${NAME}-${VERSION}
mkdir -p ${NAME}-${VERSION}
cp -f ${MAN1} ${HDR} ${SRC} ${COMPATSRC} ${DOC} \
- Makefile favicon.png logo.png style.css \
+ Makefile favicon.png style.css \
example_create.sh example_post-receive.sh \
${NAME}-${VERSION}
# make tarball
@@ -85,7 +85,6 @@ install: all
mkdir -p ${DESTDIR}${DOCPREFIX}
cp -f style.css\
favicon.png\
- logo.png\
example_create.sh\
example_post-receive.sh\
README\
@@ -102,7 +101,6 @@ uninstall:
rm -f \
${DESTDIR}${DOCPREFIX}/style.css\
${DESTDIR}${DOCPREFIX}/favicon.png\
- ${DESTDIR}${DOCPREFIX}/logo.png\
${DESTDIR}${DOCPREFIX}/example_create.sh\
${DESTDIR}${DOCPREFIX}/example_post-receive.sh\
${DESTDIR}${DOCPREFIX}/README
diff --git a/flake.nix b/flake.nix
@@ -35,7 +35,7 @@
mkdir -p $out/share/doc/stagit
cp stagit $out/bin/
cp stagit-index $out/bin/
- cp style.css logo.png favicon.png $out/share/doc/stagit/
+ cp style.css favicon.png $out/share/doc/stagit/
wrapProgram $out/bin/stagit --prefix PATH : ${lib.makeBinPath [ chroma ]}
'';
};
diff --git a/logo.png b/logo.png
Binary files differ.
diff --git a/stagit-index.1 b/stagit-index.1
@@ -6,6 +6,7 @@
.Nd static git index page generator
.Sh SYNOPSIS
.Nm
+.Op Fl n Ar sitename
.Op Ar repodir...
.Sh DESCRIPTION
.Nm
@@ -25,14 +26,14 @@ The content of the follow files specifies the meta data for each repository:
description
.It .git/owner or owner (bare repo).
owner of repository
+.It Fl n Ar sitename
+Set the site name used in the header button.
.El
.Pp
For changing the style of the page you can use the following files:
.Bl -tag -width Ds
.It favicon.png
favicon image.
-.It logo.png
-32x32 logo.
.It style.css
CSS stylesheet.
.El
diff --git a/stagit-index.c b/stagit-index.c
@@ -9,6 +9,7 @@
#include <git2.h>
static git_repository *repo;
+static char *sitename = "Git";
static const char *relpath = "";
@@ -112,15 +113,17 @@ void writeheader(FILE *fp) {
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n",
relpath);
fputs("</head>\n<body>\n", fp);
- fprintf(fp,
- "<table>\n<tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" "
- "height=\"32\" /></td>\n"
- "<td><span class=\"desc\">",
- relpath);
- xmlencode(fp, description, strlen(description));
+
+ fputs("<header class=\"header\">\n", fp);
+ fputs("<div class=\"header-inner\">\n", fp);
+ fputs("<div class=\"header-logo\">\n", fp);
+ fprintf(fp, "<a href=\"./\">%s</a>\n", sitename);
+ fputs("</div>\n", fp);
+ fputs("</div>\n", fp);
+ fputs("</header>\n", fp);
+ fputs("<div id=\"content\">\n", fp);
+
fputs(
- "</span></td></tr><tr><td></td><td>\n"
- "</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n"
"<table id=\"index\"><thead>\n"
"<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Owner</b></td>"
"<td><b>Last commit</b></td></tr>"
@@ -178,17 +181,32 @@ err:
return ret;
}
+void usage(char *argv0) {
+ fprintf(stderr, "usage: %s [-n sitename] [repodir...]\n", argv0);
+ exit(1);
+}
+
int main(int argc, char *argv[]) {
FILE *fp;
char path[PATH_MAX], repodirabs[PATH_MAX + 1];
const char *repodir;
int i, ret = 0;
- if (argc < 2) {
- fprintf(stderr, "usage: %s [repodir...]\n", argv[0]);
- return 1;
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ if (argv[i][1] == 'n') {
+ if (i + 1 >= argc)
+ usage(argv[0]);
+ sitename = argv[++i];
+ } else {
+ usage(argv[0]);
+ }
+ }
}
+ if (argc < 2)
+ usage(argv[0]);
+
/* do not search outside the git repository:
GIT_CONFIG_LEVEL_APP is the highest level currently */
git_libgit2_init();
@@ -205,6 +223,12 @@ int main(int argc, char *argv[]) {
writeheader(stdout);
for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ if (argv[i][1] == 'n')
+ i++;
+ continue;
+ }
+
repodir = argv[i];
if (!realpath(repodir, repodirabs))
err(1, "realpath");
diff --git a/stagit.1 b/stagit.1
@@ -9,6 +9,7 @@
.Op Fl c Ar cachefile
.Op Fl l Ar commits
.Op Fl u Ar baseurl
+.Op Fl n Ar sitename
.Ar repodir
.Sh DESCRIPTION
.Nm
@@ -35,6 +36,8 @@ However the commit files are written as usual.
.It Fl u Ar baseurl
Base URL to make links in the Atom feeds absolute.
For example: "https://github.com/maydayv7/stagit/".
+.It Fl n Ar sitename
+Set the site name used in the header button.
.El
.Pp
The options
@@ -103,8 +106,6 @@ For changing the style of the page you can use the following files:
.Bl -tag -width Ds
.It favicon.png
favicon image.
-.It logo.png
-32x32 logo.
.It style.css
CSS stylesheet.
.El
diff --git a/stagit.c b/stagit.c
@@ -64,6 +64,7 @@ static git_repository *repo;
static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
static const char *relpath = "";
static const char *repodir;
+static char *sitename = "Git";
static char *name = "";
static char *strippedname = "";
@@ -522,24 +523,35 @@ void writeheader(FILE *fp, const char *title) {
fp,
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n",
relpath);
- fputs("</head>\n<body>\n<table><tr><td>", fp);
+ fputs("</head>\n<body>\n", fp);
+
+ fputs("<header class=\"header\">\n", fp);
+ fputs("<div class=\"header-inner\">\n", fp);
+ fputs("<div class=\"header-logo\">\n", fp);
fprintf(fp,
- "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" "
- "height=\"32\" /></a>",
- relpath, relpath);
- fputs("</td><td><h1>", fp);
+ "<a href=\"../%s\">"
+ "%s</a>\n",
+ relpath, sitename);
+ fputs("</div>\n", fp);
+ fputs("</div>\n", fp);
+ fputs("</header>\n", fp);
+
+ fputs("<div id=\"repo-header\">\n", fp);
+ fputs("<h1>", fp);
xmlencode(fp, strippedname, strlen(strippedname));
fputs("</h1><span class=\"desc\">", fp);
xmlencode(fp, description, strlen(description));
- fputs("</span></td></tr>", fp);
+ fputs("</span></div>\n", fp);
+
if (cloneurl[0]) {
fputs("<tr class=\"url\"><td></td><td>git clone <a href=\"", fp);
- xmlencode(fp, cloneurl, strlen(cloneurl)); /* not percent-encoded */
+ xmlencode(fp, cloneurl, strlen(cloneurl));
fputs("\">", fp);
xmlencode(fp, cloneurl, strlen(cloneurl));
fputs("</a></td></tr>", fp);
}
- fputs("<tr><td></td><td>\n", fp);
+
+ fputs("<div id=\"nav\">\n", fp);
fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);
@@ -550,7 +562,9 @@ void writeheader(FILE *fp, const char *title) {
fprintf(fp, " | <a href=\"%sfile/%s.html\">README</a>", relpath, readme);
if (license)
fprintf(fp, " | <a href=\"%sfile/%s.html\">LICENSE</a>", relpath, license);
- fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp);
+ fputs("\n</div>\n", fp);
+
+ fputs("<hr/>\n<div id=\"content\">\n", fp);
}
void writefooter(FILE *fp) { fputs("</div>\n</body>\n</html>\n", fp); }
@@ -1267,7 +1281,7 @@ int writerefs(FILE *fp) {
void usage(char *argv0) {
fprintf(stderr,
"usage: %s [-c cachefile | -l commits] "
- "[-u baseurl] repodir\n",
+ "[-u baseurl] [-n sitename] repodir\n",
argv0);
exit(1);
}
@@ -1302,6 +1316,10 @@ int main(int argc, char *argv[]) {
if (i + 1 >= argc)
usage(argv[0]);
baseurl = argv[++i];
+ } else if (argv[i][1] == 'n') {
+ if (i + 1 >= argc)
+ usage(argv[0]);
+ sitename = argv[++i];
}
}
if (!repodir)