tadd $STAGIT_BASEURL environment variable to make Atom links absolute - stagit … | |
git clone git://src.adamsgaard.dk/stagit | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 266c623668ec1b9be5878043a81c4e37209d6a2e | |
parent d8600b4268a10008719ff573344d3d0096a4a276 | |
Author: Hiltjo Posthuma <[email protected]> | |
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: | |
M stagit.1 | 10 +++++++++- | |
M stagit.c | 8 ++++++-- | |
2 files changed, 15 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/stagit.1 b/stagit.1 | |
t@@ -1,4 +1,4 @@ | |
-.Dd July 19, 2020 | |
+.Dd March 4, 2021 | |
.Dt STAGIT 1 | |
.Os | |
.Sh NAME | |
t@@ -103,6 +103,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/stagit.c b/stagit.c | |
t@@ -58,6 +58,7 @@ struct referenceinfo { | |
static git_repository *repo; | |
+static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */ | |
static const char *relpath = ""; | |
static const char *repodir; | |
static char index_link[255] = "<a href=\"..\">Back to index</a>"; | |
t@@ -820,8 +821,8 @@ printcommitatom(FILE *fp, struct commitinfo *ci, const cha… | |
xmlencode(fp, ci->summary, strlen(ci->summary)); | |
fputs("</title>\n", fp); | |
} | |
- fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"commit/… | |
- ci->oid); | |
+ fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommi… | |
+ baseurl, ci->oid); | |
if (ci->author) { | |
fputs("<author>\n<name>", fp); | |
t@@ -1204,6 +1205,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]); |