#! /bin/ksh
# dolist: codename may span different publication categories (confer/video)

. functions
PGM=$0



genheader "Publications"

echo "ACM SIGCHI is the ACM's
Special Interest Group on Computer-Human Interaction.
Through ACM, SIGCHI has published
books,
journals and magazines
conference proceedings,
and videos.
On these pages you will find ACM publications
officially sponsored by SIGCHI,
and some related in content to the SIGCHI charter.
<p>
<font size=-4><b>Disclaimer</b>:
We have tried to gather accurate information,
but some information has been difficult to obtain.
In particular, temporary ACM order numbers may used for older SIGCHI videos,
and prices and availability may not be correct.
The ACM catalog may have more accurate information.
</font>
"

gencomment This page generated `date` by $0 in $PGM


template_image="<img border=0 src=%imagesmall align=middle height=100 alt=\"\">"
template_title="<font size=+2>%title</font>"
template="<dt><a href=%category.html>$template_image $template_title</a><dd>
%desc
<br>
"
template="<tr><td valign=top align=center><a href=%category.html>$template_image</a>
<td valign=top><a href=%category.html>$template_title</a>
<br>
%desc
<br>
"

#genliststart # start of category definition list
echo "<table border=1 cellpadding=5>"

if test $# -eq 0
then
	categories=`ssformat -t %category pubs.db`
else
	categories="$*"
fi

for category in $categories
do
	catrec=`sssearch "category=$category" pubs.db`

	## begin $category.html
	tmp=`echo "$catrec" | ssformat -t %title`
	genheader "$tmp" > $category.html
	gencomment This page generated `date` by $0 in $PGM >> $category.html
	sssearch "category=$category" pubs.db |
		ssformat -t "%desc<p>%detail" >> $category.html

	# format template for each category in index.html
	echo "$catrec" | ssformat -t "$template"

	# insert shortcut links to codenames (if more than 1)
	codenames=`ssformat -t %codename $category.db | sort -fu`
	ncodenames=`echo $codenames | wc -w`
	debug $category $codenames
	if test "$ncodenames" -gt 1 # many codes, so insert links
	then
		## begin list of codenames in $category.html
		genliststart >> $category.html
		for codename in $codenames
		do
			# each pub has an acmordernumber
			acmordernumbers=`sssearch "codename=$codename" $category.db |
				ssformat -t "%acmordernumber"`
			npubs=`echo "$acmordernumbers" | wc -w`
			if test $npubs -eq 1 # just link to the pub's page
			then
				codelink=$acmordernumbers      # 123456
				tmp=
			else # link to a page for the codename
				codelink=$category-$codename   # conferences-UIST.html
				### generate page that the quicklink will link to
				(
				tmp=`echo "$catrec" | ssformat -t "%title: $codename`
				genheader "$tmp"
				gencomment This page generated `date` by $0 in $PGM
				gendesc -v $category $codename
				genpubtab $category $codename
				genfooter $category
				) > $codelink.html
				tmp=:$npubs # will place count after codename
			fi
			# add codelink to index.html
			echo "<a href=$codelink.html>[$codename$tmp]</a>"
			## add codelink to $category.html
			echo "<dt><font size=+2><a href=$codelink.html>$codename</a></font><dd>" >> $category.html
			gendesc $category $codename >> $category.html

		done
		## end list of codenames in $category.html
		genlistend >> $category.html
	else
		genpubtab $category >> $category.html
	fi
	## end $category.html
	genfooter index >> $category.html
done
#genlistend # end of category definition list
echo "</table>"

gencontact

genfooter

