summaryrefslogtreecommitdiff
path: root/vcs-server/usr-src-infra-scripts/generate-project-list-html.sh
blob: 819e2243e82df2351658f3914a4e07ec84cf8d80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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"