Jump to content

Module:Protection banner/config: Difference between revisions

use a new approach to the banner config, allowing more fine-grained control and less hopping around between parameter definitions
m (add some missing full stops)
(use a new approach to the banner config, allowing more fine-grained control and less hopping around between parameter definitions)
Line 1: Line 1:
-- This module provides configuration data for [[Module:Protection banner]].
-- This module provides configuration data for [[Module:Protection banner]].


local cfg, msg = {}, {}
local cfg = {}
 
--------------------------------------------------------------------------------
-- Banner data
--------------------------------------------------------------------------------
 
--[[
-- The following banner data fields are available:
-- text, explanation, tooltip, alt, image, category
--
-- When the module is asked to retrieve one of these data fields, it looks in
-- the cfg.bannerData table. It uses five properties in its search:
-- 1. the expiry date
-- 2. the namespace
-- 3. the protection reason (e.g. "dispute" or "vandalism")
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")
-- 5. the action (e.g. "edit" or "move")
--
-- For each data field, the module will check to see if the field exists in the
-- table with the key corresponding to all five parameters. For example, a
-- user page semi-protected from vandalism for two weeks would have the key
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module
-- changes the first part of the key to "all" and checks the table again. It
-- keeps checking increasingly generic key combinations until it finds the
-- field, or until it reaches the key "all-all-all-all-all".
--
-- This makes it possible to specify fine-grained distinctions in banner text.
-- For example, data defined for the key "all-user-vandalism-all-edit" can be
-- used for user pages that are protected either temporarily or permanently,
-- and either fully protected or semi-protected, but it won't be used for
-- articles or for pages protected against sockpuppetry.
--
-- Note that the fields don't have to be in the same table. A given banner
-- might use text from "temp-user-vandalism-autoconfirmed-edit" but a
-- category from "all-all-vandalism-all-edit".
--
-- The module uses a binary matrix to determine the order in which to search.
-- This is best demonstrated by a table. In this table, the "0" values
-- represent "all", and the "1" values represent the original data (e.g.
-- "indef" or "file" or "vandalism").
--
--        expiry    namespace reason  level    action
-- order
-- 1      1        1        1        1        1
-- 2      0        1        1        1        1
-- 3      1        0        1        1        1
-- 4      0        0        1        1        1
-- 5      1        1        0        1        1
-- 6      0        1        0        1        1
-- 7      1        0        0        1        1
-- 8      0        0        0        1        1
-- 9      1        1        1        0        1
-- 10    0        1        1        0        1
-- 11    1        0        1        0        1
-- 12    0        0        1        0        1
-- 13    1        1        0        0        1
-- 14    0        1        0        0        1
-- 15    1        0        0        0        1
-- 16    0        0        0        0        1
-- 17    1        1        1        1        0
-- 18    0        1        1        1        0
-- 19    1        0        1        1        0
-- 20    0        0        1        1        0
-- 21    1        1        0        1        0
-- 22    0        1        0        1        0
-- 23    1        0        0        1        0
-- 24    0        0        0        1        0
-- 25    1        1        1        0        0
-- 26    0        1        1        0        0
-- 27    1        0        1        0        0
-- 28    0        0        1        0        0
-- 29    1        1        0        0        0
-- 30    0        1        0        0        0
-- 31    1        0        0        0        0
-- 32    0        0        0        0        0
--
-- In this scheme the action has the highest priority, as it is the last
-- to change, and the expiry has the least priority, as it changes the most.
-- The priorities of the expiry, the protection level and the action are
-- fixed, but the priorities of the reason and the namespace can be swapped
-- through the use of the cfg.bannerDataNamespaceHasPriority table.
--
--
--                          PARAMETERS
--
-- The values in the banner data can take parameters. These are specified
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name
-- enclosed in curly braces). Available parameters:
--
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".
-- Defined in the cfg.pagetypes table.
--
--
--]]
 
cfg.bannerDataNamespaceHasPriority = {
-- If the reason specified to the template is listed in this table,
-- namespace data will take priority over reason data in the bannerData
-- table.
vandalism = true,
}
 
cfg.bannerDataNamespaceKeys = {
-- The string to use as a namespace key for bannerData for each
-- namespace number.
[  2] = 'user',
[  3] = 'user',
[  4] = 'project',
[  6] = 'file',
[ 10] = 'template',
[ 12] = 'project',
[ 14] = 'category',
[100] = 'portal',
}
 
cfg.bannerData = {
-- The key strings follow this format:
-- type, level, ns, reason, expiry
['all-all-all-all-all'] = {
text = '',
explanation = '',
tooltip = '',
alt = '',
category = 'Wikipedia protected pages',
},
['all-all-office-all-all'] = {
category = 'Wikipedia Office-protected pages',
},
['all-all-reset-all-all'] = {
category = 'Wikipedia Office-protected pages',
},
['all-template-all-all-edit'] = {
category = 'Wikipedia protected templates',
},
['all-all-all-autoconfirmed-edit'] = {
category = 'Wikipedia semi-protected pages',
},
['indef-all-all-autoconfirmed-edit'] = {
category = 'Wikipedia indefinitely semi-protected pages',
},
['all-all-blp-autoconfirmed-edit'] = {
category = 'Wikipedia indefinitely semi-protected biographies of living people',
},
['temp-all-blp-autoconfirmed-edit'] = {
category = 'Wikipedia temporarily semi-protected biographies of living people',
},
['all-all-dispute-autoconfirmed-edit'] = {
category = 'Wikipedia pages semi-protected due to dispute',
},
['all-all-sock-autoconfirmed-edit'] = {
category = 'Wikipedia pages semi-protected from banned users',
},
['all-all-vandalism-autoconfirmed-edit'] = {
category = 'Wikipedia pages semi-protected against vandalism',
},
['all-category-all-autoconfirmed-edit'] = {
category = 'Wikipedia semi-protected categories',
},
['all-file-all-autoconfirmed-edit'] = {
category = 'Semi-protected images',
},
['all-portal-all-autoconfirmed-edit'] = {
category = 'Semi-protected portals',
},
['all-project-all-autoconfirmed-edit'] = {
category = 'Semi-protected project pages',
},
['all-talk-all-autoconfirmed-edit'] = {
category = 'Semi-protected talk pages',
},
['all-template-all-autoconfirmed-edit'] = {
category = 'Wikipedia semi-protected templates',
},
['all-template-all-autoconfirmed-edit'] = {
category = 'Wikipedia semi-protected templates',
},
['all-user-all-autoconfirmed-edit'] = {
category = 'Wikipedia semi-protected user and user talk pages',
},
['all-all-blp-sysop-edit'] = {
category = 'Wikipedia indefinitely protected biographies of living people',
},
['temp-all-blp-sysop-edit'] = {
category = 'Wikipedia temporarily protected biographies of living people',
},
['all-all-dispute-sysop-edit'] = {
category = 'Wikipedia pages protected due to dispute',
},
['all-all-sock-sysop-edit'] = {
category = 'Wikipedia pages protected from banned users',
},
['all-all-vandalism-sysop-edit'] = {
category = 'Wikipedia pages protected against vandalism',
},
['all-category-all-sysop-edit'] = {
category = 'Wikipedia protected categories',
},
['all-file-all-sysop-edit'] = {
category = 'Protected images',
},
['all-project-all-sysop-edit'] = {
category = 'Protected project pages',
},
['all-talk-all-sysop-edit'] = {
category = 'Protected talk pages',
},
['all-template-all-sysop-edit'] = {
category = 'Wikipedia protected templates',
},
['all-user-all-sysop-edit'] = {
category = 'Wikipedia protected user and user talk pages',
},
['all-all-all-sysop-move'] = {
category = 'Wikipedia move-protected pages',
},
['indef-all-all-sysop-move'] = {
category = 'Wikipedia indefinitely move-protected pages',
},
['all-all-dispute-sysop-move'] = {
category = 'Wikipedia pages move-protected due to dispute',
},
['all-all-vandalism-sysop-move'] = {
category = 'Wikipedia pages move-protected due to vandalism',
},
['all-portal-all-sysop-move'] = {
category = 'Wikipedia move-protected portals',
},
['all-portal-all-sysop-move'] = {
category = 'Wikipedia move-protected portals',
},
['all-project-all-sysop-move'] = {
category = 'Wikipedia move-protected project pages',
},
['all-talk-all-sysop-move'] = {
category = 'Wikipedia move-protected talk pages',
},
['all-template-all-sysop-move'] = {
category = 'Wikipedia move-protected templates',
},
['all-user-all-sysop-move'] = {
category = 'Wikipedia move-protected user and user talk pages',
},
['all-all-all-autoconfirmed-autoreview'] = {
category = 'Wikipedia pending changes protected pages (level 1)',
},
['all-all-all-reviewer-autoreview'] = {
category = 'Wikipedia pending changes protected pages (level 2)',
},
}


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 35: Line 283:
-- $17 = Deletion log link
-- $17 = Deletion log link
-- $18 = The explanation text, based on the protection action and level.
-- $18 = The explanation text, based on the protection action and level.
--


cfg.defaultBanners = {
cfg.defaultBanners = {
Line 165: Line 415:
image = 'Padlock-black.svg',
image = 'Padlock-black.svg',
categoryOrder = 'reason',
categoryOrder = 'reason',
categoryReason = 'office',
}
}


Line 264: Line 513:
['all-all-all-all-all']                  = 'Wikipedia protected pages',
['all-all-all-all-all']                  = 'Wikipedia protected pages',
['all-all-all-office-all']              = 'Wikipedia Office-protected pages',
['all-all-all-office-all']              = 'Wikipedia Office-protected pages',
['all-all-all-reset-all']                = 'Wikipedia Office-protected pages',
['edit-all-template-all-all']            = 'Wikipedia protected templates',
['edit-all-template-all-all']            = 'Wikipedia protected templates',
['edit-autoconfirmed-all-all-all']      = 'Wikipedia semi-protected pages',
['edit-autoconfirmed-all-all-all']      = 'Wikipedia semi-protected pages',
Line 309: Line 559:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


cfg.categoryPagetypes = {
cfg.pagetypes = {
[2] = 'user',
[3] = 'user',
[4] = 'project',
[6] = 'file',
[10] = 'template',
[12] = 'project',
[14] = 'category',
[100] = 'portal',
}
 
cfg.bannerPagetypes = {
[0] = 'article',
[0] = 'article',
[6] = 'file',
[6] = 'file',
Line 345: Line 584:
--  
--  
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local msg = {}


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Cookies help us deliver our services. By using our services, you agree to our use of cookies.