Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(add p.renderPadlock function) |
(add a p.renderBanner function) |
||
Line 1: | Line 1: | ||
-- This module implements {{pp-meta}} and its daughter templates such as |
-- This module implements {{pp-meta}} and its daughter templates such as |
||
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}. |
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}. |
||
-------------------------------------------------------------------------------- |
|||
-- Configuration |
|||
-------------------------------------------------------------------------------- |
|||
local categories = { |
local categories = { |
||
Line 80: | Line 84: | ||
-- Main functions |
-- 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. |
-- Define often-used functions as local variables. |
||
Line 233: | Line 241: | ||
function p.renderPadlock(data) |
function p.renderPadlock(data) |
||
--[[ |
|||
-- Renders the padlock seen in the top-right-hand corner or protected pages, |
-- Renders the padlock seen in the top-right-hand corner or protected pages, |
||
-- using the data provided in the data table. |
-- 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') |
local root = mw.html.create('div') |
||
root |
root |
||
Line 245: | Line 262: | ||
)) |
)) |
||
return tostring(root) |
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 |
end |
||