Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

remote_search no results on reload

Quote Reply
remote_search no results on reload
Hello world!

I have xml_search_results plugin installed.
When I use remote_search.cgi script and search for "car" it gives me good results, but when I try to search same word (car) one more time it says "No links were found containing car"

I think there is a problem in remote_search.cgi file at RED line:

main();
sub main {
# -----------------------------------------------------------------------------
my $q = new CGI;
my $query = $q->param('query');
$query =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/ge;
print $q->header;
$q->param or return print "No search term entered.";
eval {
require LWP::Simple;
import LWP::Simple;
};
if ($@) {
return print "You must have LWP::Simple installed in order to use this script.";
}
my $content = get("$URL&query=$query") or return print "Unable to load $URL. Reason: $!";
my $item_count = 0;
my $link_results_loop;
while ($content =~ m,<item>(.*?)</item>,sg) {
my $item = $1;
my ($title,$link,$description,$link_category_id) = $item =~ m,
<title>(.*?)</title>\s*
<link>(.*?)</link>\s*
<description>(.*?)</description>
<link_category_id>(.*?)</link_category_id>
,sx;
$item_count++;
push @$link_results_loop => {title => $title, link => $link, description => $description, link_category_id => $link_category_id};
}
$item_count or return print "No links were found containing <b>$query</b> !";

open (TMP, $TEMPLATE) or return print "Unable to open template file: $TEMPLATE ($!)";
read (TMP, my $data, -s TMP);
close TMP;
print '<html><head><meta http-equiv="Content-Type" content="charset=iso-8859-2"><title>Raziskovalec</title></head><body>';
print parse_template($data, $link_results_loop);
print '</body></html>';

}
sub parse_template {
#-------------------------------------------------------------------------
# Simply parse the template and replace the link loop
#
my ($TEMPLATE,$loop) = @_;
(ref $loop eq 'ARRAY') || return;
my ($loop_content) = $TEMPLATE =~ /<%link_loop%>(.*?)<%end_loop%>/sm;
my $result;
foreach (@$loop) {
my $tmp = $loop_content;
$tmp =~ s/<%\s*(.*?)\s*%>/(exists $_->{$1})?$_->{$1}:'';/seg;
$result .= $tmp;
}
$TEMPLATE =~ s/(<%link_loop%>.*?<%end_loop%>)/$result/sm;

return $result;
}








I wonder why it works when I search first time and dont work second time for same search term.

thanks,
Saso
Subject Author Views Date
Thread remote_search no results on reload raziskovalec 1987 Dec 26, 2005, 12:52 PM
Thread Re: [raziskovalec] remote_search no results on reload
raziskovalec 1918 Dec 27, 2005, 2:40 AM
Thread Re: [raziskovalec] remote_search no results on reload
socrates 1896 Dec 29, 2005, 5:01 PM
Post Re: [socrates] remote_search no results on reload
tandat 1888 Dec 29, 2005, 8:49 PM