Extension:Capiunto/Infobox/Basic usage

From MediaWiki.org
Jump to navigation Jump to search

Capiunto is a MediaWiki extension based on Scribunto allowing to write flexible Infoboxes. For Capiunto a basic knowledge of Lua is necessary. To read up on Lua the Lua for beginners Help page or MediaWiki Lua reference manual is useful.

Create an Infobox module[edit]

A Lua module is needed in order to set up an Infobox with Capiunto. This way you will be able to keep for example a certain design and structure and just pass data to the module which can be useful in various situations. For a complete documentation see Extension:Capiunto/Infobox.

Setting options for capiunto.create[edit]

You have different options for styling your Infobox and setting some basic options in this step. You can get an overview here. The attributes are based on CSS therefore it allows easy changing styles of every element of the Infobox. Via the title variable a title for the Infobox can be set. The Lua function mw.title.getCurrentTitle() can be used to set the title of the Page as the title of the Infobox.

capiunto.create( {
	-- …
	title = tostring(mw.title.getCurrentTitle())
	-- …
} )

Another example is setting the borders of a infobox's body to 10 pixels' thickness and color red with bodyStyle = 'border: 10px solid red' It is possible to change most of the styling of the infoboxes this way if wanted but there are also very convenient defaults.

Example of the usage of Capiunto

Adding data to the Infobox[edit]

Adding data to the Infobox is rather simple. With the help of

:addRow( label, data )

it's possible to add a new Row to the Infobox with a label and data.

In the example below, three chemical elements and their symbols are being added to the Infobox. This data is static and can't be changed from outside the module.

To add data to the rows when the module is called, the module could have arguments passed when invoked.

Example of the usage of Capiunto using the image File:Keyhole Nebula - Hubble 1999.jpg

The same way it's possible to add images, header, subheader and similar. An overview can be found at Extension:Capiunto/Infobox#capiunto:getHtml. This makes it possible to use templates with arguments and thereby define a style, change that style and add data as needed.

Using the Infobox module[edit]

To use the Infobox modul, you have to go to the page where you want to use the module and depending on whether you have parameters, that you give the module invoke it this way;