wiki::toolkit::search::base(3pm) [debian man page]
Wiki::Toolkit::Search::Base(3pm) User Contributed Perl Documentation Wiki::Toolkit::Search::Base(3pm)NAME
Wiki::Toolkit::Search::Base - Base class for Wiki::Toolkit search plugins.
SYNOPSIS
my $search = Wiki::Toolkit::Search::XXX->new( @args );
my %wombat_nodes = $search->search_nodes("wombat");
This class details the methods that need to be overridden by search plugins.
METHODS
"new"
my $search = Wiki::Toolkit::Search::XXX->new( @args );
Creates a new searcher. By default the arguments are just passed to "_init", so you may wish to override that instead.
"search_nodes"
# Find all the nodes which contain the word 'expert'.
my %results = $search->search_nodes('expert');
Returns a (possibly empty) hash whose keys are the node names and whose values are the scores in some kind of relevance-scoring system I
haven't entirely come up with yet. For OR searches, this could initially be the number of terms that appear in the node, perhaps.
Defaults to AND searches (if $and_or is not supplied, or is anything other than "OR" or "or").
Searches are case-insensitive.
"analyze"
@terms = $self->analyze($string)
Splits a string into a set of terms for indexing and searching. Typically this is done case-insensitively, splitting at word boundaries,
and extracting words that contain at least 1 word characters.
"fuzzy_title_match"
$wiki->write_node( "King's Cross St Pancras", "A station." );
my %matches = $search->fuzzy_title_match( "Kings Cross St. Pancras" );
Returns a (possibly empty) hash whose keys are the node names and whose values are the scores in some kind of relevance-scoring system I
haven't entirely come up with yet.
Note that even if an exact match is found, any other similar enough matches will also be returned. However, any exact match is guaranteed
to have the highest relevance score.
The matching is done against "canonicalised" forms of the search string and the node titles in the database: stripping vowels, repeated
letters and non-word characters, and lowercasing.
"index_node"
$search->index_node($node, $content);
Indexes or reindexes the given node in the search engine indexes. You must supply both the node name and its content.
canonicalise_title
$fuzzy = $self->canonicalise_title( $ node);
Returns the node title as suitable for fuzzy searching: with punctuation and spaces removes, vowels removed, and double letters squashed.
"delete_node"
$search->delete_node($node);
Removes the given node from the search indexes. NOTE: It's up to you to make sure the node is removed from the backend store. Croaks on
error.
"supports_phrase_searches"
if ( $search->supports_phrase_searches ) {
return $search->search_nodes( '"fox in socks"' );
}
Returns true if this search backend supports phrase searching, and false otherwise.
"supports_fuzzy_searches"
if ( $search->supports_fuzzy_searches ) {
return $search->fuzzy_title_match("Kings Cross St Pancreas");
}
Returns true if this search backend supports fuzzy title matching, and false otherwise.
SEE ALSO
Wiki::Toolkit
perl v5.14.2 2012-05-28 Wiki::Toolkit::Search::Base(3pm)
Check Out this Related Man Page
Wiki::Toolkit::Plugin(3pm) User Contributed Perl Documentation Wiki::Toolkit::Plugin(3pm)NAME
Wiki::Toolkit::Plugin - A base class for Wiki::Toolkit plugins.
DESCRIPTION
Provides methods for accessing the backend store, search and formatter objects of the Wiki::Toolkit object that a plugin instance is
registered with.
SYNOPSIS
package Wiki::Toolkit::Plugin::Foo;
use base qw( Wiki::Toolkit::Plugin);
# And then in your script:
my $wiki = Wiki::Toolkit->new( ... );
my $plugin = Wiki::Toolkit::Plugin::Foo->new;
$wiki->register_plugin( plugin => $plugin );
my $node = $plugin->datastore->retrieve_node( "Home" );
POSSIBLE METHODS
pre_moderate
Called before moderation is performed.
Allows changes to the parameters used in moderation.
my %args = @_;
my ($name_ref,$version_ref) = @args{ qw( node version ) };
$$name_ref =~ s/s/_/g;
return 0;
post_moderate
Called after moderation has been performed.
Allows additional actions to occur after node moderation.
my %args = @_;
my ($node,$node_id,$version) =
@args{ qw( node node_id version ) };
&update_pending_list($node,$version);
pre_rename
Called before a rename is performed.
Allows changes to the parameters used by rename.
my %args = @_;
my ($old_name_ref,$new_name_ref,$create_new_versions_ref) =
@args{ qw( old_name new_name create_new_versions ) };
$$old_name_ref =~ s/s/_/g;
$$new_name_ref =~ s/s/_/g;
return 0;
post_rename
Called after a rename has been performed.
Allows additional actions to occur after node renames.
my %args = @_;
my ($old_name,$new_name,$node_id) =
@args{ qw( old_name new_name node_id ) };
&recalculate_category_listings();
pre_retrieve
Called before a retrieve is performed.
Allows changes to the parameters used by retrieve.
my %args = @_;
my ($name_ref,$version_ref) = @args{ qw( node version ) };
return &check_retrive_allowed($$name_ref);
TODO: Allow declining of the read.
pre_write
Called before a write is performed.
Allows changes to the parameters used by the write;
my %args = @_;
my ($node_ref,$content_ref,$metadata_ref) =
@args{ qw( node content metadata ) };
$$content_ref =~ s/pub/Pub/g;
return 1;
post_write
Called after a write has been performed.
Allows additional actions to occur after node writes.
my %args = @_;
my ($node,$node_id,$version,$content,$metadata) =
@args{ qw( node node_id version content metadata ) };
&log_node_write($node,gmtime);
post_delete
Called after a delete has been performed.
Allows additional actions to occur after node deletions.
my %args = @_;
my ($node,$node_id,$version) =
@args{ qw( node node_id version ) };
&log_node_delete($node,gmtime);
DECLINING ACTIONS FROM PRE_ METHODS
Note: This functionality is missing for pre_retrieve
It is possible for the pre_ methods (eg C<pre_write>) to
decline the action. This could be due to an authentication
check done by the plugin, due to the content, or whatever else
the plugin fancies. There are three possible return values from
a pre_ plugin:
C<-1> - Deny this action
C<0> or C<undef> - I have no opinion
C<1> - Allow this action
If you have only zeros, the action will be allowed. If you have ones
and zeros, it will also be allowed.
If you have minus ones and zeros, it will be denied. If you have minus
ones, ones and zeros, the sum will be used to decide.
For default deny, have one plugin return -1, and another only return 1
if the action is explicity allowed)
METHODS
new
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->_init if $self->can("_init");
return $self;
}
Generic contructor, just returns a blessed object.
wiki
Returns the Wiki::Toolkit object, or "undef" if the "register_plugin" method hasn't been called on a Wiki::Toolkit object yet.
datastore
Returns the backend store object, or "undef" if the "register_plugin" method hasn't been called on a Wiki::Toolkit object yet.
indexer
Returns the backend search object, or "undef" if the "register_plugin" method hasn't been called on a Wiki::Toolkit object yet, or if
the wiki object had no search object defined.
formatter
Returns the backend formatter object, or "undef" if the "register_plugin" method hasn't been called on a Wiki::Toolkit object yet.
SEE ALSO
Wiki::Toolkit
AUTHOR
Kake Pugh (kake@earth.li).
COPYRIGHT
Copyright (C) 2003-4 Kake Pugh. All Rights Reserved.
Copyright (C) 2006 the Wiki::Toolkit team. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2011-09-25 Wiki::Toolkit::Plugin(3pm)