garbash-stagit

garbash fork of stagit for git hosting with subdirs
git clone git://git.alexkarle.com.com/garbash-stagit
Log | Files | Refs | README | LICENSE

commit 8efe972cd5002ebe386b738d13e99ad82856debd (patch)
parent d880df3be9d9e399ac9291be87a9ebedebb3e595
Author: alex <alex@garbash.com>
Date:   Fri, 24 Sep 2021 21:34:35 -0400

stagit: Add -r flag to override logo link

This is needed for subdirectory installations (see stagit-index -r).
If the repo is in a subdirectory, the ".." default relpath for the logo
is the subdirectory, and not the root.

Diffstat:
Mstagit.1 | 4++++
Mstagit.c | 14++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)

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 r Ar rooturl .Ar repodir .Sh DESCRIPTION .Nm @@ -35,6 +36,9 @@ 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://git.codemadness.org/stagit/". +.It Fl r Ar rooturl +Root URL to link to for the logo. +Defaults to "..". .El .Pp The options diff --git a/stagit.c b/stagit.c @@ -59,6 +59,7 @@ struct referenceinfo { static git_repository *repo; static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */ +static const char *rooturl = ""; /* logo.png links to this (used in multi-dir solutions) */ static const char *relpath = ""; static const char *repodir; @@ -486,8 +487,13 @@ writeheader(FILE *fp, const char *title) name, relpath); fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath); 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); + if (rooturl) { + fprintf(fp, "<a href=\"%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>", + rooturl, relpath); + } else { + fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>", + relpath, relpath); + } fputs("</td><td><h1>", fp); xmlencode(fp, strippedname, strlen(strippedname)); fputs("</h1><span class=\"desc\">", fp); @@ -1182,6 +1188,10 @@ main(int argc, char *argv[]) if (i + 1 >= argc) usage(argv[0]); baseurl = argv[++i]; + } else if (argv[i][1] == 'r') { + if (i + 1 >= argc) + usage(argv[0]); + rooturl = argv[++i]; } } if (!repodir)