Extension:Scribunto

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Scribunto

Release status: beta

Implementation Parser extension
Description Framework for embedding scripting languages into MediaWiki pages
Author(s) Victor & Tim (Tim Starlingtalk)
MediaWiki 1.20 and up (check out the REL1_20 branch for support with 1.20, but note it lacks some features)
License No license specified
Download
Example Test2 Wikipedia
Namespace Module
Check usage and version matrix
Bugs: list open list all report

Scribunto (Latin: "they shall write") is an extension for embedding scripting languages in MediaWiki. Currently the only supported scripting language is Lua.

To help: translate the namespace name "Module".

Contents


Usage [edit]

Scripts are contained within a new namespace called "Module". Each module has a collection of functions, and the functions can be called using wikitext syntax such as:

{{#invoke: Module_name | function_name | arg1 | arg2 | arg3 ... }}

Installation [edit]

Scribunto comes with bundled Lua binaries for Linux and Windows, on Intel 32 and 64 bit platforms. If you have one of these two platforms, Scribunto should work for you out of the box.

  • Download and extract the files in a directory called "Scribunto" in your extensions/ folder.
  • Add the following code to your LocalSettings.php (at the bottom)
require_once( "$IP/extensions/Scribunto/Scribunto.php" );
$wgScribuntoDefaultEngine = 'luastandalone';
  • Yes check.svg Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


For a more pleasant user interface, with syntax highlighting and a code editor with autoindent, install the following extensions:

Then in your LocalSettings.php after all the extension registrations, add:

$wgScribuntoUseGeSHi = true;
$wgScribuntoUseCodeEditor = true;

Additional binaries [edit]

Additional Lua binaries can be obtained from http://luabinaries.sourceforge.net/ or from your Linux distribution. Only Lua 5.1.x is supported. Configure the location of the binary file with:

$wgScribuntoEngineConf['luastandalone']['luaPath'] = '/path/to/lua';

LuaSandbox [edit]

We have developed an extension to PHP written in C called LuaSandbox. It can be used as an alternative to the standalone binaries, and will provide improved performance. To install it, install the headers and library files for either Lua 5.1.x or LuaJIT 1.1.x, as well as PHP, then run:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/php/luasandbox.git
# Or download a snapshot and unpack

cd luasandbox
phpize
./configure
make
make install

Lua [edit]

Lua is a simple programming language intended to be accessible to beginners. The best introduction to Lua is the book Programming in Lua. The first edition (for Lua 5.0) is available online and is mostly relevant to Lua 5.1 used by Scribunto:

The reference manual is also useful:

Lua environment [edit]

In Lua, the set of all global variables and functions is called an environment.

Each {{#invoke:}} call runs in a separate environment. Variables defined in one {{#invoke:}} will not be available from another. This restriction was necessary to maintain flexibility in the wikitext parser implementation.

Note [edit]

The environment which scripts run in is not quite the same as in standard Lua. These differences are noted in /Lua reference manual#Differences from standard Lua.

Design documents [edit]

Other pages [edit]