# SliTaz package receipt.

PACKAGE="hatenarunner"
VERSION="1.0"
CATEGORY="games"
SHORT_DESC="Loderunner game in javascript"
MAINTAINER="pascal.bellard@slitaz.org"
WEB_SITE="http://lodedome.no-ip.com/"
TARBALL="JavaScript_Hatena.Runner_Satoshi.Ueyama.zip"
#_WGET_URL="http://lodedome.no-ip.com/download.php?rfname=$TARBALL&request_id=Lode_5BBAB6F85D944A4A5CB7AC12B0BFD18D"
WGET_URL="http://mirror.slitaz.org/sources/packages/${TARBALL:0:1}/$TARBALL"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	unzip -o HatenaRunner_MainGameScript.zip
	rm -f HatenaRunner_MainGameScript.zip
	dos2unix js/* *.htm *.css
	# Add u, i, o, j, k, and l keys
	sed -i	-e 's/104:$/& case 73: case 105:/' \
		-e 's/98:$/& case 75: case 107:/' \
		-e 's/100:$/& case 74: case 106:/' \
		-e 's/102:$/& case 76: case 108:/' \
		-e 's/88:/& case 79: case 111:/' \
		-e 's/90:/& case 85: case 117:/' \
			js/key.js
	sed -i	-e 's/<title>.*</<title>Lode Runner</' \
		-e 's/preStart()"/preStart(); javascript:init();"/' \
		-e '/a href=/d' -e '/li>/d' -e '/ul>/d' -e '/Explorer/d' \
			runner.htm
	rm -rf	images/start.png images/hrlogo.png ScreenS Docs Unknown \
		users favicon.ico icon.png
	mv runner.htm index.html
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
        mkdir -p $fs/var/www/lode $fs/usr/share/applications
	cp -a $src/* $fs/var/www/lode
	chown -R 80.80 $fs/var/www/lode
	cat > $fs/usr/share/applications/lode.desktop <<EOT
[Desktop Entry]
Type=Application
Name=Lode runner
Exec=browser file:///var/www/lode/index.html
Icon=/var/www/lode/images/o0.gif
Terminal=false
Categories=Game;
Comment=Lode runner clone
EOT
}