Revision [14091]
This is an old revision of SpellcheckHack made by SpectreMoo on 2006-05-03 20:40:20.
Spellcheck Hack for Wiki Pages
Using ASpell and SpellerpagesAdding spell checking to your wiki pages isn't very difficult, here's how I did it:
Steps
- Download and install GNU ASpell and an ASpell dictionary from http://aspell.net/ if it isn't already installed (e.g., you're running Windows).
- Download and unpack spellerpages from http://spellerpages.sourceforge.net/ -- put these files in wiki/3rdparty/plugins/speller.
- Make the following changes to the spellerpages files:
- In spellChecker.js:
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(); } }
- In speller/server-scripts/spellchecker.php:
$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 = $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
- Make this change around line 108 of wiki/3rdparty/plugins/wikiedit/wikiedit2.js:
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(); }
- Finally change wiki/handlers/page/edit.php:
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.
CategoryUserContributions