#! /bin/ksh
db="$BIB/Work/Done/perl95.BA"
tdb=/tmp/hfeshci.tmp
ssadd -f Z -et '%M  X' $db | sed '/%Z/s/  //' > $tdb

idents=`ssformat -t '%Z' $tdb`

function fixnote {
	perl -ne '
		s|HFES Proceedings 1983|<i>Proceedings of the Human Factors Society 27th Annual Meeting</i>, 1983|;
		s|HFES Proceedings 1984|<i>Proceedings of the Human Factors Society 28th Annual Meeting</i>, 1984|;
		s|HFES Proceedings 1985|<i>Proceedings of the Human Factors Society 29th Annual Meeting</i>, 1985|;
		s|HFES Proceedings 1986|<i>Proceedings of the Human Factors Society 30th Annual Meeting</i>, 1986|;
		s|HFES Proceedings 1987|<i>Proceedings of the Human Factors Society 31st Annual Meeting</i>, 1987|;
		s|HFES Proceedings 1988|<i>Proceedings of the Human Factors Society 32nd Annual Meeting</i>, 1988|;
		s|HFES Proceedings 1989|<i>Proceedings of the Human Factors Society 33rd Annual Meeting</i>, 1989|;
		s|HFES Proceedings 1990|<i>Proceedings of the Human Factors Society 34th Annual Meeting</i>, 1990|;
		s|HFES Proceedings 1991|<i>Proceedings of the Human Factors Society 35th Annual Meeting</i>, 1991|;
		s|HFES Proceedings 1992|<i>Proceedings of the Human Factors Society 36th Annual Meeting</i>, 1992|;
		s|HFES Proceedings 1993|<i>Proceedings of the Human Factors and Ergonomics Society 37th Annual Meeting</i>, 1993|;
		s|HFES Proceedings 1994|<i>Proceedings of the Human Factors and Ergonomics Society 38th Annual Meeting</i>, 1994|;
		print;
		';
}

for ident in $idents
do
	rec=`sssearch "z=$ident" $tdb`
	export title=`echo "$rec" | ssfill -fT -w200 | ssformat -t "%T"`
	# echo "ident=$ident title=$title"
	export authors=`echo "$rec" | ssextract -f A | sed 's/%A/\//g' | fmt | sed 's/^\/ *//'`
	export abstract=`echo "$rec" | ssformat -t "%X" | sed 's/^   /<p>/g'`
	export keywords=`echo "$rec" | ssformat -t "%K"`
	export other=`echo "$rec" | ssformat -t "%O" | fixnote`
	export url=`echo "$rec" | ssformat -t "%W"`
	export pages=`echo "$rec" | ssformat -t "%P"`

	export yr=`echo $other | sed -e 's/^.*19\([89][0-9]\).*$/\1/'`
	export pgs=`echo "$other" | sed -e 's/.*, pp. *//'`
	export filename="Abstracts/$yr:$pgs.html"

	echo $filename
	(
	echo "<html lang='en'>"
	echo "<head>"
	echo "<title>$title</title>"
	echo "</head><body>"
	echo "<h1>$title</h1>"
	echo "<p>$authors</p>"
	echo "<p><b>Abstract:</b> $abstract</p>"
	echo "<p><b>Keywords:</b> $keywords</p>"
	if test "$url"
	then
		append=", (<a href='$url' title='click to view full text (subscription required)'><b>online&nbsp;access</b></a>)."
	else
		append=.
	fi
	echo "<p><b>Note:</b> $other$append</p>"
	echo "<p><b>Republished:</b> G. Perlman, G. K. Green &amp; M. S. Wogalter (Eds)"
	echo "<a href='http://hcibib.org/perlman/hfeshci/'><b>Human Factors Perspectives on Human-Computer Interaction</b></a>:"
	echo "Selections from Proceedings of Human Factors and Ergonomics Society Annual Meetings, 1983-1994,"
	echo "Santa Monica, California: HFES, 1995, pp. $pages.</p>"
	echo "</body></html>"
	) > $filename
done

