#!/bin/sh

cat _header.html > index.html

userlink() {
	echo -n '<a href="'
	echo -n $2$1
	echo -n '">'
	echo -n $1
	echo '</a>'
}

userpic() {
	echo -n '<a href="'
	echo -n "$1"
	echo -n '">'
	echo -n '<img src="'
	echo -n "$1"
	echo -n '">'
	echo '</a>'
}

gen_user() {
	for u in /home/*/.$1; do
		bn=$(echo $u | awk -F/ '{print $3}')
	
		userlink $bn "http://tilde.town/~"
		mkdir $bn
		for pic in "$u"/scrot*.png; do
			filename=$(basename $pic)
			cp $pic $bn/$filename
			userpic $bn/$filename
		done
		cat "$u"/info.txt
		echo "<hr>" 
	done  >> index.html
}

gen_user "theme"
gen_user "rice" # DEPRECATED!

cat _footer.html >> index.html
