Module:Check blp parameter/sandbox
Appearance
From Wikipedia, the free encyclopedia
Warning This Lua module is used on approximately 2,630,000 pages, or roughly 4% of all pages .
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
[画像:Ready for use] This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
Usage
[edit ]This module is used by Template:WikiProject Biography to check for issues with the |blp=
, |BLP=
and |living=
parameters.
The above documentation is transcluded from Module:Check blp parameter/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
require('strict') local p = {} p.main = function(frame) local args = frame:getParent().args local yesno = require('Module:Yesno') local current_title = mw.title.getCurrentTitle() local pagetype = require('Module:Pagetype')._main{page = current_title.prefixedText, defaultns = "extended"} if pagetype=='user page' or args.category=='no' then -- bot does not run on user talk namespace return '' end local templates = mw.loadData('Module:WikiProject banner/config').banner_shell.redirects local getparam = function(p) local TPVmodule = require('Module:Template parameter value').getParameter local success, param = TPVmodule(current_title.fullText, templates, p, {ignore_subtemplates=true, ignore_blank=true}) return success and param or nil end local check = function(p_table) local conflict = false local resolved for _, p in pairs(p_table) do local yn = yesno(p) -- check if "other" or "activepol" are set if p=='activepol' then yn = true -- activepol are living elseif p=='other' then yn = false -- other is treated as non-living end if yn==true or yn==false then -- parameter is set if resolved==nil then -- no resolved status yet resolved = yn -- resolve to parameter elseif yn~=resolved then -- resolved differs from parameter conflict = true end end end return resolved, conflict end local conflict, shell_resolved, bio_resolved, resolved shell_resolved, conflict = check({getparam('blp'), getparam('living')}) if not conflict then bio_resolved, conflict = check({args.blp, args.living, args.BLP}) if not conflict then resolved, conflict = check({shell_resolved, bio_resolved}) end end local out if conflict then elseif shell_resolved==nil then if bio_resolved==nil then if pagetype=='article' then out = 'Biography articles without living parameter' end else out = 'Pages using WikiProject Biography which need living parameter transferring' end end return out and '[[Category:' .. out .. ']]' or '' end return p