Due to prodding and coaxing by some coworkers I finally got around to
putting this on CPAN.
It's a C::A based module that lets you easily add a site search to your
application using swish-e (http://www.swish-e.org). We've already used
it's predecessor on a pretty large project and it worked rather well as
a base class (but for most cases it can probably be used as-is).
Give it a whirl (when your favorite CPAN mirror has it) and let us know
what you think.
NAME
CGI::Application::Search - Base class for CGI::App Swish-e site engines
SYNOPSIS
package My::Search;
use base 'CGI::Application::Search';
sub cgiapp_init {
my $self = shift;
$self->param('SWISHE-INDEX' =>'my-swishe.index');
}
#let the user turn context highlighting off
sub cgiapp_prerun {
my $self = shift;
$self->param('HIGHLIGHT_CONTEXT' => 0)
if($self->query->param('highlight_off'));
}
1;
DESCRIPTION
A CGI::Application based control module that uses Swish-e API in perl
(<http://swish-e.org>) to to perform searches on a swish-e index of
documents. It uses HTML::Template to display the search form and the
results. It uses two templates ('search_results.tmpl' and
'results_header.tmpl') and any customization of the look and feel should
happen in the templates. For the majority of the cases you should simply
be able to adjust the style section found in the 'search_results.tmpl'
template.
This controller has two run modes. The start_mode is show_search.
* show_search
This run mode will show the simple search form. If there are any
results they will also be displayed. This is the default run
mode and after a search is performed, this run mode is called to
display the results.
* perform_search
This run mode will actually use the SWISH::API module to perform
the search on a given index. If the HIGHLIGHT_CONTEXT option is
set is will then use Text::Context to obtain a suitable context
of the search content for each result returned and highlight the
text according to the HIGHLIGHT_START and HIGHLIGHT_STOP
options.
--
Michael Peters
Developer
Plus Three, LP
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.