(Answer) (Category) Faq-O-Matic Faq-O-Matic : (Category) Administrators' Guide : (Category) Customize :
I have a form that I would like to be part of a subcategory
I am using the FAQ-O-MATIC as a knowledge base for my companies engineering team who produces the patches and hot fixes for our core product. We use the FAQ-O-MATIC in the "normal" manner except for our descriptions of our patches. Here, our boss wants us to have a specific form. I have this form written and it works fine if I want to save it somewhere else. However we want to store it inside the FAQ-O-MATIC and I can't figure out how to make my form integrate with the fom... Basically my form's output needs to be directed into the answer section and one of my form field's value needs to be the title of the answer. Help?
-Stephanie
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>&nbsp;
                </td>
        </tr>
        <tr>
                <td valign=top><b>Client:</b>
                </td>
                <td>&nbsp;&nbsp;
                </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>&nbsp;&nbsp;
                </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&nbsp;Number:</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=20 maxlength=20 name=hotfix value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>Date&nbsp;Released:</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=20 maxlength=20 name=date_released value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>Bugzilla&nbsp;Bug&nbsp;#(s):</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=20 maxlength=20 name=bugzilla value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>ClearQuest&nbsp;Bug&nbsp;#:</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=20 maxlength=20 name=clearquest value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>Changelist&nbsp;Number&nbsp;#(s):</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=20 maxlength=20 name=changelist value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>Summary&nbsp;of&nbsp;Issues(s):</b>
                </td>
                <td>&nbsp;&nbsp;
                </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>&nbsp;&nbsp;
                </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>&nbsp;&nbsp;
                </td>
                <td valign=top><input type=text size=60 maxlength=60 name=platform value=""></input>
                </td>
        </tr>
        <tr>
                <td valign=top><b>README&nbsp;Notes:</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><TEXTAREA NAME="readme_notes" ROWS=20 COLS=60></TEXTAREA><P>&nbsp;
                </td>
        </tr>
<tr>
                <td valign=top><b>Developer&nbsp;Notes:</b>
                </td>
                <td>&nbsp;&nbsp;
                </td>
                <td valign=top><TEXTAREA NAME="dev_notes" ROWS=20 COLS=60></TEXTAREA><P>&nbsp;
                </td>
        </tr>
        <tr>
                <td align=center valign=bottom colspan=3><INPUT TYPE="submit" VALUE="Submit Form"></input>
                </td>
        </tr>
</table>
</Form>
</body>
</HTML>
well FAQ-O-MATIC killed that form....
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:&nbsp;<P></td><td valign=top>$FOR
M{client}&nbsp;<P></td></tr><tr><td valign=top>Hotfix&nbsp;Number:&nbsp;<P></td>
<td valign=top>$FORM{hotfix}&nbsp;<P></td></tr><tr><td valign=top>Date&nbsp;Rele
ased:&nbsp;<P></td><td valign=top>$FORM{date_released}&nbsp;<P></td></tr><tr><td
 valign=top>Bugzilla&nbsp;Bug&nbsp;#(s):&nbsp;<P></td><td valign=top>$FORM{bugzi
lla}&nbsp;</br></tr><tr><td valign=top>ClearQuest&nbsp;Bug&nbsp;#(s):&nbsp;<P></
td><td valign=top>$FORM{clearquest}&nbsp;<br></tr><tr><td valign=top>Changelist&
nbsp;Number&nbsp;#(s):&nbsp;<P></td><td valign=top>$FORM{changelist}&nbsp;<P></t
d></tr><tr><td valign=top><P>Summary&nbsp;of&nbsp;Issue(s):&nbsp;<P></td><td val
ign=top>$FORM{bugtitle}&nbsp;<P></td></tr><tr><td valign=top>Component:&nbsp;<P>
</td><td valign=top>$FORM{component}&nbsp;<P></td></tr><tr><td valign=top>Platfo
rm:&nbsp;<P></td><td valign=top>$FORM{platform}&nbsp;<P></td></tr><tr><td valign
=top>README&nbsp;Notes:&nbsp;<P></td><td valign=top><pre>$FORM{readme_notes}</pr
e>&nbsp;<P></td></tr><tr><td valign=top>Developer&nbsp;Notes:&nbsp;<P></td><td v
align=top><pre>$FORM{dev_notes}</pre>&nbsp;</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" ;
I wish that the 2.715d  had the fix for the greater than sign and less 
than sign.

If you wish for copies of these files just write me....

spalmer8@yahoo.com

Cheers...
[Append to This Answer]
Previous: (Answer) I want to use an external cgi-server. Is that possible with fom?
Next: (Answer) Translating FAQ-O-Matic to a new language
This document is: http://www.jonh.net/cgi-bin/faqomatic/fom?file=1735
[Search] [Appearance]
This is a Faq-O-Matic 2.718d.
Hosted by SourceForge Logo and jonh.net.