]> git.armaanb.net Git - stagit.git/blob - example.sh
improve make dist, thanks Quentin Rameau
[stagit.git] / example.sh
1 #!/bin/sh
2 # - Makes index for repositories in a single directory.
3 # - Makes static pages for each repository directory.
4 #
5 # NOTE, things to do manually (once):
6 # - copy style.css, logo.png and favicon.png manually, a style.css example
7 #   is included.
8 # - write clone url, for example "git://git.codemadness.org/dir" to the "url"
9 #   file for each repo.
10 #
11 # Usage:
12 # - mkdir -p htmldir && cd htmldir
13 # - sh example.sh
14
15 reposdir="/var/www/domains/git.codemadness.nl/home/src"
16 curdir=$(pwd)
17
18 # make index.
19 cd "${reposdir}"
20 find . -maxdepth 1 -type d | grep -v "^.$" | sort | xargs stagit-index |
21         sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
22         sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index.html"
23
24 # make index (sort by last commit author time).
25 find . -maxdepth 1 -type d | grep -v "^.$" | while read -r dir; do
26         d=$(basename "${dir}")
27         cd "${reposdir}/${d}"
28         timestamp=$(git show -s --pretty="format:%at" || true)
29
30         printf "%d %s\n" "${timestamp}" "${d}"
31 done | sort -n -k 1 | cut -f 2- -d ' ' | xargs stagit-index | \
32         sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
33         sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index-time.html"
34
35 # make files per repo.
36 cd "${reposdir}"
37 find . -maxdepth 1 -type d | grep -v "^.$" | sort | while read -r dir; do
38         d=$(basename "${dir}")
39         printf "%s..." "${d}"
40
41         mkdir -p "${curdir}/${d}"
42         cd "${curdir}/${d}"
43         stagit "${reposdir}/${d}"
44
45         # symlinks
46         ln -sf log.html index.html
47         ln -sf ../style.css style.css
48         ln -sf ../logo.png logo.png
49         ln -sf ../favicon.png favicon.png
50
51         printf " done\n"
52 done