added search indexer

This commit is contained in:
JT Smith 2006-01-20 21:18:09 +00:00
parent cb5e059b2e
commit fd3fb924f3
12 changed files with 214 additions and 16 deletions

View file

@ -36,6 +36,30 @@ These methods are available from this package:
=cut
#-------------------------------------------------------------------
=head2 addFile ( path )
Use an external filter defined in the config file as searchIndexerPlugins.
=head3 path
The path to the filename to index, including the filename.
=cut
sub addFile {
my $self = shift;
my $path = shift;
$path =~ m/\.(\w)$/;
my $type = lc($1);
my $filters = $self->session->config->get("searchIndexerPlugins");
my $filter = $filters->{$type};
my $content = `$filter $path`;
$self->addKeywords($content) if (!$content =~ m/^\s*$/);
}
#-------------------------------------------------------------------
=head2 addKeywords ( text )
@ -57,6 +81,20 @@ sub addKeywords {
}
#-------------------------------------------------------------------
=head2 asset ( )
Returns a reference to the asset object we're indexing.
=cut
sub asset {
my $self = shift;
return $self->{_asset};
}
#-------------------------------------------------------------------
=head2 create ( asset )
@ -125,6 +163,21 @@ sub getId {
#-------------------------------------------------------------------
=head2 setIsPublic ( boolean )
Sets the status of whether this asset will appear in public searches.
=cut
sub isPublic {
my $self = shift;
my $boolean = shift;
my $set = $self->session->db->prepare("update assetIndex set isPublic=? where assetId=?");
$set->execute($boolean, $self->getId);
}
#-------------------------------------------------------------------
=head2 new ( asset )
Constructor.
@ -138,7 +191,7 @@ A reference to an asset object.
sub new {
my $class = shift;
my $asset = shift;
my $self = {_session=>$asset->session, _id=>$asset->getId};
my $self = {_asset=>$asset, _session=>$asset->session, _id=>$asset->getId};
return $self;
}