Extension:PreviewFunctions

From MediaWiki.org
Jump to navigation Jump to search


MediaWiki extensions manual
OOjs UI icon advanced.svg
PreviewFunctions
Release status: beta
Implementation Parser function
Description Add functions to do special stuff during previews
Author(s) Bawolfftalk
Latest version 2
MediaWiki 1.18+ (possibly earlier too)
License GPLv2
Download Template:WikimediaDownload/svn
Translate the PreviewFunctions extension if it is available at translatewiki.net
Check usage and version matrix.

What can this extension do?[edit]

This extension adds a function {{#onpreview:Text to say during preview|text to say during normal view}} With the intention people could issue warnings about template usage that only appear during preview. Its inspired by how Wikipedians abuse {{REVISIONTIMESTAMP}} (see discussion on rev:100610). It also allows {{#ifpreview:...}} as an alias for #onpreview

Additionally it adds a tag hook <previewwarning>warning here</previewwarning> Which adds a warning to top of preview, in the same manner as how people are warned if they go over $wgExpensiveParserFunctionLimit on a page. It can also take a paramter nodiv to prevent the warning being contained inside a div (Aka <previewwarning nodiv="true">warning here</previewwarning></nowiki>). If one wishes to have template parameters expanded, one must use syntax like {{#tag:previewwarning|warning here involving {{{1}}} }}.

Download instructions[edit]

If you have an svn client installed, checkout the url http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PreviewFunctions Otherwise you may have to download the files individually by hand from that url.

Template:WikimediaDownload/svn

(Note the version listed for 1.19 also works for version 1.18)

Installation[edit]

Download thingy, put it in appropriate place in extensions directory, add line require_once( "$IP/extensions/reviewFunctions/PreviewFunctions.php" ); to bottom of LocalSettings.php

I have tested this extension with MediaWiki 1.18, so it should work on any version of MediaWiki 1.18 or higher. I don't use any particularly new features, so it will also probably work with earlier versions (if they aren't totally ancient), but i haven't tested that at all so ymmv.

Known limitations[edit]

  • previewwarning will strip out any strip markers when used in #tag mode. Hence one cannot use code like {{#tag:previewwarning|Foo <nowiki>bar</nowiki>}}.

See also[edit]