logo

stagit

STAtic GIT web view generator (in C) git clone https://hacktivis.me/git/stagit.git
commit: cc9938ff2dfbb23733276342e363a48cb1cee4e3
parent 261c7389213760c17d4f42365e8a5d420fd4acff
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed,  1 Aug 2018 00:44:21 +0200

stagit-index.c: HTML5 it, Remove Owner

Diffstat:

Mconfig.h2++
Mstagit-index.c32++++++++++++++++++++------------
2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/config.h b/config.h @@ -3,3 +3,5 @@ static const unsigned summarylen = 70; /* summary length in the log */ static const int showlinecount = 1; /* display line count or file size in file tree index */ static const char *assetpath = "/git/"; /* Where are the assets (example: assetpath/style.css ) */ static const char *faviconurl = "/git/logo.png"; /* Where is the favicon (example: /favicon.png ) */ +static const char *repo_name = "/git/"; +static const char *repo_description = "Lanodan’s git repositories"; 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 = ""; @@ -69,24 +71,32 @@ 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); + if(strlen(faviconurl) > 0) { + fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%s\" />\n", faviconurl); + } else { + fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", assetpath); + } fprintf(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("</span></td></tr><tr><td></td><td>\n" - "</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n" + fputs("</head>\n<body>\n<header>", fp); + fprintf(fp, "<img src=\"%slogo.png\" alt=\"logo\" width=\"32\" height=\"32\" />", + assetpath); + fputs("<h1>", fp); + xmlencode(fp, repo_name, strlen(repo_name)); + fputs("</h1><span class=\"desc\">", fp); + xmlencode(fp, repo_description, strlen(repo_description)); + fputs("</span></header>", fp); + fputs("<main>\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>" + "<tr><th>Name</th><th>Description</th>" + "<th>Last commit</th></tr>" "</thead><tbody>\n", fp); } void writefooter(FILE *fp) { - fputs("</tbody>\n</table>\n</div>\n",fp); + fputs("</tbody>\n</table>\n",fp); + fputs("</main>\n", fp); fputs("\t<footer>Please <a href=\"https://hacktivis.me/about\">contact me</a> by any means for patches, issues(tracker will maybe be added oneday), thanks/donations, or whatever else.</footer>\n", fp); fputs("</body>\n</html>\n", fp); } @@ -127,8 +137,6 @@ writelog(FILE *fp) fputs("</a></td><td>", fp); xmlencode(fp, description, strlen(description)); fputs("</td><td>", fp); - xmlencode(fp, owner, strlen(owner)); - fputs("</td><td>", fp); if (author) printtimeshort(fp, &(author->when)); fputs("</td></tr>", fp);