MediaWiki extensions manual
Release status: unmaintained
Implementation Hook , Page action
Description Extension to create new pages when links are followed
Author(s) Jim Wilson, JimHu
Latest version 0.2 (2014-10-8)
MediaWiki 1.18+
License MIT License
Example EcoliWiki

Rationale and Features edit

We wanted an easy way to force certain pages to use defined templates based on the structure of the page title. With PagesOnDemand, pages are created from templates when users follow links if the link matches a string comparison that tells the PagesOnDemand system that the desired page is of a desired type. For example, pages with titles that match the regular expression '/^PMID:\\d+$/' are recognized by PagesOnDemand.php (and subsequently PMID_OnDemand.php) as being about articles in the scientific literature. When the system recognizes this pattern, it creates a page based on a template for wiki articles about the scientific literature and then forwards the user to the newly created page, instead of to an edit page. PagesOnDemand effectively makes some "red links" behave like "blue links".

Installing this extension by itself won't affect the wiki in and of itself, instead offloading the real work to modules capable of performing the article insertion. PagesOnDemand hooks at ArticleFromTitle and does the following when a link is clicked:

  • short circuits and returns true if the article already exists
  • provides a hook, PagesOnDemand, that passes the title and article objects to any extensions that hook there (modules).
  • on return, ensures that the user will be forwarded to the article view after any other extensions hooking at ArticleFromTitle have had a chance to run

Two examples of such modules are provided with the distribution. We hope others will write additional modules.

What the modules do edit

Modules should be written to examine the title using a string comparison function to determine whether a page should be created or not. If not, return true. If the module finds a match to the page title, it should generate the desired prepopulation text somehow and create the article. This is demonstated by the DemoOnDemand code: https://github.com/jimhu-tamu/hulab_wiki-extensions/blob/master/PagesOnDemand/DemoOnDemand.php

Status edit

version 0.2 requires 1.18 or later

Works with MediaWiki 1.23

version 0.1:

Tested with MediaWiki 1.8.3 and 1.9.3. Help testing this extension on other versions will be appreciated!

Works with MediaWiki 1.11.0 ---Snuck 01:52, 6 October 2008 (UTC)

Works with MediaWiki 1.19.6

Installation edit

  • Download from https://github.com/jimhu-tamu/hulab_wiki-extensions/archive/master.zip
  • Unpack in your extensions directory. Files included:
    • PagesOnDemand.php - the main extension
    • DemoOnDemand - a demo of how to write new extensions that hook into PagesOnDemand
    • ArticleOnDemand - a means to start an article in the main namespace by planting a seedling of a template or other starting point
    • PMID OnDemand - an extension to create pages for papers in the National Library of Medicine PubMed system, using a template page and PubMed's E-utilities
      • This requires an additional extension for using NCBI's web E-Utilities web services.
  • add
    require_once("$IP" ."/extensions/PagesOnDemand/PagesOnDemand.php");
    to LocalSettings.php , along with require statements for any additional extensions that use PagesOnDemand

Alternatives edit

Inputbox can be used to prepopulate a new page, but it takes you to an edit page, not the page itself. In particular, the Inputbox extension cannot be used to run arbitrary PHP code (the module) to generate the page text.