Skip to content

Universal-Omega/AutoCreatePage

Repository files navigation

AutoCreatePage

MediaWiki extension to automatically create pages with a parser function.

The purpose of this is that wiki pages, especially pages that use templates, can trigger the creation of auxiliary pages. This makes most sense when using an extension like Semantic MediaWiki, which can create rich content pages automatically without much user input.

For example, imagine a wiki that has pages about people and pages about projects, where many people can be involved in one project. Then it makes sense to have pages that list all the projects of one person. This can be done automatically with Semantic MediaWiki, but you would still need to create the page first. With this extension, the template that is used for person pages can make sure that also a page with projects of that person is created.

Another example are bi-lingual wikis that use a lot of templates and forms (so many pages consist mainly of data, not of text). Then one can enter data in one language (e.g., create a page in German using a Semantic Form), and the templates used can make sure that the page also exists in another language (e.g., create a page named "{{PAGENAME}}/en" that contains a Semantic MediaWiki template that queries and displays all relevant data, but this time with English labels).

Both of these uses were pioneered by the AIFB Portal Wiki.

Usage

The extension provides one parser function, createpageifnotex that takes a page title and a text to use when creating the page. Example:

{{#createpageifnotex:Test page 1|The content of test page 1}}

Pages are only created if they don't exist yet. The author of the new page is the user who saved the edit to the page that contained the parser function call. Pages are only created when saving an edit, never when viewing a page.

Pages are only created if the parser function is used on a page in one of MediaWiki's content namespaces. Nothing will happen if the parser function is called on, e.g., template pages.

Installation

Download the repository (including the top directory AutoCreatePage) to the extension directory of your MediaWiki installation. You can do this with git by calling:

git clone https://github.com/Universal-Omega/AutoCreatePage.git

from your extension directory. Then add to your LocalSettings.php:

wfLoadExtension( 'AutoCreatePage' );

This extension requires MediaWiki 1.36.0+ to work.

Configuration

The extension supports three configuration variables, that can be set in LocalSettings.php.

$wgAutoCreatePageMaxRecursion: The maximum recursion depth to which calls of createpageifnotex are executed on created pages. Default: 1.

$wgAutoCreatePageIgnoreEmptyContent: If invocations of createpageifnotex should silently ignore missing page content. Default: false (will put an error message on the wiki page).

$wgAutoCreatePageIgnoreEmptyTitle: If invocations of createpageifnotex should silently ignore missing page title. Default: false (will put an error message on the wiki page).

$wgAutoCreatePageNamespaces: The list of namespaces in which calls of createpageifnotex are executed. If your call originates from a page not in one of these namespaces, it gets ignored. Defaults to $wgContentNamespaces. Example:

$wgAutoCreatePageNamespaces = [ NS_MAIN, NS_USER, NS_CUSTOM ];

Status

This code is experimental. Use with care. Internationalization is largely missing.

As of MediaWiki 1.23, the code avoids deprecated functions or hooks. However, it accesses the parser's mStripState member (intended private?) to process nowiki tags. This might have to be replaced by some other approach in the future.

Credits

The original idea and first implementation was done by Daniel Herzig (AIFB). The code was modernized to work with MediaWiki 1.23 by Markus Kroetzsch. The extension was reorganised in order to be converted to ExtensionRegistry by Universal Omega.

The code is licensed under GPLv2.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages