#!/bin/sh

#	.mkaff.sh -	Generates the "Affinity" Profile webpage
#		Author:	Jack C Lipton
#
#
#

HTML=affinity2.html		# resultant file
LIST=.squicks			# list of "squick" categories


AWK=/tmp/mkaff2A.$$		# awk script
TMP=/tmp/mkaff2T.$$		# volatile file


#
#	We used to have an internal copy of the list.  I'm keeping
#	this only as a backup...
#

cat				>${HTML}+		<<HTMLFILE
<HTML>

<HEAD>
	<TITLE>Story Affinity Profile - Test</TITLE>
</HEAD>

<BODY>

<H1 ALIGN=CENTER>Story Affinity Profile<BR>Test Page</H1>

This is a prototypical form developed by <A HREF="mailto:liptonsoup1951@yahoo.com">Jack C Lipton</A>.	<BR>
You can download a copy of the generating script from
<A HREF="http://www.asstr.org/~CupaSoup/.mkaff.sh">http://www.asstr.org/~CupaSoup/.mkaff2.sh</A>
and the 
<A HREF="http://www.asstr.org/~CupaSoup/.squicks">http://www.asstr.org/~CupaSoup/.squicks</A>
file is used to generate the menu.		<BR>

There are more than a few entries intended to get a laugh.
I'll even settle for chuckles.			<BR>

Another version can be seen <A HREF="squick.html">here</A>		<BR>

<BR>
<BR>

<H2>Scales</H2>

<P>
There are 5 selections per category;  These are:
<UL>
  <LI>	<B>Must</B> Contain:
	I'm not interested in any story WITHOUT this element.
  <LI>	<B>Nice</B> to Have:
	I prefer stories with this element but it's not required.
  <LI>	<B>So?</B>:
	I don't give a rat's ass if this element is present or not.
  <LI>	<B>Nope</B>:
	I'm less than thrilled to see a story with this element.
  <LI>	<B>Squick</B>:
	I *don't* want to fucking read something with this code!
</UL>

<P>
I'm sure some folks can have something funny to say about my phrasing
above.  It's a first cut so please have a good time with a chain-saw.

<BR>
<BR>
<BR>


<FORM>

HTMLFILE


cat				>$AWK			<<AWKSCRIPT
BEGIN	{
		FS =		"|";
		inlist =	0;

		STEPLIST[1] =	"+2";		# seek
		STEPLIST[2] =	"+1";		# mild approval
		STEPLIST[3] =	"0";		# neutral
		STEPLIST[4] =	"-1";		# disapproval
		STEPLIST[5] =	"-2";		# SQUICK!

		steps =		5;
	}
/^_/	{	# handle a section header

		if ( inlist != 0 ) {
			printf( "</TABLE>\n\n");
		}

		printf( "<BR><H2>%s</H2>\n<TABLE BORDER>\n", substr(\$0,2));
		printf( "  <TR>\n");
		printf( "\t<TH>Must</TH>\n");
		printf( "\t<TH>Nice</TH>\n");
		printf( "\t<TH>So?</TH>\n");
		printf( "\t<TH>Nope</TH>\n");
		printf( "\t<TH>Squick!</TH>\n");
		printf( "\t<TH>Description</TH>\n");
		inlist =	1;

		next;
	}
/^-$/	{	# inserts a blank line (results vary)

		if ( inlist == 0 ) {
			printf( "<TABLE BORDER>\n");
		} else {
			printf( "  <TR>\n");
#			printf( "</TABLE><BR><TABLE>");
#			printf( "</TABLE>\n<TABLE BORDER>");
		}
		next;
	}
	{	# acquire the varname and the description we're working with
		varname =	\$1;
		description =	\$2;
	}
	{
		printf( "  <TR>\n");

		for ( ndx = 1 ; ndx <= steps ; ndx++ ) {

			key =		STEPLIST[ndx];

			if ( ndx == 3 ) {
				printf( "\t<TD><INPUT TYPE=\\"radio\\" NAME=\\"%s\\" VALUE=\\"%s\\" CHECKED></TD>\n", varname, key);
			} else {
				printf( "\t<TD><INPUT TYPE=\\"radio\\" NAME=\\"%s\\" VALUE=\\"%s\\"></TD>\n", varname, key);
			}
		}

		printf( "\t<TD>%s</TD>\n\n", description);

	}
END	{
		if ( inlist != 0 ) {
			printf( "</TABLE>\n\n");
		}

		printf( "</FORM>\n\n<HR SIZE=5>\n<CENTER>\n");
		printf( "Copyright (c) 2002 - Jack C Lipton<BR>\n");
		printf( "</CENTER>\n\n</BODY>\n\n</HTML>\n");
	}
AWKSCRIPT

awk	-f $AWK		$LIST				>>${HTML}+

cutover	$HTML

rm -f		$AWK	$TMP

exit	0