Module:Protection banner/config: Difference between revisions

add more comments; explain functions in the banner config and what some of the other config tables do
en>Mr. Stradivarius
(add more comments)
en>Mr. Stradivarius
(add more comments; explain functions in the banner config and what some of the other config tables do)
Line 83: Line 83:
-- ${VANDAL} - links for the specified username (or the root page name)
-- ${VANDAL} - links for the specified username (or the root page name)
-- using Module:Vandal-m.
-- using Module:Vandal-m.
--
--                                Functions
--
-- For advanced users, it is possible to use Lua functions instead of strings
-- in the banner config tables. Using functions gives flexibility that is not
-- possible just by using parameters. Functions take two arguments, the
-- protection object and the template arguments, and they must output a string.
--
-- For example:
--
-- text = function (protectionObj, args)
--    if protectionObj.level == 'autoconfirmed' then
--        return 'foo'
--    else
--        return 'bar'
--    end
-- end
--
-- Some protection object properties and methods that may be useful:
-- protectionObj.action - the protection action
-- protectionObj.level - the protection level
-- protectionObj.reason - the protection reason
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set
--    to indefinite, and the protection time in unix time if temporary.
-- protectionObj.protectionDate - the protection date in unix time, or nil if
--    unspecified.
-- protectionObj.bannerConfig - the banner config found by the module. Beware
--    of editing the config field used by the function, as it could create an
--    infinite loop.
-- protectionObj:isProtected - returns a boolean showing whether the page is
--    protected.
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is
--    temporary.
-- protectionObj:isIncorrect - returns a boolean showing whether the protection
--    template is incorrect.
--]]
--]]


Line 118: Line 153:
-- In fact, the reasons specified in this table control which reasons are
-- In fact, the reasons specified in this table control which reasons are
-- valid inputs to the first positional parameter.
-- valid inputs to the first positional parameter.
--
-- There is also a non-standard "description" field that can be used for items
-- in this table. This is a description of the protection reason for use in the
-- module documentation.
--
-- *required* - this table needs edit, move, and autoreview subtables.
-- *required* - this table needs edit, move, and autoreview subtables.
banners = {
banners = {
Line 329: Line 369:
autoreview = {}
autoreview = {}
},
},
--------------------------------------------------------------------------------
--
--                            GENERAL DATA TABLES
--
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 334: Line 380:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- This table produces the protection blurbs available with the
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and
-- protection level, and is checked by the module in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, and autoreview subtables.
-- *required* - this table needs edit, move, and autoreview subtables.
protectionBlurbs = {
protectionBlurbs = {
Line 365: Line 419:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- This table produces the explanation blurbs available with the
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,
-- protection level, and whether the page is a talk page or not. If the page is
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk
-- key of "subject". The table is checked in the following order:
-- 1. page's protection action, page's protection level, page's talk key
-- 2. page's protection action, page's protection level, default talk key
-- 3. page's protection action, default protection level, page's talk key
-- 4. page's protection action, default protection level, default talk key
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, and autoreview subtables.
-- *required* - this table needs edit, move, and autoreview subtables.
explanationBlurbs = {
explanationBlurbs = {
Line 452: Line 517:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which
-- produces a short label for different protection levels. It is sorted by
-- protection action and proteciton level, and is checked in the following
-- order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, and autoreview subtables.
-- *required* - this table needs edit, move, and autoreview subtables.
protectionLevels = {
protectionLevels = {
Line 470: Line 544:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- *required* - this table needs edit, move, and autoreview subtables.
-- This table lists different padlock images for each protection action and
-- protection level. It is used if an image is not specified in any of the
-- banner data tables, and if the page does not satisfy the conditions for using
-- the ['image-filename-indef'] image. It is checked in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
images = {
images = {
edit = {
edit = {
Anonymous user