Revision [10238]

This is an old revision of SpellcheckHack made by SpectreMoo on 2005-07-27 23:45:48.

 

Spellcheck Hack for Wiki Pages

Using ASpell and Spellerpages


I find having a spellchecker on the wiki quite useful; here's how I added one:


Steps




	//	this.popUpUrl = '/speller/spellchecker.html';
	//  this.spellCheckScript = '/speller/server-scripts/spellchecker.php';


...to...

	this.popUpUrl = [YOUR HARD-CODED PATH TO SPELLCHECKER.HTML]";
	// 	For Example:  this.popUpUrl = "http://www.notadomain.net/wiki/3rdparty/plugins/speller/spellchecker.html";
	this.spellCheckScript = './server-scripts/spellchecker.php';	// note the '.'


and:

		if( evalText ) {
			this.controlWin.evaluatedText.value = evalText;
			ww.setFocus( this.currentTextIndex, this.currentWordIndex );
			this._getSuggestions( this.currentTextIndex, this.currentWordIndex );
		}


...becomes...

	if( evalText ) {
		// changes to prevent WikiWords from being checked:
		if (evalText.match(/[A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*/) == null)
		{
			this.controlWin.evaluatedText.value = evalText;
			ww.setFocus( this.currentTextIndex, this.currentWordIndex );
			this._getSuggestions( this.currentTextIndex, this.currentWordIndex );
		}
		else
		{
			this.currentWordIndex++;
			this._spellcheck();
		}
	}		




$spellercss = '/speller/spellerStyle.css';
$word_win_src = '/speller/wordWindow.js';
$textinputs = $_POST['textinputs']; # array
$aspell_prog = 'aspell';

...becomes...
$wiki_path = "/wiki/3rdparty/plugins";
$spellercss = $wiki_path.'/speller/spellerStyle.css';
$word_win_src = spellercss = $wiki_path.'/speller/wordWindow.js';
$word_win_src = $wiki_path.'/speller/wordWindow.js';
$textinputs = $_POST['textinputs']; # array
$aspell_prog = 'aspell';   // fine for *nix systems?
# $aspell_prog = '"[PATCH TO ASPELL EXECUTABLE]"';   // required for Windows, replaces previous line




this.addButton(" ");
this.addButton("spell","Check Spelling","","document.getElementById('" + this.id + "')._owner.spellcheck");


...and this at the end of the file, after the closing brace: (line 645 or so):

WikiEdit.prototype.spellcheck = function ()
{
	var speller = new spellChecker();
	speller.checkTextAreas(); 
}



line 142:
	'<script language="JavaScript" src="3rdparty/plugins/speller/spellChecker.js"></script>'."\n".


You need to provide your own "spell" icon to put in 3rdparty/plugins/wikiedit/images -- I used someone's copy of a standard MS application spellcheck action. For testing, you can use any of the included icons, for instance "createtable".

There's probably a way to clean up the wiki paths to use the Wikka config variables, but for me the hard coded paths worked fine.
There are 3 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki