#!/bin/bash

#18.01.2003 by nthx :)

head=$1
for i in [1-9]*; do
    echo -n "Doing file: $i.."
    act=`echo $i| cut -d\. -f1`
    next=`expr $act + 1`
    prev=`expr $act - 1`
    file=$$.tmp

    echo -n > $file
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">
<html>
<head>
    <meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">
    <meta http-equiv=\"content-language\" content=\"pl\">
    <meta name=\"Author\" content=\"nthx\">
    <title>$1</title>" >> $file
    echo "</head>" >> $file
    echo "<body>" >> $file

    #GLOWNA STRONA
    echo "<p><div align=center><a href=index.html>Strona główna</a></div>" >> $file
    #GORNE LINKI
    echo "<p><div align=center>" >> $file
    echo "<p><table width=80%><tr><td align=left><a href=$prev.html>Wcześniejszy</a>" >> $file
    echo "<td align=right><a href=$next.html>Następny</table>" >> $file
    echo "</div" >> $file
    #OBRAZEK
    echo "<p><div align=center>" >> $file
    echo "<p><a href=$next.html><img src=$act.jpg border=0></a>" >> $file
    echo "</div>" >> $file
    #DOLNE LINKI
    echo "<p><div align=center>" >> $file
    echo "<p><table width=80%><tr><td align=left><a href=$prev.html>Wcześniejszy</a>" >> $file
    echo "<td align=right><a href=$next.html>Następny</table>" >> $file
    echo "</div" >> $file
    #GLOWNA STRONA
    echo "<p><div align=center><a href=index.html>Strona główna</a></div>" >> $file

    echo "</body></html>" >> $file
    mv $file "$act".html
    echo "done"

done


#ROBIMY index.html
file=index.html
echo "Doing file: html/$file.."
echo > $file
echo "<html><body>" >> $file
echo "<h3 align=center>$head</h3>" >> $file
echo "<p><div align=center>" >> $file

for i in *.html; do
    echo "<a href=$i>$i</a> <br>" >> $file
done

echo "</div>" >> $file
echo "</body></html>" >> $file
echo "done"

chmod a+rx .
chmod -R a+r *