Infoboxes are like fact sheets or sidebars in magazine articles; designed to present a summary of the topic of the page. They present important points in an organized and quickly readable format. Infoboxes are generally made using templates, to create consistency across a community.
More infos...
require('Module:No globals')
--local checkType = require('libraryUtil').checkType
--local inspect = require('Module:Inspect').inspect
local TableTools = require('Module:TableTools')
local p = {}
p.Attribute = {
Stacked = {
layout = 'stacked',
},
Collapsible = {
collapse = 'open',
},
Collapsed = {
collapse = 'closed',
},
Horizontal = {
layout = 'horizontal',
},
ShowEmpty = {
show = 'incomplete',
},
}
function p.buildInfobox(...)
local infobox = mw.html.create('infobox')
for i,v in TableTools.sparseIpairs(arg) do
infobox:node(v)
end
return infobox
end
function p.buildPanels(...)
local panels = mw.html.create('panel')
for i,v in TableTools.sparseIpairs(arg) do
panels:node(v)
end
return panels
end
function p.buildPanel(title, ...)
local panel = mw.html.create('section')
if mw.text.trim(title or '') ~= '' then
panel:node(mw.html.create('label'):wikitext(title))
end
for i,v in TableTools.sparseIpairs(arg) do
panel:node(v)
end
return panel
end
function p.buildGroup(title, attributes, ...)
local group = mw.html.create('group')
if attributes then
for i,attribute in TableTools.sparseIpairs(attributes) do
for k,v in pairs(attribute) do
group:attr(k, v)
end
end
end
if mw.text.trim(title or '') ~= '' then
group:node(mw.html.create('header'):wikitext(title))
end
for i,v in TableTools.sparseIpairs(arg) do
group:node(v)
end
return group
end
local function _buildData(type, label, value)
if mw.text.trim(value or '') == '' then
return nil
end
if type ~= 'data' or mw.text.trim(label or '') == '' then
return mw.html.create(type):node(mw.html.create('default'):wikitext(value))
else
return mw.html.create(type):node(mw.html.create('label'):wikitext(label)):node(mw.html.create('default'):wikitext(value))
end
end
function p.buildTitle(value)
return _buildData('title', nil, value)
end
function p.buildImage(value)
if mw.text.trim(value or '') == '' then
return nil
end
if mw.ustring.find(value, '^%[%[File:') and not mw.ustring.find(value, '^%[%[File:Placeholder') then
return _buildData('image', nil, value)
else
return _buildData('data', nil, tostring(mw.html.create('div'):addClass('pi-image'):wikitext(value)))
end
end
function p.buildData(label, value)
return _buildData('data', label, value)
end
return p