stagit

git site generator
Contents

add $STAGIT_BASEURL environment variable to make Atom links absolute

With feedback from adc, thanks!

Hiltjo Posthuma hiltjo@codemadness.org

commit: 2eea2be parent: ee8294e
2 files changed, 15 insertions(+), 3 deletions(-)
Mstagit.1+9-1
Mstagit.c+6-2
M · stagit.1 +9, -1
 1@@ -1,4 +1,4 @@
 2-.Dd July 19, 2020
 3+.Dd March 4, 2021
 4 .Dt STAGIT 1
 5 .Os
 6 .Sh NAME
 7@@ -103,6 +103,14 @@ favicon image.
 8 .It style.css
 9 CSS stylesheet.
10 .El
11+.Sh ENVIRONMENT
12+.Bl -tag -width Ds
13+.It Ev STAGIT_BASEURL
14+Base URL to make links
in atom.xml absolute.
15+For example:
STAGIT_BASE_URL="https://git.codemadness.org/stagit/".
16+.El
17+.Sh EXIT STATUS
18+.Ex -std
19 .Sh SEE ALSO
20 .Xr stagit-index
1
21 .Sh AUTHORS
M · stagit.c +6, -2
 1@@ -58,6 +58,7 @@ struct referenceinfo {
 2
 3 static
git_repository *repo;
 4
 5+static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
 6 static const char *relpath = "";
 7 static const char
*repodir;
 8
 9@@ -807,8 +808,8 @@ printcommitatom(FILE *fp, struct commitinfo *ci, const char *tag)
10 xmlencode(fp, ci->summary,
strlen(ci->summary));
11
fputs("</title>\n", fp);
12 }
13- fprintf(fp, "<link rel=\"alternate\"
type=\"text/html\" href=\"commit/%s.html\" />\n",
14- ci->oid);
15+ fprintf(fp,
"<link rel=\"alternate\" type=\"text/html\"
href=\"%scommit/%s.html\" />\n",
16+ baseurl,
ci->oid);
17
18 if
(ci->author) {
19
fputs("<author>\n<name>", fp);
20@@ -1184,6 +1185,9 @@ main(int argc, char *argv[])
21 }
22 #endif
23
24+ if ((p = getenv("STAGIT_BASEURL")))
25+ baseurl = p;
26+
27 if (git_repository_open_ext(&repo, repodir,
28
GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) {
29 fprintf(stderr,
"%s: cannot open repository\n", argv[0]);