commit a722864f83b9c8697fbf085eb0e2e51cb129e8cb
parent a4d283cbe995468334872de7c5bff0ef5633c747
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 5 Mar 2021 12:45:22 +0100
change STAGIT_BASEURL to an -u option and also update the example script
Diffstat:
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/example_create.sh b/example_create.sh
@@ -32,7 +32,8 @@ for dir in "${reposdir}/"*/; do
mkdir -p "${destdir}/${d}"
cd "${destdir}/${d}" || continue
- stagit-gopher -b "${stagitdir}/${d}" -c ".cache" "${reposdir}/${r}"
+ stagit-gopher -b "${stagitdir}/${d}" -c ".cache" \
+ -u "gopher://codemadness.org/1/git/$d/" "${reposdir}/${r}"
# symlinks
ln -sf log.gph index.gph
diff --git a/example_post-receive.sh b/example_post-receive.sh
@@ -67,7 +67,8 @@ stagitdir=$(printf "%s" "${stagitdir}" | sed 's@[/]*$@@g')
stagit-gopher-index -b "${stagitdir}" "${reposdir}/"*/ > "${destdir}/index.gph"
# make pages.
-stagit-gopher -b "${stagitdir}/${d}" -c "${cachefile}" "${reposdir}/${r}"
+stagit-gopher -b "${stagitdir}/${d}" -c "${cachefile}" \
+ -u "gopher://codemadness.org/1/git/$d/" "${reposdir}/${r}"
ln -sf log.gph index.gph
diff --git a/stagit-gopher.1 b/stagit-gopher.1
@@ -1,4 +1,4 @@
-.Dd March 4, 2021
+.Dd March 5, 2021
.Dt STAGIT-GOPHER 1
.Os
.Sh NAME
@@ -9,6 +9,7 @@
.Op Fl b Ar baseprefix
.Op Fl c Ar cachefile
.Op Fl l Ar commits
+.Op Fl u Ar baseurl
.Ar repodir
.Sh DESCRIPTION
.Nm
@@ -35,6 +36,11 @@ Write a maximum number of
.Ar commits
to the log.gph file only.
However the commit files are written as usual.
+.It Fl u Ar baseurl
+Base URL to make links in the Atom feeds absolute.
+Does not use the prefix from the -b option.
+It should include the gopher type.
+For example: "gopher://codemadness.org/1/git/stagit-gopher/".
.El
.Pp
The options
@@ -95,14 +101,6 @@ 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
diff --git a/stagit-gopher.c b/stagit-gopher.c
@@ -1224,7 +1224,8 @@ writerefs(FILE *fp)
void
usage(char *argv0)
{
- fprintf(stderr, "%s [-b baseprefix] [-c cachefile | -l commits] repodir\n", argv0);
+ fprintf(stderr, "%s [-b baseprefix] [-c cachefile | -l commits] "
+ "[-u baseurl] repodir\n", argv0);
exit(1);
}
@@ -1263,6 +1264,10 @@ main(int argc, char *argv[])
if (argv[i][0] == '\0' || *p != '\0' ||
nlogcommits <= 0 || errno)
usage(argv[0]);
+ } else if (argv[i][1] == 'u') {
+ if (i + 1 >= argc)
+ usage(argv[0]);
+ baseurl = argv[++i];
}
}
if (!repodir)
@@ -1290,9 +1295,6 @@ 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]);