Module:ButtonBox: Difference between revisions
Appearance
forgot an angle bracket |
testing cargo functionality |
||
| Line 2: | Line 2: | ||
function p.buttonbox() | function p.buttonbox() | ||
local | local query = mw.ext.cargo.query( | ||
"avatars", | |||
"name, image, link, label", | |||
{ | { | ||
limit = 100, | |||
orderBy = "name" | |||
} | } | ||
) | |||
local out = {} | |||
table.insert(out, '{| class="buttonbox"') | |||
local out = {} | local out = {} | ||
table.insert(out, '{| class="buttonbox"') | table.insert(out, '{| class="buttonbox"') | ||
for | for i, row in ipairs(query) do | ||
table.insert(out, '|- | if (i - 1) % 4 == 0 then | ||
table.insert(out, '|-') | |||
end | |||
local image = row.image | |||
local label = row.label or row.name | |||
local link = row.link or ("[[User:" .. row.name .. "]]") | |||
local cell = '| <div class="buttonbox-entry">'..image..'<div class="buttonbox-label">'..label..'</div> </div>' | |||
table.insert(out, cell) | |||
end | end | ||
Revision as of 23:01, 23 June 2025
Documentation for this module may be created at Module:ButtonBox/doc
local p = {}
function p.buttonbox()
local query = mw.ext.cargo.query(
"avatars",
"name, image, link, label",
{
limit = 100,
orderBy = "name"
}
)
local out = {}
table.insert(out, '{| class="buttonbox"')
local out = {}
table.insert(out, '{| class="buttonbox"')
for i, row in ipairs(query) do
if (i - 1) % 4 == 0 then
table.insert(out, '|-')
end
local image = row.image
local label = row.label or row.name
local link = row.link or ("[[User:" .. row.name .. "]]")
local cell = '| <div class="buttonbox-entry">'..image..'<div class="buttonbox-label">'..label..'</div> </div>'
table.insert(out, cell)
end
table.insert(out, '|}')
return table.concat(out, '\n')
end
return p