Jump to content

Extension:Capiunto

本頁使用了標題或全文手工轉換
From mediawiki.org
This page is a translated version of the page Extension:Capiunto and the translation is 100% complete.
MediaWiki扩展手册
Capiunto
发行状态: 稳定版
描述 为Scribunto提供基本信息框功能。
作者 Marius Hoch (Hoo man留言)
兼容性政策 快照跟随MediaWiki发布。 master分支不向后兼容。
MediaWiki 1.25+
数据库更改
许可证 GNU General Public License 2.0 or later
下載
前往translatewiki.net翻譯Capiunto扩展
問題 开启的任务 · 报告错误

Capiunto拉丁語:"它們將包含")擴充功能為Scribunto提供了基本的資訊框功能。

有關Capiunto所提供的Lua方法的概觀,請參閱/Infobox

Capiunto提供Scribunto靈活的資訊框功能,並能針對資訊框的各項功能(例如標題和行)生成HTML程式碼。

Capiunto是專為簡潔現代的資訊框而設計。 採用Lua作為資訊框模板的腳本語言,Lua開發目的就是為了製作資訊框:

  • 簡潔且井然有序
  • 可跨語言版本使用
  • 由維基數據的資料驅動
  • 易於維護與擴充

使用Capiunto Lua程式碼建立一個基本的資訊框,可能如下所示:

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,以验证此扩展已成功安装。

使用範例

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
}}

参阅