stagit

personal fork of stagit (rnpnr branch)
git clone anongit@rnpnr.xyz:stagit.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 60a5ed12b8fa55c414da6ceb2e75b5d7500ec4a6
Parent: 24947722ffb535e7128de8dca261cff30ee0a1a1
Author: Randy Palamar
Date:   Sat,  4 Nov 2023 13:15:09 -0600

print a navbar based on config.h

Diffstat:
Aconfig.h | 7+++++++
Mstagit-index.c | 9++++++++-
Mstagit.c | 9++++++++-
3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/config.h b/config.h @@ -0,0 +1,7 @@ +static const char indextitle[] = "git | rnpnr"; +static const char navtitle[] = "randy palamar"; +static const char *navbar[][2] = { + { "[blog]", "blog" }, + { "[git]", "git" }, + { "[setup]", "setup.html" }, +}; diff --git a/stagit-index.c b/stagit-index.c @@ -8,6 +8,8 @@ #include <git2.h> +#include "config.h" + static git_repository *repo; static const char *relpath = ""; @@ -99,10 +101,15 @@ writeheader(FILE *fp) "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" "<title>", fp); - xmlencode(fp, description, strlen(description)); + fputs(indextitle, fp); 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); fputs("</head>\n<body>\n", fp); + fprintf(fp, "<nav>\n\t<h4><a href=\"/\">%s</a></h4>\n", navtitle); + fputs("\t<div class=\"navbar\">\n", fp); + for (int i = 0; i < (sizeof(navbar)/sizeof(*navbar)); i++) + fprintf(fp, "\t\t<a href=\"/%s\">%s</a>\n", navbar[i][1], navbar[i][0]); + fputs("\t</div><hr>\n</nav>\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)); diff --git a/stagit.c b/stagit.c @@ -15,6 +15,7 @@ #include <git2.h> #include "compat.h" +#include "config.h" #define LEN(s) (sizeof(s)/sizeof(*s)) @@ -519,7 +520,13 @@ writeheader(FILE *fp, const char *title) 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); - fputs("</head>\n<body>\n<table><tr><td>", fp); + fputs("</head>\n<body>\n<nav>\n\t<h4>", fp); + fprintf(fp, "<a href=\"/\">%s</a></h4>\n", navtitle); + fputs("\t<div class=\"navbar\">\n", fp); + for (int i = 0; i < LEN(navbar); i++) + fprintf(fp, "\t\t<a href=\"/%s\">%s</a>\n", navbar[i][1], navbar[i][0]); + fputs("\t</div><hr>\n</nav>\n", fp); + fputs("<table><tr><td>", fp); fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>", relpath, relpath); fputs("</td><td><h1>", fp);