]> git.armaanb.net Git - stagit.git/blob - example.sh
example.sh: fix go to appropriate dir
[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 set -e
16
17 reposdir="/var/www/domains/git.codemadness.nl/home/src"
18 curdir=$(pwd)
19
20 # make index.
21 cd "${reposdir}"
22 find . -maxdepth 1 -type d | grep -v "^.$" | sort | xargs stagit-index |
23         sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
24         sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index.html"
25
26 # make index (sort by last commit author time).
27 find . -maxdepth 1 -type d | grep -v "^.$" | while read -r dir; do
28         d=$(basename "${dir}")
29         cd "${reposdir}/${d}"
30         timestamp=$(git show -s --pretty="format:%at" || true)
31
32         printf "%d %s\n" "${timestamp}" "${d}"
33 done | sort -n -k 1 | cut -f 2- -d ' ' | xargs stagit-index | \
34         sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
35         sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index-time.html"
36
37 cd "${reposdir}"
38
39 # make files per repo.
40 find . -maxdepth 1 -type d | grep -v "^.$" | sort | while read -r dir; do
41         d=$(basename "${dir}")
42         printf "%s..." "${d}"
43         cd "${curdir}"
44
45         test -d "${d}" || mkdir -p "${d}"
46         cd "${d}"
47         stagit "${reposdir}/${d}"
48
49         printf " done\n"
50
51         # symlinks
52         ln -sf log.html index.html
53         ln -sf ../style.css style.css
54         ln -sf ../logo.png logo.png
55         ln -sf ../favicon.png favicon.png
56 done