Extension:Scribunto/ja

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

使用法
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:

インストール
Scribunto comes with bundled Lua binaries for Linux, Mac Lion and Windows, on Intel 32 and 64 bit platforms. If you have one of these platforms, Scribunto should work for you out of the box.

省略可能なインストール
For a more pleasant user interface, with syntax highlighting and a code editor with autoindent, install the following extensions:


 * Extension:WikiEditor/ja
 * Extension:SyntaxHighlight GeSHi/ja
 * Extension:CodeEditor/ja

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

$wgScribuntoUseGeSHi = true; $wgScribuntoUseCodeEditor = true;

追加のバイナリ
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
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 cd luasandbox phpize ./configure make make install
 * 1) Or  and unpack

トラブルシューティング

 * When using the LuaStandalone engine (this is the default), errors along the lines of "Script error: Lua error: Internal error: The interpreter exited with status 1" may be generated if the standalone Lua interpreter cannot be executed or runs into various runtime errors. To obtain more information, assign a file path to . The interpreter's error output will be logged to the specified file, which should prove more helpful in tracking down the issue.
 * If the above gives you errors such as "version `GLIBC_2.11' not found", it means the version of the standard C library on your system is too old for the binaries provided with Scribunto. You should upgrade your C library, or use a version of Lua 5.1 compiled for the C library you do have installed.
 * If you are getting errors such as "attempt to index field 'text' (a nil value)" when attempting to use the  module, most likely your version of Scribunto is out of date. Upgrade if possible; for advanced users, you might also try to identify the needed newer commits and cherry-pick them into your local installation.

Lua
Lua is a simple programming language intended to be accessible to beginners. For a quick crash-course on Lua, try Learn Lua in 15 Minutes.

The best comprehensive 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, the version used by Scribunto:


 * Programming in Lua (scroll down past the book ads to find the text)

The reference manual is also useful:


 * Extension:Scribunto/Lua reference manual

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

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

注記
The environment which scripts run in is not quite the same as in standard Lua. These differences are noted in Extension:Scribunto/Lua reference manual.

デザインのドキュメント

 * Extension:Scribunto/Parser interface design
 * Extension:Scribunto/Victor's API proposal
 * Extension:Scribunto/Documentation specification
 * Extension:Scribunto/Tim's draft roadmap

その他のページ

 * Extension:Scribunto/Deployment priorities
 * Extension:Scribunto/Brainstorming
 * Lua scripting - Wikimedia activity page describing deployment plan to Wikimedia sites
 * Extension:Scribunto/Lua reference manual - The reference about the Lua language, as well as its standard libraries and common Scribunto modules supported on Wikimedia sites