Monday, July 23, 2012

Mediawiki AJAX autocomplete Search POB

Here a couple of POB Recipes you can run with Remoto-IT to upgrade your Mediawiki Search functionality so it uses AJAX to autocomplete for case insensitive results. The first is for installing:
#!/bin/bash -e
# mediawiki-autocomplete-search-install.sh

hostname=$1

USAGE="Usage: `basename $0` <mediawikiHome> <titleKeyUrl> <titleKeyFileName>"

if [ $# -ne "3" ] 
then
 echo $USAGE
  exit 1 
fi

mediawikiHome=$1
titleKeyUrl=$2
titleKeyFileName=$3

wget -O "$titleKeyFileName" $titleKeyUrl
tar -xzf $titleKeyFileName -C $mediawikiHome/extensions
The second is for configuring:
#!/bin/bash -e
# mediawiki-autocomplete-search-config.sh

hostname=$1

USAGE="Usage: `basename $0` <mediawikiHome>"

if [ $# -ne "1" ] 
then
 echo $USAGE
  exit 1 
fi

mediawikiHome=$1

sed -i '/$wgEnableMWSuggest/d' $mediawikiHome/LocalSettings.php && sed -i '/TitleKey/d' $mediawikiHome/LocalSettings.php && echo -e 'require_once( "$IP/extensions/TitleKey/TitleKey.php" );' >> $mediawikiHome/LocalSettings.php && echo '$wgEnableMWSuggest = true;' >> $mediawikiHome/LocalSettings.php
cd $mediawikiHome/maintenance/
php update.php 
cd $mediawikiHome/extensions/TitleKey/
php rebuildTitleKeys.php
And here is how to call it. For example suppose your tools.sample.com server has two mediawiki installations like samplewiki and just wiki. Then your host recipe script will look like:
#!/bin/bash -e
#tools.sample.com.sh

common/mediawiki/mediawiki-autocomplete-search-install.sh /var/www/samplewiki http://upload.wikimedia.org/ext-dist/TitleKey-MW1.17-81394.tar.gz TitleKey-MW1.17-81394.tar.gz 
common/mediawiki/mediawiki-autocomplete-search-config.sh /var/www/samplewiki
common/mediawiki/mediawiki-autocomplete-search-config.sh /var/www/wiki

1 comment:

Unknown said...

very useful article, i benefited.. thanks a lot.. :) MediaWiki Tutorial For Beginners

Followers