Git Web frontend with stagit(1)

stagit(1) reads Git repositories and generates static pages for them with a predefined CSS stylesheet (I said stylesheet twice!), a website logo and a favicon.

Required:

Install stagit(1):

$ git clone git://git.codemadness.org/stagit
$ cd stagit
# doas make install clean

I like to have everything stagit(1)-related inside /var/www/htdocs/git.example.org along with the actual repositories, but you can choose any other directory.

Store the stylesheet, logo and favicon inside. You'll find the stylesheet inside the stagit(1) repository you cloned earlier; it's called style.css. For the logo and favicon, just make your own, but make sure they are in PNG format and have the same names as below.

# cp logo.png favicon.png style.css /var/www/htdocs/git.example.org

You can edit the stylesheet to your likings, but if you're afraid that you'll mess things up, play around with the colors only.

Here I created a repository named repo in /var/www/htdocs/git.example.org/repo.git. I will now make a directory to store the files that stagit(1) will produce. I like to give it the same name as the repository but without the .git extension:

# mkdir /var/www/htdocs/git.example.org/repo

Create symlinks for the stylesheet, logo and favicon inside the directory you just created:

$ cd /var/www/htdocs/git.example.org/repo
# ln -s ../style.css ../logo.png ../favicon.png .

Run stagit(1) and generate the static page for your repository. This has to be done inside the directory you just created since stagit(1) stores the files in the working directory. Make sure that you give it the .git directory (i.e the actual repository):

# stagit ../repo.git

Go to the top-level Git directory and generate an index.html file which is your Git server's homepage where all repositories will be listed. Again, you give it the actual repositories:

$ cd /var/www/htdocs/git.example.org
# stagit-index repo.git > index.html

I've made a simple script to automate the generation process:

#!/bin/sh

cd /var/www/htdocs/git.example.org
for dir in $(ls | grep "git"); do
	cd ${dir%.*} && stagit ../${dir} && cd .. && echo "updating ${dir}: ok"
done
stagit-index $(ls | grep "git") > index.html && echo "creating index.html. ok"

Fire up a browser and go to git.example.org and you should see everything. Success!