Extension:HtdigSearch

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
HtdigSearch

Release status: stable

HtdigSearch.png
Implementation Special page
Description ht:/Dig integration
Author(s) Cchanteptalk
Latest version 1.1-SNAPSHOT (2010-08-04)
MediaWiki 1.11.x to 1.16.0
License No license specified
Download here
Example example 1,
example 2
Hooks used
ArticleSaveComplete

Translate the HtdigSearch extension if possible

Check usage and version matrix; code metrics

What can this extension do?[edit | edit source]

This extension allow to integrate ht:/Dig search in your wiki. This special page acts as a mediawiki proxy on configured htsearch CGI url.

Usage[edit | edit source]

Download instructions[edit | edit source]

You can download HtdigSearch extension from there.

Installation[edit | edit source]

To install this extension, put HtdigSearch in your extensions directory, then add the following to LocalSettings.php:

require_once( "$IP/extensions/HtdigSearch/HtdigSearch.setup.php" );

Ajust values on HtdigSearch/HtdigSettings.php file :

<?php
/**
 * Site relative url to htsearch CGI
 */
$htsearchUrl = '/htsearch';
 
/**
 * Configuration to be used by htsearch (see htsearch 'config' param)
 */
$htsearchConf = 'myHtdigConf';
 
/**
 * Wiki text before search content
 */
$wikiTextBefore = NULL;
 
/**
 * Wiki text after search content
 */
$wikiTextAfter = NULL;
?>

You can verify installation opening wiki page Special:HtdigSearch .

Configuration parameters[edit | edit source]

See HtdigSearch/HtdigSettings.php

fopen for url should be enabled in your php.ini.

Encoding issue[edit | edit source]

ht:/Dig only supports iso-8859-1 charset, if your wiki is made with another one you will have to add accept-charset="iso-8859-1" attribute to your search form tag :

...
<form method="get" action="/index.php/Special:HtdigSearch" accept-charset="iso-8859-1">
...
</form>
...
See also 
ht:/Dig utf8 workaround (internal handler) (based on iconv and some unix stuff)

Incremental update (HtdigUpdate)[edit | edit source]

With HtdigUpdate code (added to this extension — 2008-11-19), you can make your ht:/Dig update be updated as soon as you make a new revision of an article. As LocalSettings.php is concerned you just have to uncomment HtdigUpdate line from provided sample LocalSettings.part.

You also have to check parameters htdigConfdir, htdigConfSuffix and htdigProgPath in extension configuration file HtdigSettings.php.

Main job about that is to ensure apache user (user that run apache server), has proper rights to execute htdig program, and to write ht:/Dig database. You can check it, before having activated HtdigUpdate, under unix with following commands (with «apache» as apache user, «/etc/htdig/my.wiki.conf» your ht:/Dig site configuration file, and «http://my.wiki.com/index.php/MyArticle» an article changed after last ht:Dig database update) :

# su -s /bin/bash apache
# echo 'http://my.wiki.com/index.php/MyArticle' | htdig -c '/etc/htdig/my.wiki.conf' -m -

If you get following error «htdig: Unable to open/create document database», you need you check right granted to apache user on ht:/Dig database files are sufficient (ht:/Dig database directory path should be set in htdig.conf or in your ht:/Dig site configuration file). In this case you will probably want to run commands such as following, in order to fix permissions (with «/var/htdig/my.wiki.com» path to your ht:/Dig database directory):

# chgrp apache /var/htdig/my.wiki.com/db.*
# chmod g+w /var/htdig/my.wiki.com/db.*

You could also have permission trouble about htdig program himself, if not executable by apache user, or about program(s) you set as handler (external_handler) in your ht:/Dig configuration file. If you see such error («xxx: Permission denied») running tests commands (see at beginning of this section), you will need to chmod it to allow execute by apache user (chmod +x).

Daily update/database optimisation[edit | edit source]

Even if use incremental update provided by HtdigUpdate code, it's strongly recommanded to recheck periodically your whole ht:/Dig database.

  • If you don't use incremental update such periodic task you update database.
  • If you use incremental update periodic recheck will clean obselete document from index and optimize database.

This can be performed using a cron script, or things like that. If you traditionnal /etc/cron.daily place, you can put under it a script like following :

#! /bin/sh

HTDIGCMD="/path/to/your/htdig"

HTDIG_OPTS="-v -s -c /path/to/your/htdig/site.conf"

"$HTDIGCMD" $HTDIG_OPTS