Skip to main content.
home | support | download

Back to List Archive

Re: Re: Older scripts working with swish dev ?

From: Andrew Lord <andrewlord(at)not-real.internode.on.net>
Date: Mon Jul 01 2002 - 15:29:48 GMT
On Saturday 29 June 2002 05:33 am, you wrote:

Hi Bill,

> >With regards to some of those other bits and pieces you mentioned, I'm not
> >sure what they're about either; I'm not the author and haven't got to the
> >point of fully understanding that script.
>
> Me either.  What's it suppose to do?  A rewrite might be in order.

A general description of the script as a whole (when working correctly): 

With the way the form is set up at present, sub makeselect generates the 
dropdown menu content based on whatever indexes happen to reside in $swishdir 
(see dictionarydev1.cgi).  So say I have indexes thisindex.swish (IndexName 
of 'This Path' ) and thatindex.swish (IndexName of 'That Path'), then the 
drop-down menu generated by dictionarydev1.cgi will list the IndexName(s), 
with the select name being 'index' and the select options being 
'thisindex.swish' and 'thatindex.swish'.

The way the form works at present is very convenient from the point of view 
of adding further directories; the user can simply index whatever path they 
like (placing the index and conf files into $swishdir) and the index is then 
available for use, straight-away, in the drop-down menu.  

Initially the desired index is selected from the drop-down menu and upon 
clicking a letter, a list of words corresponding to that letter and that 
index is produced.  The words that are returned in that list each contain a 
hyperlink that includes a reference to that same index and a reference to the 
particular word itself, so that when you click on the word, that word and 
target index are submitted to the searchscript nominated in $searchscript 
(see top of dictionarydev1.cgi).  

I think the best way to explain is by example, so I've put together an 
attachment called dictionarydev1.cgi for you.  To see how it works or doesn't 
work (with line 185 "my @requested_indexes = $cgi->param('index');" commented 
out), just do the following:

1) place it in your cgi-bin
2) Change lines 28 & 172 to reflect path to your swish executable
3) Change line 33 $swishdir to reflect the path to your swishindexdirectory.
4) Change Line 195 to reflect path to one of your own indexes in $swishdir
5) Change line 204 to reflect the list of indexes in your swish index 
directory (and leave it ## commented).

In your browser, http://localhost.localdomain/cgi-bin/dictionarydev1.cgi: if 
you click on a letter you should get all the words beginning with that letter 
and corresponding to the index nominated at line 195.  In its present form, 
no matter which index is selected from the drop-down menu, you will always 
get the same list of words generated when you click a letter (corresponding 
to the content of the index nominated at line 195).  However the script does 
partly work, to the extent that any selections made from the dropdown menu 
are reflected in altered hyperlinking of the word.  

Now, if we comment out line 195 and uncomment line 204, then load 
dictionarydev1.cgi again, and click a letter we get the following error 
message (no matter which index is selected from the drop-down menu):

"Could not open the index file 
'/home/httpd/html/swishindexdirectory/that.swish/home/httpd/html/swishindexdirectory/this.swish/home/httpd/html/swishindexdirectory/another.swish'"

So it appears that there's something wrong with the way the script is 
validating the indexes submitted from the dropdown menu.  The script is 
substituting the joined list of all possible acceptable indexes for the 
actual index selected from the drop-down menu.  Any clues what I've done 
wrong in putting together sub makeselect and how it should be changed ? 


> Not sure what you are asking, but the -f parameter takes a list of index
> file names (or paths).  If you are asking about what to pass in from the
> form you can pick anything you like -- you can pass in the actual index
> file names, or some index.  I would not use the IndexName as there's
> nothing that says that they must be unique.  Therefore, I'd create a map:
>
>     my %index_map = (
>         1    => 'index1',
>         2    => 'index2',
>         3    => 'index3',
>    );
>
> and then you have your drop-down list use the values 1, 2, 3,....


With regards to validating any inputs from the drop down menu in the 
web page, I assume that I should change the hash "%index_map" to the 
following:

my %index_map = (
	this.swish => 'This Path',
	that.swish => 'That Path',
	another.swish => 'Another Path',
);

>    my @requested_indexes = $cgi->param('index_select');

Then change the above line to reflect the name of the drop-down menu (which 
is just called 'index') and leave the rest the same as you provided ?

    my @requested_indexes = $cgi->param('index');
 
    my $index_files = join ' ',
       map { $index_map{$_} } grep { exists $index_map{$_} )
          @requested_indexes;

However a problem occurs if I include line 185 "my @requested_indexes = 
$cgi->param('index');" since when I try to load 
http://localhost.localdomain/cgi-bin/dictionarydev1.cgi, I get the error 
message  "The document contained no data.  Try again later, or contact the 
server's administrator."  Commenting out ## the line allows the form to 
function (although still imperfectly, as described above ).  Any idea what 
should be done to correct this ?


Cheers,

Andrew Lord



*********************************************************************
Due to deletion of content types excluded from this list by policy,
this multipart message was reduced to a single part, and from there
to a plain text message.
*********************************************************************
Received on Mon Jul 1 08:29:04 2002