#! /bin/ksh

# makepage: make html pages on the accepted papers

bib=./hph.bib    # intermediate file of all the accepted papers
hphdir=.
abstractdir=$hphdir/Abstracts # where to store the individual paper entries
contents=$hphdir/contents.html # where to store the table of contents

echo "$0: making table of contents: $contents"
if test $bib -nt $contents
then
	(
	echo "<title>HF Perspectives on HCI</title>"
	echo "<br><b>Human Factors Perspectives on Human-Computer Interaction:</b>"
	echo "<i>Selections from Proceedings of Human Factors and Ergonomics Society Annual Meetings, 1983-1994</i>"
	echo "<p>Edited by Gary Perlman, Georgia K. Green, and Michael S. Wogalter"
	echo "<p>Published by the Human Factors and Ergonomics Society"
	echo "<p><b>Table of Contents</b>"
	echo "<ol>"
	ssformat -t "<li><a href=$abstractdir/%I.html>%T</a>
		(%B)" $bib
	echo "</ol>"
	) > $contents
fi

function pagekexpand
{
sed '
	s/\<T\>/ZZZ/
	s/\<TI\>/ZZZ/
	s/\<TIK\>/Keyboard input/
	s/\<TIP\>/Pointing device input/
	s/\<TIV\>/Voice\/Speech input/
	s/\<TIO\>/ZZZ/
	s/\<TO\>/ZZZ/
	s/\<TOS\>/Screen output/
	s/\<TOV\>/Voice\/Speech output/
	s/\<TON\>/Non-speech output/
	s/\<TOO\>/ZZZ/
	s/\<L\>/Process lifecycle/
	s/\<LA\>/Analysis/
	s/\<LD\>/Design/
	s/\<LP\>/Prototyping/
	s/\<LI\>/Implementation/
	s/\<LE\>/Evaluation/
	s/\<LO\>/ZZZ/
	s/\<A\>/ZZZ/
	s/\<AC\>/Computer-supported cooperative work/
	s/\<AH\>/Hypermedia\/Information systems/
	s/\<AI\>/Intelligent\/Expert systems/
	s/\<AX\>/Complex systems/
	s/\<AS\>/Special populations/
	s/\<AO\>/ZZZ/
	s/\<M\>/ZZZ/
	s/\<ME\>/Empirical studies/
	s/\<MC\>/Case studies/
	s/\<MD\>/ZZZ/
	s/\<MS\>/Survey/
	s/\<MM\>/Models and theories/
	s/\<MO\>/ZZZ/
	s/\<O\>/ZZZ/
	s/\[//
	s/\]//
	s/[*="]//g
	/^ZZZ$/d
	s/ZZZ//
	s/$/;/
	'
}

# Now generate the individual papers

if test ! -d $abstractdir
then
	mkdir $abstractdir
fi

ID=`ssformat -t %I $bib` # IDs of all the accepted papers

echo "$0: making individual paper pages"
for i in $ID
do
	r=`sssearch I=$i $bib`
	echo $i
	(
	# Use short title for page title, long title for heading 1
	echo "$r" | ssformat -t "<title>%H</title>
		<br><b>%T</b><br>"
	echo "$r" | ssextract -f A |
		sed -e 's.%A ..' -e 's/$/ \//' |
			ff -w 200 |
				sed -e 's/ $//' -e 's/\/$//'
	echo "<p>"
	echo "$r" | ssformat -t "<b>Abstract:</b> %X" |
		sed '
			s/^   /<p>/
			s/{sub:\(.*\)}/<i>\1<\/i>/g
			s/{sup:\(.*\)}/<b>\1<\/b>/g
			'
	echo "<p><b>Keywords:</b>"
	echo "$r" | ssformat -t %K | pagekexpand | sort | ff -w 200 |
		sed 's/; *$//'
	HFS="<i>Proceedings of the Human Factors Society"
	HFES="<i>Proceedings of the Human Factors and Ergonomics Society"
	AM="Annual Meeting<\/i>"
	echo "$r" | ssformat -t "<p><b>Originally published:</b> %D, pp. %P" | sed "
		s/1983/$HFS 27th $AM, &/
		s/1984/$HFS 28th $AM, &/
		s/1985/$HFS 29th $AM, &/
		s/1986/$HFS 30th $AM, &/
		s/1987/$HFS 31st $AM, &/
		s/1988/$HFS 32nd $AM, &/
		s/1989/$HFS 33rd $AM, &/
		s/1990/$HFS 34th $AM, &/
		s/1991/$HFS 35th $AM, &/
		s/1992/$HFS 36th $AM, &/
		s/1993/$HFES 37th $AM, &/
		s/1994/$HFES 38th $AM, &/
		"
	echo "$r" | ssformat -t "<p><b>Republished:</b>
	G. Perlman, G. K. Green, & M. S. Wogalter (Eds.)
	<a href=http://www.acm.org/~perlman/hfeshci/index.html
	><b>Human Factors Perspectives on Human-Computer Interaction</a>:
	<i>Selections from Human Factors and Ergonomics Society Annual Meetings 1983-1994</i></b>, Santa Monica, CA: HFES, pp. %C."
	) > $abstractdir/$i.html
done
