#!/bin/sh

cd ../apps
odir=$HOME/out/easylang/games
mkdir -p $odir

cp ../run/icon.png $odir

exec >$odir/index.html
cat <<xxx
<!doctype html>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="keywords" content="learning games kids">
<meta name="description" content="learning games for kids">
<link rel="icon" href="icon.png" type="image/x-png">
<title>Games & Apps</title>

<style>
body {
	background:#222;
	color:#fff;
	max-width:600px;
}
a {color:#fff;}
a:hover {background-color:#4a4}
h2 {background-color:#484;padding:7px;padding-left:12px}
h3 {background-color:#484;padding:5px;padding-left:12px}
img {float:left;padding-right:10px;padding-bottom:30px}
p {clear:left}
</style>

<h2>Games, Learning Games and Learning Apps</h2>

For fun and learning

xxx

#<h2>Learning Apps, Learning Games and Games</h2>

apps1="1st-math-trainer 1x1-trainer math-trainer roman-numbers learning-clock piano"
apps2="ice-cream letter-memory paint"
apps3="mastermind mine-sweeper 15-puzzle monster-maze snake tictactoe reaction-test catch-the-ball"

test -e /run && alias ghead=head

wrcode() {
	printf "<a href=\"../run/#cod="
	#ghead cat $1.kab  | gzip | tail -c +11 | ghead -c -8 | base64 | ghead -c -1
	cat $1.kab  | gzip | tail -c +11 | ghead -c -8 | base64 | awk '{ printf "%s", $0 }'

	#printf "<a href=\"../run/#code="
	#cat $1.kab | jq -s -R -r @uri
	echo  "\""
	f=$(echo $1 | cut -c1 | tr a-z A-Z)
	n=$f$(echo $1 | cut -c2- | tr '-' ' ')
	echo $1:$f:$n >&2
	echo "><img src=$1.png>"
	echo "<b>$n</b>"
	echo "</a>"
	echo "<p>"
}

echo "<h3>Games</h3>"
for k in $apps3; do
	wrcode $k
done

echo "<h3>Learning games</h3>"
for k in $apps2; do
	wrcode $k
done

echo "<h3>Learning apps</h3>"
for k in $apps1; do
	wrcode $k
done

cp png/*.png $odir
#cp png/easyide.png $odir
cat <<xxx
<p>
<h3>Make your own game</h3>
<a href="../ide/">An easy programming language and development environment.</a> These games were created with it.
<p>
<a href="../ide/"><img src=easyide.png alt=easylang.online></a>
<p>
<hr>
<small>christof.kaser@gmail.com</small>
xxx

