Module:Protection banner/config: Difference between revisions
(add an indefImageReasons table) |
m (137 revisions imported from wikipedia:Module:Protection_banner/config: see Topic:Vtixlm0q28eo6jtf) |
||
| (63 intermediate revisions by 25 users not shown) | |||
| Line 4: | Line 4: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | |||
-- BANNER DATA | -- BANNER DATA | ||
-- | |||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | --[[ | ||
-- Banner data consists of six fields: | |||
-- * text - the main protection text that appears at the top of protection | |||
-- banners. | |||
-- * explanation - the text that appears below the main protection text, used | |||
-- to explain the details of the protection. | |||
-- * tooltip - the tooltip text you see when you move the mouse over a small | |||
-- padlock icon. | |||
-- * link - the page that the small padlock icon links to. | |||
-- * alt - the alt text for the small padlock icon. This is also used as tooltip | |||
-- text for the large protection banners. | |||
-- * image - the padlock image used in both protection banners and small padlock | |||
-- icons. | |||
-- | |||
-- The module checks in three separate tables to find a value for each field. | |||
-- First it checks the banners table, which has values specific to the reason | |||
-- for the page being protected. Then the module checks the defaultBanners | |||
-- table, which has values specific to each protection level. Finally, the | |||
-- module checks the masterBanner table, which holds data for protection | |||
-- templates to use if no data has been found in the previous two tables. | |||
-- | -- | ||
-- The values in the banner data can take parameters. These are specified | -- The values in the banner data can take parameters. These are specified | ||
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name | -- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name | ||
-- enclosed in curly braces). Available parameters: | -- enclosed in curly braces). | ||
-- | |||
-- Available parameters: | |||
-- | -- | ||
-- ${CURRENTVERSION} - a link to the page history or the move log, with the | -- ${CURRENTVERSION} - a link to the page history or the move log, with the | ||
| Line 18: | Line 41: | ||
-- | -- | ||
-- ${EDITREQUEST} - a link to create an edit request for the current page. | -- ${EDITREQUEST} - a link to create an edit request for the current page. | ||
-- | -- | ||
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes | -- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes | ||
| Line 60: | Line 80: | ||
-- ${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. | |||
--]] | --]] | ||
-- The master banner data, used if no values have been found in banners or | |||
-- defaultBanners. | |||
-- | |||
masterBanner = { | masterBanner = { | ||
text = '${INTROBLURB}', | text = '${INTROBLURB}', | ||
explanation = '${EXPLANATIONBLURB}', | explanation = '${EXPLANATIONBLURB}', | ||
tooltip = '${TOOLTIPBLURB} | tooltip = '${TOOLTIPBLURB}', | ||
link = '${IMAGELINK}', | link = '${IMAGELINK}', | ||
alt = 'Page ${PROTECTIONLEVEL}' | alt = 'Page ${PROTECTIONLEVEL}' | ||
}, | }, | ||
-- The default banner data. This holds banner data for different protection | |||
-- levels. | |||
-- *required* - this table needs edit, move, autoreview and upload subtables. | |||
defaultBanners = { | defaultBanners = { | ||
edit = {}, | edit = {}, | ||
move = {}, | move = {}, | ||
autoreview = { | autoreview = { | ||
default = { | default = { | ||
alt = 'Page protected with pending changes | alt = 'Page protected with pending changes', | ||
tooltip = 'All edits by users | tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users', | ||