Ugly HTML FORM to be used with the api.cgi...
---begin form -----
<HTML>
<head><meta http-equiv="content-type" content="application/x-www-form-urlencoded ; charset=ISO-8859-1">
<Title>Hotfix Form</title></head>
<body>
<Form name='faqinfo' method="post" action="http://(domain:port)/cgi-bin/api.cgi">
<table width = 90% align=center>
<tr>
<td colspan=3>This form will automatically update the "Hotfix" section of the FAQ-O-Matic.<P>Please try to give as much detailed information as possible about what the issue was, how you resolved it, and as much Client information as possible. (i.e.: How their systems are set up, who was the contact person with their information, etc..)<P>
</td>
</tr>
<tr>
<td valign=top><b>Client:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=60 maxlength=60 name=client value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Hotfix Category:</b>
</td>
<td>
</td>
<td valign=top>
<select name=hotfixCategory>
<option value=173>Agents 3.0.0.x</option>
<option value=164>5.0.1.x</option>
<option value=163>5.0.0.x</option>
<option value=95>4.7.1.x</option>
<option value=94>4.7.0.x</option>
<option value=93>4.6.x</option>
</select>
</td>
</tr>
<tr>
<td valign=top><b>Hotfix Number:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=20 maxlength=20 name=hotfix value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Date Released:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=20 maxlength=20 name=date_released value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Bugzilla Bug #(s):</b>
</td>
<td>
</td>
<td valign=top><input type=text size=20 maxlength=20 name=bugzilla value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>ClearQuest Bug #:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=20 maxlength=20 name=clearquest value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Changelist Number #(s):</b>
</td>
<td>
</td>
<td valign=top><input type=text size=20 maxlength=20 name=changelist value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Summary of Issues(s):</b>
</td>
<td>
</td>
<td valign=top><input type=text size=60 maxlength=500 name=bugtitle value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Component:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=60 maxlength=60 name=component value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>Platform:</b>
</td>
<td>
</td>
<td valign=top><input type=text size=60 maxlength=60 name=platform value=""></input>
</td>
</tr>
<tr>
<td valign=top><b>README Notes:</b>
</td>
<td>
</td>
<td valign=top><TEXTAREA NAME="readme_notes" ROWS=20 COLS=60></TEXTAREA><P>
</td>
</tr>
<tr>
<td valign=top><b>Developer Notes:</b>
</td>
<td>
</td>
<td valign=top><TEXTAREA NAME="dev_notes" ROWS=20 COLS=60></TEXTAREA><P>
</td>
</tr>
<tr>
<td align=center valign=bottom colspan=3><INPUT TYPE="submit" VALUE="Submit Form"></input>
</td>
</tr>
</table>
</Form>
</body>
</HTML>
|
Not a pretty cgi at all.
It spits out an HTML Table which is inserted as the text of the new answer.
The title of the new answer is from the HTML field "Hotfix".
You ought to modify the output to generate some natural text.
I am realizing painfully that FAQ-O-MATIC isn't handling HTML
the way I wish it would.
Anyhow here is the guts of the cgi...
---- begin cgi script ----
#!/usr/bin/perl -w
use lib '.'; # for suid installations
use lib '/usr/lib/perl5/site_perl/5.6.1';
use FAQ::OMatic::API;
use FAQ::OMatic;
use LWP::UserAgent;
use URI;
use HTTP::Request::Common qw(GET POST);
use Carp qw (cluck);
use CGI qw (ErrorsToBrowser);
print "Content-type:text/html\n\n";
print "<html><body><title>HotFix Posting</title>";
print "<h3>Your Hotfix has been posted as:</h3><P>";
# read in form data
my %FORM;
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
my @pairs = split(/&/, $buffer);
my $pair;
foreach $pair (@pairs) {
my ($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
#print "<tr><td>$name</td><td>$value</td></tr>\n"
# if $debug;
}
}
my $url = 'http://something.fully.qualified:80/cgi-bin/fom';
# the FAQ-O-MATIC administrator must add this user to the FAQ-O-MATIC
# make sure only people who are allowed to add the answer using the form
# are given permissions using the "[Edit Category Permissions]" via
# FAQ-O-MATIC interface...
my $id = 'faqmailer@something.fully.qualified';
my $pass = 'faqmailer';
my $fom_api = new FAQ::OMatic::API() or die "Failed to create FaqOMatic object $
!\n";
$fom_api->setURL($url) or die "Set URL call failed $!\n";
$fom_api->setAuth($id, $pass) or die "Set Auth call failed $!\n";
my $bodytext="<table><tr><td valign=top>Client: <P></td><td valign=top>$FOR
M{client} <P></td></tr><tr><td valign=top>Hotfix Number: <P></td>
<td valign=top>$FORM{hotfix} <P></td></tr><tr><td valign=top>Date Rele
ased: <P></td><td valign=top>$FORM{date_released} <P></td></tr><tr><td
valign=top>Bugzilla Bug #(s): <P></td><td valign=top>$FORM{bugzi
lla} </br></tr><tr><td valign=top>ClearQuest Bug #(s): <P></
td><td valign=top>$FORM{clearquest} <br></tr><tr><td valign=top>Changelist&
nbsp;Number #(s): <P></td><td valign=top>$FORM{changelist} <P></t
d></tr><tr><td valign=top><P>Summary of Issue(s): <P></td><td val
ign=top>$FORM{bugtitle} <P></td></tr><tr><td valign=top>Component: <P>
</td><td valign=top>$FORM{component} <P></td></tr><tr><td valign=top>Platfo
rm: <P></td><td valign=top>$FORM{platform} <P></td></tr><tr><td valign
=top>README Notes: <P></td><td valign=top><pre>$FORM{readme_notes}</pr
e> <P></td></tr><tr><td valign=top>Developer Notes: <P></td><td v
align=top><pre>$FORM{dev_notes}</pre> </td></tr></table>";
my $text=scalar($bodytext);
print "$text";
my $res = $fom_api->newAnswer($FORM{'hotfixCategory'}, $FORM{'hotfix'}, $text);
die "Could not post answer\n" unless $res;
print <<EndofHTML;
<P><h3>To see the new Hotfix please click here:<br>
<a href=\"http://something.fully.qualified:80/cgi-bin/fom\?file=$FORM{'hotfixCategory'}\
">
http://something.fully.qualified:80/cgi-bin/fom\?file=$FORM{'hotfixCategory'}
</a></h3>
EndofHTML
print "</body></html>\n" ; |