Module:Protection banner: Difference between revisions

add a p.renderBanner function
(add p.renderPadlock function)
(add a p.renderBanner function)
Line 1:
-- This module implements {{pp-meta}} and its daughter templates such as
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
 
--------------------------------------------------------------------------------
-- Configuration
--------------------------------------------------------------------------------
 
local categories = {
Line 80 ⟶ 84:
-- Main functions
--------------------------------------------------------------------------------
 
-- Initialise necessary modules.
local mArguments = require('Module:Arguments')
local mMessageBox -- only needs to be loaded if we are outputting a banner, so lazily initialise
 
-- Define often-used functions as local variables.
Line 233 ⟶ 241:
 
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.
--
-- Data fields:
-- data.right
-- data.image
-- data.iconLink
-- data.iconText
-- data.altText
--]]
local root = mw.html.create('div')
root
Line 245 ⟶ 262:
))
return tostring(root)
end
 
function p.renderBanner(data)
--[[
-- Renders the large protection banner placed at the top of articles,
-- using the data provided in the data table.
--
-- Data fields:
-- data.page
-- data.image
-- data.text
--]]
mMessageBox = require('Module:Message box')
local mbargs = { -- arguments for the message box module
page = data.page,
type = 'protection',
image = data.image,
text = data.text
}
return mMessageBox.main('mbox', mbargs)
end