Module:Protection banner: Difference between revisions
add p.renderPadlock function
(try tweaking the order) |
(add p.renderPadlock function) |
||
Line 86: | Line 86: | ||
local tremove = table.remove | local tremove = table.remove | ||
local ceil = math.ceil | local ceil = math.ceil | ||
local format = string.format | |||
local function toTableEnd(t, pos) | local function toTableEnd(t, pos) | ||
Line 229: | Line 230: | ||
end | end | ||
error('No category match found; please define the category for key "all-all-all-all-all"') | error('No category match found; please define the category for key "all-all-all-all-all"') | ||
end | |||
function p.renderPadlock(data) | |||
-- Renders the padlock seen in the top-right-hand corner or protected pages, | |||
-- using the data provided in the data table. | |||
local root = mw.html.create('div') | |||
root | |||
:addClass('metadata topicon nopopups') | |||
:attr('id', 'protected-icon') | |||
:css{display = 'none', right = data.right or '55px'} | |||
:wikitext(format( | |||
'[[Image:%s|20px|link=%s|%s|alt=%s]]', | |||
data.image, data.iconLink, data.iconText, data.altText | |||
)) | |||
return tostring(root) | |||
end | end | ||
return p | return p |