Author: earle Date: 2008-01-20 18:46:51 +0000 (Sun, 20 Jan 2008) New Revision: 1140
Modified: trunk/Changes trunk/lib/OpenGuides/Search.pm Log: Don't include redirect pages in search results. Closes #24.
Modified: trunk/Changes =================================================================== --- trunk/Changes 2008-01-20 00:52:37 UTC (rev 1139) +++ trunk/Changes 2008-01-20 18:46:51 UTC (rev 1140) @@ -7,6 +7,7 @@ Ensure that all modules we ship are versioned. Added experimental support for local IP blacklisting modules; see the display_node method in "perldoc OpenGuides" for details. + Don't include redirect pages in search results. (#24) Include map link URLs in RDF output. (#26) Hide historic versions of nodes from search engines. (#207)
Modified: trunk/lib/OpenGuides/Search.pm =================================================================== --- trunk/lib/OpenGuides/Search.pm 2008-01-20 00:52:37 UTC (rev 1139) +++ trunk/lib/OpenGuides/Search.pm 2008-01-20 18:46:51 UTC (rev 1140) @@ -503,17 +503,25 @@ $contents_res{$node} = int( $contents_res{$node} / $num_results ) + 1; }
- # It'll be a real phrase (as opposed to a word) if it has a space in it. - # In this case, dump out the nodes that don't match the search exactly. - # I don't know why the phrase searching isn't working properly. Fix later. - if ( $phrase =~ /\s/ ) { - my @tmp = keys %contents_res; - foreach my $node ( @tmp ) { - my $content = $wiki->retrieve_node( $node ); + my @tmp = keys %contents_res; + foreach my $node ( @tmp ) { + my $content = $wiki->retrieve_node( $node ); + + # Don't include redirects in search results. + if ($content =~ /^#REDIRECT/) { + delete $contents_res{$node}; + next; + } + + # It'll be a real phrase (as opposed to a word) if it has a space in it. + # In this case, dump out the nodes that don't match the search exactly. + # I don't know why the phrase searching isn't working properly. Fix later. + if ( $phrase =~ /\s/ ) { unless ( $content =~ /$phrase/i || $node =~ /$phrase/i ) { delete $contents_res{$node}; - } + } } + }
my %results = map { $_ => { name => $_, score => $contents_res{$_} } }