Jump to content

扩展:Capiunto

From mediawiki.org
This page is a translated version of the page Extension:Capiunto and the translation is 35% complete.
MediaWiki扩展手册
Capiunto
发行状态: 稳定版
描述 为Scribunto提供基本信息框功能。
作者 Marius Hoch (Hoo man留言)
兼容性政策 快照跟随MediaWiki发布。 master分支不向后兼容。
MediaWiki 1.25+
数据库更改
许可协议 GNU通用公眾授權條款2.0或更新版本
下載
季度下載量 34 (Ranked 103rd)
前往translatewiki.net翻譯Capiunto扩展
問題 开启的任务 · 报告错误

The Capiunto (Latin: "they shall contain") extension provides a basic Infobox functionality for Scribunto.

An overview of the Lua methods which Capiunto provides can be found at /Infobox.

Capiunto provides flexible Infobox functionality for Scribunto and generates HTML for Infobox features such as headers and rows.

Capiunto is designed for clean and modern Infoboxes. Using Lua as a scripting language for Infobox templates, it was developed to make Infoboxes:

  • clean and clutter-free
  • usable across different language versions
  • driven by data from Wikidata
  • easy to maintain and extend

With Capiunto Lua code to create a basic Infobox might look like this:

local capiunto = require 'capiunto'
capiunto.create( {
	title = 'Title of the Infobox'
} )
:addRow( 'A label', 'some data' )
:addHeader( 'A header between the data rows' )
:addRow( 'Another label', 'more data' )

条件

Capiunto依赖于Scribunto扩展。

安裝

  • 下载文件,并将解压后的Capiunto文件夹移动到extensions/目录中。
    开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Capiunto
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'Capiunto' );
    
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。

Example usage

Module
(Module:CapiuntoTest)
Template
(Template:CapiuntoTest)
Article
local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local headerStyle
	if args.headerstyle and args.headerstyle ~= '' then
		headerStyle = string.format('background-color:%s;', args.headerstyle)
	else
		headerStyle = 'background-color:grey;'
	end
	local retval = capiunto.create( {
		title = args.title,
		headerStyle = headerStyle, 
	} )
	:addImage( args.image, args.caption )
	:addRow( 'Foo', args.foo )
	:addHeader( 'A header between the data rows' )
	:addRow( 'Bar', args.bar )
	return retval
end

return p
<includeonly>{{#invoke:CapiuntoTest|main}}</includeonly>
{{CapiuntoTest
| title       = The title
| headerstyle = (defaults to background-color:grey)
| image       = [[File:Example.svg|200px]]
| caption     = An example image
| foo         = Something
| ("A header between the data rows")
| bar         = Something else
}}

参见