Skip to main content.
home | support | download

Back to List Archive

Displaying index results with summaries (no meta tags required)...

From: Dave Thomson <davet1(at)not-real.home.com>
Date: Sat Dec 12 1998 - 21:35:18 GMT
I've just joined the list - thanks for all the great info. There's 
been a couple of posts wondering how to display index results along with
descriptions, and I guess this is one reason people end up sending 
Micro$oft and others thousands of their (company's?) dollars. It 
can actually be done very easily within swish-e. I'm no perl expert, 
but here's what I've implemented to do this. It requires reading 2500 bytes
for each hit (I'm banking on no html tags being open after 2500 bytes) so
this is quite hungry at search time, but if you only do this for 'pages'
of 25-hits or so, it works very well for local files. I'm sure someone 
can find a more efficient way to strip the html...
 So, the following gets called for each swish 'hit'...

 sub getfile {
   $basedir = '/usr/www/docs/your.root.directory';
   ($file) = $url"=~ m\.*//[^/]*(.*)\;
   $file = substr($file,26);
   $file = "$basedir$file";
   $chars=0;
   $junk="";
   open(FILE,"$file") || print "error: $file";
   while ($chars <2500)
     {
     $mychar = getc(FILE);
     $junk = $junk . $mychar;
     $chars++;
     }
    $junk =~ s/<(([^>]|\n)*)>//g;
    print substr($junk,0,500) . "...";
 }
Received on Sat Dec 12 13:35:54 1998