I've made two improvements to the MODULES.html generator:

2023-04-17  Bruno Haible  <[email protected]>

        MODULES.html.sh: Ensure hyperlinked files are displayable.
        * MODULES.html.sh (repo_url_prefix): Use cgit instead of gitweb.

        MODULES.html.sh: Avoid a HTTP redirect.
        * MODULES.html.sh (repo_url_prefix): Use the unabbreviated name of the
        git repository server.

>From 02287d59a1923059f896bb71d5cd00de6d0acff2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 17 Apr 2023 13:07:28 +0200
Subject: [PATCH 1/2] MODULES.html.sh: Avoid a HTTP redirect.

* MODULES.html.sh (repo_url_prefix): Use the unabbreviated name of the
git repository server.
---
 ChangeLog       | 6 ++++++
 MODULES.html.sh | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e190bd90d3..796314bd3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-17  Bruno Haible  <[email protected]>
+
+	MODULES.html.sh: Avoid a HTTP redirect.
+	* MODULES.html.sh (repo_url_prefix): Use the unabbreviated name of the
+	git repository server.
+
 2023-04-16  Bruno Haible  <[email protected]>
 
 	year2038: Add tests.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 2eeffb690f..0f8294ed56 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -30,7 +30,7 @@ if test $# != 0; then
   case "$1" in
     --git-urls)
       # Generate URLs to the official gnulib git repository.
-      repo_url_prefix='https://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f='
+      repo_url_prefix='https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f='
       repo_url_suffix=''
       ;;
   esac
-- 
2.34.1

>From 879c7d6ecfa968a66eb202d5094747064b5e9ff6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 17 Apr 2023 13:41:57 +0200
Subject: [PATCH 2/2] MODULES.html.sh: Ensure hyperlinked files are
 displayable.

* MODULES.html.sh (repo_url_prefix): Use cgit instead of gitweb.
---
 ChangeLog       |  3 +++
 MODULES.html.sh | 38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 796314bd3b..bd17733008 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-04-17  Bruno Haible  <[email protected]>
 
+	MODULES.html.sh: Ensure hyperlinked files are displayable.
+	* MODULES.html.sh (repo_url_prefix): Use cgit instead of gitweb.
+
 	MODULES.html.sh: Avoid a HTTP redirect.
 	* MODULES.html.sh (repo_url_prefix): Use the unabbreviated name of the
 	git repository server.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 0f8294ed56..5892711519 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -24,13 +24,49 @@ PATH=`dirname "$0"`:$PATH; export PATH
 POSIX2001_URL='https://pubs.opengroup.org/onlinepubs/009695399'
 POSIX2008_URL='https://pubs.opengroup.org/onlinepubs/9699919799'
 
+# repo_url_prefix and repo_url_suffix are chosen such that
+#   <A HREF="${repo_url_prefix}FILENAME${repo_url_suffix}">...</A>
+# will allow to open the hyperlink and thus see the contents of FILENAME
+# in the browser.
+#
+# There are two possible ways to access files in the git repository:
+#   - Through gitweb. This is the preferred UI for humans.
+#     repo_url_prefix='https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f='
+#     repo_url_suffix=''
+#   - Through cgit.
+#     repo_url_prefix='https://git.savannah.gnu.org/cgit/gnulib.git/plain/'
+#     repo_url_suffix=''
+#
+# Unfortunately, the response headers of gitweb are not right.  For example, for
+# FILENAME = lib/stdlib.in.h, gitweb's response headers are:
+#   Content-Type: text/x-chdr; charset=ISO-8859-1
+#   Content-disposition: inline; filename="lib/stdlib.in.h"
+# whereas cgit's response headers are:
+#   Content-Type: text/plain; charset=UTF-8
+#   Content-Disposition: inline; filename="stdlib.in.h"
+# gitweb's response headers have three problems:
+#   * The content type for .h file is text/x-chdr, for .c files is text/x-csrc.
+#     The effect of this content type is that Firefox (on Ubuntu 22.04), by
+#     default, does not display the contents of the file but instead opens a
+#     download (save) dialog.  This is unwelcome in this context.
+#   * The charset=ISO-8859-1 causes incorrect display of non-ASCII characters
+#     for files such as m4/fnmatch.m4, since all of the gnulib repository is
+#     in UTF-8.
+#   * The filename="lib/stdlib.in.h" causes Firefox to propose a file name
+#     'lib_stdlib.in.h', if the user has chosen to download the file.
+# These problems come from the gitweb implementation, as can be seen from
+# https://repo.or.cz/git.git/blame_incremental/HEAD:/gitweb/gitweb.perl
+# procedure "sub git_blob_plain".  It ends up determining the content type
+# based on some MIME type registry, such as /etc/mime.types.
+#
+# So, we better choose cgit here.
 repo_url_prefix=
 repo_url_suffix=
 if test $# != 0; then
   case "$1" in
     --git-urls)
       # Generate URLs to the official gnulib git repository.
-      repo_url_prefix='https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f='
+      repo_url_prefix='https://git.savannah.gnu.org/cgit/gnulib.git/plain/'
       repo_url_suffix=''
       ;;
   esac
-- 
2.34.1

Reply via email to