UseModWiki | RecentChanges | Preferences

I think the objective of this is to avoid entirely modifications to wiki.pl. Is this a feasible possibility?. Say I write a patch (I will) to have an input text field that takes valid wiki pagenames and brings you directly to that page (sort of like the search).

We could have somewhere in wiki.pl a line such as

 if $WikiPlugins?==1 do ('wikiplugins.pl') 
or something similar so that wiki.pl doesn't need to be changed. But now how do we put the text field on the page? We have to modify BrowseCode or GetGotoBar or something else. Is there another feasible strategy?

-- ElMoro

In the current implementation there are only two ways to do this, (correct me if I am wrong, somebody), and one is a bit naughty as it means using an file for a previously unintended purpose.

The naughty way would be to put the code to call plugins into the config file.

The clean way is to load UseModWiki from a wrapper, with $_ set to inhibit the code from running, then do your plugin, then run &UseModWiki::DoWikiRequest. The wrapper then is what gets put into the web cgi-bin space for the user to load.

    # simple example wrapper to load plugin then run DoWikiRequest
    # adapted from an example by CliffordAdams
    $_ = 'nocgi';  # Do not run script immediately when loaded
    require "/full/path/from/root/to/code/dir/wiki.pl";
    do      "/full/path/from/root/to/code/dir/wikiplugins.pl";
    &UseModWiki::DoWikiRequest();  # Do the request
The require line will declare the variables and set the values that are set outside any of the subs in UseModWiki, but will not actually call DoWikiRequest as $_ is explicitly tested for the value 'nocgi'.

The file wikiplugins can then refer to any UseModWiki variable as required. It can even run any UseModWiki subs, with the same syntax as is used to call DoWikiRequest above.

Other methods would depend on CliffordAdams liking the idea of plugins enough to facilitate them in a future release.

One simple option would be for wiki.pl to "do" a standard file that loaded plugins. Or to run every sub in an array @PlugIns?. Even more simply, the documentation could explicitly invite the use of the config file to load plugins, which then would no longer be naughty!

But my guess is that, as the wrapper approach already allows us to do anything we want between loading the variables and calling DoWikiRequest, that is probably a better approach than introducing new complexity into wiki.pl - if I were Cliff I'd be reluctant to write new code to allow people to do what the wrapper already allows.

OddMuse (one of the UseModDescendant) has an nice modules system. Maybe someone could take a closer look and backport it. See OddMuse:Modules for details. --TilmannHolst, 2004-05-22

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited February 3, 2005 12:08 am by user-10cmeae.cable.mindspring.com (diff)