Jim Wilson and I have been working on a new extension, which I call
PagesOnDemand that does the following:
Hooks at ArticleFromTitle
Uses a regex to look for a pattern in the requested title
If the title matches the pattern and the page does not already exist,
runs a function to create the desired stub content and saves it
Note that if this runs when a user clicks on a red link, it acts like
a blue link - the user is directed to a view of the brand new page.
Currently, if the user searches for a page that matches the regex,
the extension populates the page if the user clicks the red link in
the search page, or clicks "create this page", but they get the edit
page.
PagesOnDemand is set up so that other extension writers can add
additional regex/content creation combinations. Before I put up a
page in
mediawiki.org, I'd like to check with the experts here about
how I've done a couple of things to let future extensions use
PagesOnDemand:
1) The future extensions would need to register to use a "hook"
inside the PagesOnDemand extension. So I'd like to reserve that hook
name - or whatever the devs want me to name it -within reason ; ) -
within mediawiki. I assume that this would have to be approved by
Brion et al? (I use "hook" in quotes because I'm not using RunHooks
to run the function).
2) To keep the regex and the function together, I've set it up so
that the content creator extensions register by pushing a 2-element
array onto $wgHooks, where the array is (regex, functionName). For
example, to look for page titles that correspond to PubMed IDs (which
is why I wrote it), the creator extension uses:
$wgHooks['PagesOnDemand'][] = array('/^PMID:\\d+
$/','wfPubMedOnDemand') ;
Is this kosher ? Jim W. doesn't like it, but I don't like his
alternative, which is to pass the regex matching to the content
creator. I don't want to distribute the code on
mediawiki.org if it
does something evil. Thanks in advance for advice.
Jim
=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054