#!/usr/bin/perl -w

my $srcname = shift @ARGV;

open ($src, $srcname) || die "Can't open $srcname: $!";

print << "EOF";
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!-- This was generated by 'build-people name-account.txt' -->
<head>
	<meta http-equiv="CONTENT-TYPE" content="text/html; charset=URF-8">
	<title>OOo name to user maps</title>
</head>
<body lang="en-US" dir="LTR">
<h11>A mapping of names to OO.o accounts</h11>
<p>Without this mapping, using Issuezilla can be particularly
painful. If you have a mapping you think is useful and doesn't appear
here, please mail it to <a href="mailto:michael\@ximian.com">me</a>. 
</p>
<table border=1 cellpadding=2 cellspacing=3>
	<tr>
		<th width=153>
			Name
		</th>
		<th width=110>
			<I>\@openoffice.org</I>
		</th>
		<th width=96>
			IRC nick
		</th>
		<th width=201>
			Notes
		</th>
		<th width=202>
			Affiliation
		</th>
	</tr>
EOF

my @people = ();

while (<$src>) {
	my @elems = split /:/, $_;
	defined $elems[4] || die "Mangled line";
	push @people, \@elems;	
}
close ($src);

sub get2nd($)
{
  my $name = shift;
  my @elems = split (/ /, $name);
  return $elems[1] if $elems[1];
  return $name;
}

sub by2ndname
{
	get2nd(@{$a}[0]) cmp get2nd(@{$b}[0]);
}

for my $details (sort by2ndname @people) {
	my ($name,$acc,$irc,$notes,$affil) = @{$details};
	print "<tr><td>$name</td><td>$acc</td><td>$irc</td><td>$notes</td><td>$affil</td></tr>\n";
}

print << "EOF";
</table>
<font size=1 style="font-size: 8pt">May 2004 Edited by
utomo99(at)OpenOffice.org</font>
<br><br>

</body>
</html>
EOF
