缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:信息框/用户信息框
刷
历
编
< 模块:信息框
跳到导航
跳到搜索
此模块的文档可以在模块:信息框/用户信息框/doc创建
local infobox = require([[Module:信息框]])
local fstr = mw.ustring.format
local p = {}
local innerNodes = {
{
tag = 'image',
source = 'image',
children = {{tag = 'caption', source = 'caption'}}
},
{
tag = 'data',
source = 'name',
label = '姓名'
},
{
tag = 'data',
source = 'nickname',
label = '昵称'
},
{
tag = 'data',
source = 'status',
label = '身份'
},
{
tag = 'data',
source = 'nationality',
label = '国籍'
},
{
tag = 'data',
source = 'country',
label = '国家'
},
{
tag = 'data',
source = 'location',
label = '目前位置'
},
{
tag = 'data',
source = 'languages',
label = '语言'
},
{
tag = 'data',
source = 'timezone',
label = '时区'
},
{
tag = 'data',
source = 'current_time',
label = '当前时间'
},
{
tag = 'group',
header = '参与的 Wiki',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'wikis',
},
}
},
{
tag = 'group',
header = '基本信息',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'ethnicity',
label = '民族'
},
{
tag = 'data',
source = 'race',
label = '种族'
},
{
tag = 'data',
source = 'gender',
label = '性别'
},
{
tag = 'data',
source = 'wikis',
label = '当前时间'
},
{
tag = 'data',
source = 'height',
label = '身高'
},
{
tag = 'data',
source = 'weight',
label = '体重'
},
{
tag = 'data',
source = 'hair',
label = '发色'
},
{
tag = 'data',
source = 'eyes',
label = '瞳色'
},
{
tag = 'data',
source = 'handedness',
label = '惯用手'
},
{
tag = 'data',
source = 'blood_type',
label = '血型'
},
}
},
{
tag = 'group',
header = '家人和朋友',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'marital_status',
label = '婚姻状况'
},
{
tag = 'data',
source = 'spouse',
label = '配偶'
},
{
tag = 'data',
source = 'girlfriend',
label = '女友'
},
{
tag = 'data',
source = 'boyfriend',
label = '男友'
},
{
tag = 'data',
source = 'children',
label = '儿女'
},
{
tag = 'data',
source = 'siblings',
label = '兄弟姐妹'
},
{
tag = 'data',
source = 'pets',
label = '宠物'
},
}
},
{
tag = 'group',
header = '教育和就业',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'occupation',
label = '职业'
},
{
tag = 'data',
source = 'education',
label = '教育程度'
},
{
tag = 'data',
source = 'primaryschool',
label = '小学'
},
{
tag = 'data',
source = 'midschool',
label = '中学'
},
{
tag = 'data',
source = 'highschool',
label = '高中'
},
{
tag = 'data',
source = 'college',
label = '学院'
},
{
tag = 'data',
source = 'university',
label = '大学'
},
}
},
{
tag = 'group',
header = '爱好、喜爱和信仰',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'hobbies',
label = '爱好'
},
{
tag = 'data',
source = 'religion',
label = '宗教信仰'
},
{
tag = 'data',
source = 'movies',
label = '电影'
},
{
tag = 'data',
source = 'shows',
label = '节目'
},
{
tag = 'data',
source = 'books',
label = '书籍'
},
{
tag = 'data',
source = 'games',
label = '游戏'
},
}
},
{
tag = 'group',
header = '联系方式',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'website',
label = '网站'
},
{
tag = 'data',
source = 'blog',
label = '博客'
},
{
tag = 'data',
source = 'email',
label = '电子邮件'
},
}
},
{
tag = 'group',
header = '账号统计',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = 'account_creation',
label = '建立账号'
},
{
tag = 'data',
source = 'joined_date',
label = '加入本 Wiki'
},
{
tag = 'data',
source = 'first_edit',
label = '首次编辑'
},
{
tag = 'data',
source = 'global_edit_count',
label = '全域编辑数'
},
{
tag = 'data',
source = 'edit_count',
label = '本 Wiki 编辑数'
},
{
tag = 'data',
source = 'permissions',
label = '权限'
},
{
tag = 'data',
source = 'signature',
label = '签名'
},
}
},
}
function p.custominfobox(args)
local customNodes = {}
local childNodes = {}
local generated = {}
if args.custom_data ~= nil then
local customgroup = {}
customgroup.tag = 'data'
customgroup.source = 'custom_data'
table.insert(childNodes,customgroup)
end
for i=1,9 do
local customgroup = {}
local label = 'custom_label'..tostring(i)
local data = 'custom_data'..tostring(i)
if args[data] ~= nil then
customgroup.tag = 'data'
customgroup.source = data
if args[label] ~= nil then
customgroup.label = args[label]
end
table.insert(childNodes,customgroup)
else
break
end
end
if args.custom_header ~= nil then
local customgroup = {}
customgroup.tag = 'group'
customgroup.header = args.custom_header
customgroup.attr = {collapse = 'open'}
customgroup.children = childNodes
table.insert(customNodes,customgroup)
else
customNodes = childNodes
end
for _, n in ipairs(customNodes) do
local child = infobox.genNode(n, args)
if child ~= nil then table.insert(generated, child) end
end
mw.logObject(generated)
return generated
end
-- test: = p.infoboxContent{['装饰值'] = 5, ['装饰半径'] = 1, ['寿命'] = 1}
function p.infoboxContent(args)
local generated = {}
for _, n in ipairs(innerNodes) do
local child = infobox.genNode(n, args)
if child ~= nil then table.insert(generated, child) end
end
return generated
end
function p.main(title, data, raw)
local nodes = {}
local contentNodes = nil
if #data == 1 then
contentNodes = p.infoboxContent(data[1].data)
customNodes = p.custominfobox(data[1].data)
for _, node in ipairs(contentNodes) do table.insert(nodes, node) end
for _, node in ipairs(customNodes) do table.insert(nodes, node) end
else
local panelData = {}
for _, pData in ipairs(data) do
table.insert(panelData, {
label = pData.label,
content = p.infoboxContent(pData.data)
})
end
nodes = {infobox.panel(panelData)}
end
return infobox.infobox(title, nodes, raw)
end
function p.demo(frame)
local getArgs = require('Module:Dev/Arguments').getArgs
local args = getArgs(frame)
return p.main(args['标题'], {{data = args}}, args.raw)
end
return p