add $STAGIT_BASEURL environment variable to make Atom links absolute - stagit-gopher - A git gopher frontend. (mirror) HTML git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit a4d283cbe995468334872de7c5bff0ef5633c747 DIR parent a8a22b38a884641557532a52eff67ad3ba530d30 HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Fri, 5 Mar 2021 11:52:44 +0100 add $STAGIT_BASEURL environment variable to make Atom links absolute And to specify the correct gopher type. With feedback from adc, thanks! Diffstat: M stagit-gopher.1 | 12 +++++++++++- M stagit-gopher.c | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) --- DIR diff --git a/stagit-gopher.1 b/stagit-gopher.1 @@ -1,4 +1,4 @@ -.Dd July 19, 2020 +.Dd March 4, 2021 .Dt STAGIT-GOPHER 1 .Os .Sh NAME @@ -95,6 +95,16 @@ primary clone url of the repository, for example: git://git.2f30.org/stagit .Pp When a README or LICENSE file exists in HEAD or a .gitmodules submodules file exists in HEAD a direct link in the index is made. +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev STAGIT_BASEURL +Base URL to make links in atom.xml absolute. +Does not use the prefix from the -b option. +It should include the gopher type. +For example: STAGIT_BASE_URL="gopher://codemadness.org/1/git/stagit-gopher/". +.El +.Sh EXIT STATUS +.Ex -std .Sh SEE ALSO .Xr stagit-gopher-index 1 .Sh AUTHORS DIR diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -62,6 +62,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; @@ -913,8 +914,8 @@ printcommitatom(FILE *fp, struct commitinfo *ci, const char *tag) xmlencode(fp, ci->summary, strlen(ci->summary)); fputs("</title>\n", fp); } - fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"commit/%s.gph\" />\n", - ci->oid); + fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommit/%s.gph\" />\n", + baseurl, ci->oid); if (ci->author) { fputs("<author>\n<name>", fp); @@ -1289,6 +1290,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]);