commit ff41682701c859b2c10e3be802e6d76b74c5cf12
parent 37646e890fb91b6c42dc11378ef2d916986d43a7
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 5 Mar 2021 11:51:21 +0100
add $STAGIT_BASEURL environment variable to make Atom links absolute
With feedback from adc, thanks!
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/man/stagit.1 b/man/stagit.1
@@ -101,6 +101,14 @@ favicon image.
.It style.css
CSS stylesheet.
.El
+.Sh ENVIRONMENT
+.Bl -tag -width Ds
+.It Ev STAGIT_BASEURL
+Base URL to make links in atom.xml absolute.
+For example: STAGIT_BASE_URL="https://git.codemadness.org/stagit/".
+.El
+.Sh EXIT STATUS
+.Ex -std
.Sh SEE ALSO
.Xr stagit-index 1
.Sh AUTHORS
diff --git a/src/stagit.c b/src/stagit.c
@@ -56,6 +56,7 @@ struct commitinfo {
static git_repository *repo;
+static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
static const char *relpath = "";
static const char *repodir;
@@ -784,8 +785,8 @@ printcommitatom(FILE *fp, struct commitinfo *ci)
xmlencode(fp, ci->summary, strlen(ci->summary));
fputs("</title>\n", fp);
}
- fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"commit/%s.html\" />\n",
- ci->oid);
+ fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommit/%s.html\" />\n",
+ baseurl, ci->oid);
if (ci->author) {
fputs("<author>\n<name>", fp);
@@ -1234,6 +1235,9 @@ main(int argc, char *argv[])
}
#endif
+ if ((p = getenv("STAGIT_BASEURL")))
+ baseurl = p;
+
if (git_repository_open_ext(&repo, repodir,
GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) {
fprintf(stderr, "%s: cannot open repository\n", argv[0]);