]> git.armaanb.net Git - stagit.git/commitdiff
add $STAGIT_BASEURL environment variable to make Atom links absolute
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 5 Mar 2021 10:51:21 +0000 (11:51 +0100)
committerArmaan Bhojwani <me@armaanb.net>
Thu, 8 Apr 2021 01:54:56 +0000 (21:54 -0400)
With feedback from adc, thanks!

man/stagit.1
src/stagit.c

index 23e7ca73af45c1f570eedeb145943abd4546d6e1..d53595f880dcdb69af47fd2499fd58e58a91227c 100644 (file)
@@ -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
index ba154d05333c177a711508414be1c288118ca8c2..d99ae191580cafebbee451b168911ff7f64ec45c 100644 (file)
@@ -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]);