Module:Protection banner: Difference between revisions
Content deleted Content added
add a p.getPagetype function |
add a p.renderImageLink function so that we can share image generation code between the padlock and the banner |
||
Line 258:
end
function p.
--[[
-- Renders the
--
--
-- @parameters:
-- image - the image name
-- size - the image size, as a number
-- link - page linked to by the image
-- text - the tooltip text
-- alt - the alt text
--
-- All parameters are optional apart from the text parameter.
--]]
image = image or 'Transparent.gif'
size = size or 20
if link then
link = '|link=' .. link
else
link = ''
end
text = text or error('No text parameter supplied to p.renderImageLink')
if alt then
alt = '|alt=' .. alt
else
alt = ''
end
return string.format('[[Image:%s|%dpx%s|%s%s]]', image, size, link, text, alt)
end
function p.renderPadlock(image, right)
--[[
-- Renders the html of the padlock seen in the top-right-hand corner
-- of protected pages.
--
--
-- image - the image wikitext
-- right - the "right" css property value, as a string
--
-- Both parameters are optional.
--]]
local root = mw.html.create('div')
Line 274 ⟶ 303:
:addClass('metadata topicon nopopups')
:attr('id', 'protected-icon')
:css{display = 'none', right =
:wikitext(
return tostring(root)
end
function p.renderBanner(
--[[
-- Renders the large protection banner placed at the top of articles,
-- using the data provided in the data table.
--
--
-- page - demo page parameter to pass to {{mbox}}
--
--
--
-- All parameters are optional.
--]]
mMessageBox = require('Module:Message box')
local mbargs = { -- arguments for the message box module
page =
type = 'protection',
image =
text =
}
return mMessageBox.main('mbox', mbargs)
|