From: Hiltjo Posthuma Date: Fri, 5 Mar 2021 10:51:21 +0000 (+0100) Subject: add $STAGIT_BASEURL environment variable to make Atom links absolute X-Git-Url: https://git.armaanb.net/?p=stagit.git;a=commitdiff_plain;h=ff41682701c859b2c10e3be802e6d76b74c5cf12 add $STAGIT_BASEURL environment variable to make Atom links absolute With feedback from adc, thanks! --- diff --git a/man/stagit.1 b/man/stagit.1 index 23e7ca7..d53595f 100644 --- 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 index ba154d0..d99ae19 100644 --- 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("\n", fp); } - fprintf(fp, "\n", - ci->oid); + fprintf(fp, "\n", + baseurl, ci->oid); if (ci->author) { fputs("\n", 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]);