Christoph Halbartschlager

NAME

HtDig::Config - Perl extension for managing ht://Dig configuration files

SYNOPSIS

  use HtDig::Config;
  my $htdig = new HtDig::Config('/opt/www/conf/configdig_sites.pl');
  $htdig->autodetect();
  while (my ($site_name, $path) = each %{$htdig->sites()}) {
    print "Site $site_name found at $path\n";
  }
  my $site = $htdig->sites("default");
  #etc.
  #See the HtDig::Site module for information on using the Site object
  #

DESCRIPTION

HtDig::Config provides an object-oriented interface to the configuration files for ht://Dig, a popular, open-source content indexing and searching system.

ht://Dig allows you to specify a configuration file to use when beginning an indexing run or doing a search, thus allowing you to maintain multiple databases of indexed web pages. The Config object's main job is to help you keep track of all the site configuration files you have, using a sort of "registry" to keep track of sites you've registered with ConfigDig. The HtDig::Site object works with the Config object to help you modify and save each site's configuration settings.

METHODS

*new
  my $htdig = new HtDig::Config(conf_path=>'/opt/www/conf/configdig_sites.pl');

Returns a new Config object. No required parameters. If you don't pass in conf_path, the value for $DEFAULT_CONFIF_LOCATION is used. You can change this to your own preference for convenience if you wish, with no ill effects. You can also pass in auto_create=>1 to cause a blank file to be created at conf_path, if one doesn't already exist. Dies on failure.

*save
  $htdig->save();

Causes the current Site registry to be written to the file at $config_object->{conf_path};

*sites
  my @site_list = $htdig->sites();

Returns an array listing the names of all the sites in the Site registry.

*get_site
  my $site = $htdig->get_site("default");

Returns an HtDig::Site object corresponding to the string name passed in. Returns undef on failure, such as when the site name is not found in the Site registry.

*add_site
  $htdig->add_site(site_name=>"My Site", conf_path=>"/opt/www/conf/mysite.conf");

Adds a new site to the registry, giving it the name specified in site_name, and using the config file at conf_path. Returns the Site object on success, undef on failure.

*delete_site
  $htdig->delete_site(site_name=>'My Site');

Removes the site specified in site_name from the registry. The config file itself is not removed.

*autodetect
  $htdig->autodetect(paths=>['/users/jtillman/confs/', '/users/bob/htdig'], use_env_path=>1);

Causes the Config object to search the paths specified in paths for .conf files, attempting to add each file found to the registry. If use_env_path is specified, the PATH environment variable is used to search for the htdig executable and the base htdig directory is determined using its location. Then the [base_location]/conf directory is searched for .conf files.

The method also searches /opt/www/conf and /usr/local/htdig/conf by default.

*errstr
  print $htdig->errstr . "\n";

Returns the most recently generated error. The Config object doesn't bother with error numbers, since they would be arbitrary and difficult to track. This may change if demand is high enough for error numbers.

KNOWN ISSUES

*Autodetect isn't very clever or clean. Error reporting could be better, and some attempt should be made to detect which .conf files really are htdig .conf files
*Should get_site require attrib=>value convention? Nearly all the other methods do, even delete_site.

AUTHOR

James Tillman <jtillman@bigfoot.com> CPAN PAUSE ID jtillman

SEE ALSO

HtDig::Site.

perl(1).