Revision [10218]

This is an old revision of SpectreMoo made by SpectreMoo on 2005-07-25 16:43:36.

 

SpectreMoo


Other Interests:
Biologically inspired computing (GP, NNs, etc.)
Astronomy; mostly reading, I'm no amateur astronomer
Physics
I've installed Wikka to augment our company intranet, and in the process I've made a number of both superficial and functional changes to the code which I plan on posting here when I get the chance.

The biggest enhancement request I've got so far is page anchors; other wikis typically impement them as Wikka Action type things, but ideally each header (e.g., ===Foo===) would become an automatic page anchor. I've implemented markup to add anchors (using {# and #} around an anchor name) which works, but adding it to the headers shouldn't be too difficult. I've already got the $wikka->Link method modified to accept anchor targets in the links.

(Then again, I see now that DotMG has already contributed an AnchorAction... so much for my work! <grin>)
(Ah ha! TableofcontentsAction has copious amounts of information as well.)

I'm going to post some of the hacks I've created here, maybe others will find them useful. Many of the hacks I've written work only within my company intranet environment (auto-linking of java class names to our javadocs, for instance), but anything that's more generally applicable I'll try to post here.

PHP isn't my first language (Java is), but with Wikka's structure, that's not an issue; it's quite easy to modify and expand.

Thank you!





Fortune Action



First off: the latest iteration of my {{fortune}} action:

<?php

    $location = "SOME DEFAULT";    // for example: http://www.textfiles.com/humor/TAGLINES/random.txt

    if (!$vars["location"])
    {
            $lines = file ($location);
    }  
    else
    {
        $location = $vars["location"];

        if ("http" == substr ($location, 0, 4))
        {
            $lines = file ($location);
        }
        else if ($this->IsWikiName ($location))
        {
            if (!$this->ExistsPage ($location))
            {
                echo "<em>The specified page does not exist.</em>";
                return;
            }

            $page = $this->LoadPage ($location);
            if ($page)
            {
                $line = 0;
                $pagelines = explode ("\n", $page["body"]);

                for ($i = 0; $i < count ($pagelines); $i++)
                {
                    if (preg_match ("/[ ~]*-(.*)/",$pagelines[$i],$matches))
                    {
                        $lines[$line++] = $matches[1];
                    }
                }
            }
        }

    }
       
    echo $lines[array_rand ($lines)];
?>


To use, save as fortune.php in the actions directory.

Usage: {{fortune location="URL|WikiPage"}}



Spellchecking wiki pages


I haven't tested this in a "vanilla" wikka installation yet, but I do have it running on my company's intranet wikka wiki, and I find it quite useful.


Steps



	//	this.popUpUrl = '/speller/spellchecker.html';
	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 = '/speller/server-scripts/spellchecker.php';
	this.spellCheckScript = './server-scripts/spellchecker.php';	


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




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 195:
	'<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.

As mentioned above, I can't guarantee that these steps work as presented just yet, but I wanted to get them here before they disappeared. Once I've confirmed that the process works on an "out of the box" wikka install I'll update this page and get rid of all the disclaimers.


CategoryUsers
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki