summaryrefslogtreecommitdiff
path: root/vcs-server/usr-src-infra-scripts/generate-project-list-html.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vcs-server/usr-src-infra-scripts/generate-project-list-html.sh')
-rw-r--r--vcs-server/usr-src-infra-scripts/generate-project-list-html.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/vcs-server/usr-src-infra-scripts/generate-project-list-html.sh b/vcs-server/usr-src-infra-scripts/generate-project-list-html.sh
new file mode 100644
index 0000000..819e224
--- /dev/null
+++ b/vcs-server/usr-src-infra-scripts/generate-project-list-html.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+set -e
+
+##
+## Generate a static HTML file with a list of WebGit repositories,
+## and links to the GitWeb,CGIT,direct viewers.
+##
+
+# For saner sort,join
+LC_ALL=C
+
+# File containing the project list.
+# This file is referenced from /etc/cgitrc-webgit and /etc/gitweb-webgit.conf
+PROJECT_LIST_FILE=project-list.html
+
+# Directory containing the repositories
+WEBGIT_ROOT=/srv/git/web
+
+cd "$WEBGIT_ROOT" || exit 1
+
+##
+## HTML Header
+##
+echo "
+<html>
+<head>
+<title>GNU Savannah WebGit Repositories</title>
+<style>
+table.list td {
+ padding-left: 2em;
+}
+</style>
+</head>
+<body>
+<h1>Experimental WebGit Repositories list</h1>
+The following repositories are available:
+<br/>
+<br/>
+" > t
+
+##
+## Generate content links to each letter
+##
+awk 'BEGIN { for (a=65;a<=90;a=a+1) { printf "<a href=\"#%c\">%c</a> ",a,a } }' >> t
+
+## Table header
+echo "<br/>
+<table class=\"list\">" >> t
+
+# Generate list of all projects
+find "$WEBGIT_ROOT" -maxdepth 1 -type d -name "*.git" -printf "%f\n" \
+ | sort \
+ | awk 'BEGIN { letter = "" }
+ letter != substr($0,1,1) {
+ letter = substr($0,1,1)
+ printf "<tr><td><a name=\"%s\">&nbsp;</a></td></tr>",letter
+ }
+ 1 { print "<tr>"
+ printf "<td>%s</td>\n",$0
+ printf "<td><a href=\"/cgit/%s/\">cgit</a></td>\n",$0
+ printf "<td><a href=\"/gitweb/?p=%s\">gitweb</a></td>\n", $0
+ printf "<td><a href=\"/r/%s/\">direct</a></td>\n", $0
+ print "</td>"
+ }' >> t
+
+##
+## HTML footer
+##
+echo "
+</table>
+</body>
+</html>" >> t
+
+mv t "$PROJECT_LIST_FILE"
+