#!/bin/sh

TIMESTAMP=$(date '+%FT%T%:z')
TIMEOUT=60

i=0
for URL in $(grep -v '^#' FEEDS)
do
	FN=$((i++)).feedtmp
	wget -q -T ${TIMEOUT} -U '' -O - ${URL} | xsltproc step1.xsl - | xsltproc step2.xsl - > ${FN} &
done 

wait

BODY=''
for j in $(seq 0 ${i})
do
	BODY=${BODY}$(cat ${j}.feedtmp)
done

echo '<HTML>'
echo '<HEAD>'
echo "<TITLE>${TIMESTAMP}</TITLE>"
echo '<LINK REL="stylesheet" TYPE="text/css" HREF="index.css">'
echo '</HEAD>'

echo '<BODY>'
echo "<H1>${TIMESTAMP}</H1>"

echo ${BODY}

echo '</BODY>'
echo '</HTML>'

rm *.feedtmp
