blob: 9b3de8cfefe942efbe548a0106e38c98111341c8 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/bin/sh
yourname="Sebastiano Tronto
repo="$PWD"
name="$(basename $repo .git)"
baseurl="https://git.tronto.net"
basedir="/var/www/htdocs/git.tronto.net"
htdir="$basedir/$name"
filesdir="/home/git/FILES"
bindir="/home/git/BIN"
setupinfo() {
echo "$yourname" > owner
echo "$baseurl/$name" > url
git update-server-info
}
genstagit() {
rm -rf "$htdir"
mkdir -p "$basedir"
cp -r "$repo" "$htdir"
stagit -l 100 "$repo"
git show master:README.md > file/README.md
git archive HEAD --prefix="$name/" -o "$basedir/$name.zip"
}
cpindexfile() {
cp "$htdir/files.html" "$htdir/index.html"
}
cpstylefiles() {
cp $filesdir/favicon.png "$1"
cp $filesdir/logo.png "$1"
cp $filesdir/style.css "$1"
}
formatreadme() {
printf '%s\n' \
g/class=\"line\"/d \
"/<pre id=\"blob\">" d d i "$(lowdown file/README.md)" . w \
| ed -s file/README.md.html > /dev/null
}
adddownloadbutton() {
printf '%s\n' \
"/log\.html\">Log<\/a>" i \
"<a href=\"../$name.zip\">Download</a> |" . w \
| ed -s "$1" > /dev/null
}
addbottombar() {
printf '%s\n' \
"/<\/body>" i "$(cat $filesdir/bottom.html)" . w \
| ed -s "$1" > /dev/null
}
changeindextitlestyle() {
printf '%s\n' \
"/<td><span class=\"desc\">Repositories" c \
"<td><h1>Repositories</h1></td></tr><tr><td></td><td>" . w \
| ed -s "$basedir/index.html" > /dev/null
}
genstagitindex() {
stagit-index /home/git/*.git | \
sed 's|/log\.html||g' > "$basedir/index.html"
}
mkpage() {
echo "Updating stagit page for $name"
setupinfo
genstagit
cpindexfile
cpstylefiles "./"
[ -e file/README.md ] && formatreadme
for f in $(find "$htdir" -name "*.html"); do
adddownloadbutton $f
addbottombar $f
done
}
mkindex() {
echo "Updating stagit index page"
genstagitindex
cpstylefiles "$basedir/"
addbottombar "$basedir/index.html"
changeindextitlestyle
}
if [ "$1" = "index" ]; then
mkindex
elif [ "$1" = "all" ]; then
for g in *.git; do
cd $g
printf "#!/bin/sh\n\n$bindir/post-receive-stagit\n" > \
hooks/post-receive
chmod +x hooks/post-receive
$bindir/post-receive-stagit
cd
done
mkindex
else
mkpage
fi
|