BareMetal.com

Baremetal
My Account
Domain Registration Management Services
Web Services
Rates and Specs
Bulk Rates
CGI Library
FAQ
Order Form
Tech Support
Billing Info
Company Info
Charities
Legal Info
Employment
Privacy Statement

BM


Web Services

Search Gadget;

Return CGI Library

This gadget does a simple string search through a tab delimited text file, and returns all the matches in a table.

Two or three files drive this gadget: an input form or link, a data file, and an optional format file.

Format File:

The format file is the simplest part. If it exists, it is the HTML page which the table is dropped into. The gadget scans this file looking for the tag <!FIND> and drops the table in the file at that point. If the file does not exist then the output page is simply the table and it's contents...

Here's what is in the sample format file:


<body bgcolor="#FFFFFF">
<img src="http://baremetal.com/images/bm.jpg" alt="Baremetal.com" />
<h1>Search Results:</h1>
<!FIND>
<p>
That's all folks!
</p>
<a href="http://baremetal.com/gadgets/find/">Go Back</a>

Data File:

The datafile is the next simplest component.

The first line is the field NAMES separated by tabs. The rest of the lines are the data... each field separated by a tab, and the lines/records separated by an newline character. (A newline is a line feed, and the carriage return of the CR-LF from dos won't cause any harm in html.)

The example datafile is shown between the <hr />'s:


Name:	Web Site:
tbrown  website is: <a href="http://baremetal.com/">baremetal.com</a>
sun  over here: <a href="http://www.sun.com/">www.sun.com</a>
ibm  over here: <a href="http://www.ibm.com/">www.ibm.com</a>
vvv.com	over here: <a href="http://www.vvv.com>www.vvv.com/"</a>

Filenames:

Now an explanation of filenames. The data-file and the template-file must be in the same directory. They must have the same root file name with ".data" and ".tplt" suffixes respectively. In the upcoming example we will use searchname as the root of the file name, so the files become searchname.data and searchname.tplt respectively.

Sample Input Form:

Here is an example form... HTML showing first, and then the actual working form below:


<form action="/cgi-bin/find.pl/gadgets/find/ex.find" method="post">
search text: <input type="text" name="f_find" />
    <input type="submit" value="search" /> <br />
border <input type="text" name="f_border" value="0" /> <br />
padding <input type="text" name="f_padding" value="5" /> <br />
halign <input type="text" name="f_halign" value="left" /> <br />
dalign <input type="text" name="f_dalign" value="left" /> <br />
</form>

search text:
 
border
cell padding
header alignment
data alignment

Building the form:

Setting up the form is the tricky part. There are a number of important parts to the form. The <form action=...> line is probably the most important. The action= parameter contains /cgi-bin/find.pl and the root filename as it would appear to the webserver. If /gadgets/find/ex.find.data was the URL that would load the datafile, then the "action=" clause will be:

"action=/cgi-bin/find.pl//gadgets/find/ex.find"

(Note there seems to be bug in the web server software that sometimes drops a .html suffix on the file name ... be carefull about that... the script will tell you when it can't find or read the datafile... that's why the example used here is ex.find instead of find.)

A few moments to explain the extra fields after the SEARCH button :-)...

The border, padding, halign, and dalign parameters affect the display of the table. The default values are shown in the table above...

Quick Search

There is a quick search version of this...

<a href="/cgi-bin/find.pl/gadgets/find/ex.find?tbrown">
Find tbrown
</a>

Will bring up the records matching "tbrown" ... note that if you understand the GET syntax of CGI you can pass the other fields in as well...

(e.g.: Find tbrown ).

Ask at support@baremetal.com if you need help...

Fine Points...

A maximum hit count HAS been implemented. It defaults to 100. Ask support@baremetal.com for instructions on how to change it. [It isn't posted here to stop people from writing their own forms and stealing your whole database!]

We setup the gadget so that it dumps the whole database (well, up to the maximum hit count # of lines) if there is no search string. For smallish tables this is nice (e.g. the example)

The gadget is by default NOT case-sensitive.
To turn on case sensitivity, add:
<input type="hidden" name="f_case" value="Y" /> to your form.



 
Home Page    Domain Registration Services    Web Services    Technical Support
About Baremetal    Privacy Statement    Billing Info    Charities
My Account    Legal Info    Search BareMetal

Copyright 1996-2012, BareMetal.com Inc.
Last updated: Thursday, 28-May-2015 16:14:49 PDT
Last Accessed from: No-one!
Questions and comments to support@baremetal.com