Module:Class mask: Difference between revisions

Content deleted Content added
new logic for b-class checklist parameters, mask will not autodemote or promote unless the whole checklist is completed
m Changed protection settings for "Module:Class mask": most less used now (although number of transclusions has not caught up) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
 
(5 intermediate revisions by the same user not shown)
Line 20:
 
local resolveFQSgrade = function(grade, args)
if (args[grade] or args.FQS) == 'yes' then
return ucfirst(grade)
else
Line 27:
end
 
local resolveDefaultGradep._main = function(args, title, talkDefault)
title = title or mw.title.getCurrentTitle()
if title.subjectPageTitle.isRedirect then
local out = ''
return resolveFQSgrade('redirect',args)
local grade = args[1]
end
if not grade or grade=='¬' then -- undefined
local ns = title.namespace
out = '¬'
if ns==1 then -- Talk
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
return resolveFQSgrade('disambig',args)
else
return talkDefault
end
elseif ns==7 or ns==711 then -- File talk
return resolveFQSgrade('file', args)
elseif ns==15 then -- Category talk
return resolveFQSgrade('category', args)
elseif ns==101 then -- Portal talk
return resolveFQSgrade('portal', args)
elseif ns==11 or ns==829 then -- Template talk
return resolveFQSgrade('template', args)
elseif ns==5 then -- Wikipedia talk
return resolveFQSgrade('project', args)
elseif ns==119 then -- Draft talk
return resolveFQSgrade('draft', args)
elseif ns==13 then -- Help talk
return resolveFQSgrade('help', args)
else
local ns = title.namespace
return 'NA'
grade = grade:match('^%s*(.-)%s*$'):lower()
end
if title.subjectPageTitle.isRedirect then
end
out = resolveFQSgrade('redirect',args)
 
elseif ns==1 then -- Talk
local getGrade = function(args, title)
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
local grade = args[1]
out = resolveFQSgrade('disambig',args)
grade = grade and grade:match('^%s*(.-)%s*$'):lower()
else
local ret
if grade=='start' or grade=='stub' then -- Ucfirst
 
if not args[grade or grade ]~== '¬no' then -- undefined
out = ucfirst(grade)
ret = '¬'
end
 
elseif grade=='b' or grade=='c' or grade=='fa' or grade=='fl' or grade=='a' or grade=='ga' then -- Upper-case
-- Ucfirst
if args[grade]~='no' then
elseif grade == 'start' or grade == 'stub' or grade == 'list' then
out = grade:upper()
if args[grade] ~= 'no' then
ret = ucfirst(grade)
end
 
-- B
elseif grade == 'b' or grade == 'c' then
local mask = mw.loadData('Module:WikiProject banner/config').b_checklist.mask
local isExtended = args.b1 or args.b2 or args.b3 or args.b4 or args.b5 or args.b6
if isExtended then
local all_complete, all_pass = true, true
for i = 1, 6 do
local b_param = args['b'..i] and mask[string.lower(args['b'..i])]
if b_param and b_param~='y' and b_param~='x' then -- criterion in use and is not passed or marked not applicable
all_pass = false
if b_param~='n' then
all_complete=false
end
elseif args[grade:upper()] then -- Upper-case syntax
out = args[grade:upper()]
elseif args[grade:lower()]=='yes' then -- Lower-case syntax
out = mw.language.getContentLanguage():ucfirst(grade:lower())
elseif grade=='list' or grade=='sia' or grade=='si' or grade=='sl' then-- List
if args['list']~='no' then
out = 'List'
end
elseif grade=='dab' or grade=='disambig' or grade=='disambiguation' or grade=='disamb' then
out = resolveFQSgrade('disambig', args)
end
end
elseif ns==7 or ns==711 then -- File talk
ret = all_pass and 'B' -- return B if all criteria are marked passed
if grade=='fm' and (args.fm or args.FQS)=='yes' then
or all_complete and 'C' -- or return C if whole checklist is completed but not all passed
out = 'FM'
or grade:upper() -- otherwise defer to entered grade
else
elseif args[grade]~='no' then
ret out = grade:upperresolveFQSgrade('file', args)
end
elseif ns==15 then -- Category talk
 
out = resolveFQSgrade('category', args)
-- Upper-case
elseif ns==101 then -- Portal talk
elseif grade == 'fa' or grade == 'fl' or grade == 'a' or grade == 'ga' then
out = resolveFQSgrade('portal', args)
if args[grade] ~= 'no' then
elseif ns==11 or ns==829 then -- Template talk
ret = grade:upper()
out = resolveFQSgrade('template', args)
end
elseif grade ns== 'na'5 then -- Wikipedia talk
out = resolveFQSgrade('project', args)
if args.forceNA == 'yes' then
elseif ns==119 then -- Draft talk
ret = resolveDefaultGrade(args, title, 'NA')
out = resolveFQSgrade('draft', args)
elseif ns==13 and args['help']=='yes' then -- Help talk
out = 'Help'
elseif ns==3 and args['user']=='yes' then -- User talk
out = 'User'
else
retout = 'NA'
end
elseif grade == 'file' or grade == 'image' or grade == 'img' then
ret = resolveFQSgrade('file', args)
elseif grade == 'category' or grade == 'cat' or grade == 'categ' then
ret = resolveFQSgrade('category', args)
elseif grade == 'dab' or grade == 'disambig' or grade == 'disambiguation' or grade == 'disamb' then
ret = resolveFQSgrade('disambig', args)
elseif grade == 'redirect' or grade == 'red' or grade == 'redir' then
ret = resolveFQSgrade('redirect', args)
elseif grade == 'help' then
ret = resolveFQSgrade('help', args)
elseif grade == 'portal' or grade == 'project' or grade == 'draft' then
ret = resolveFQSgrade(grade, args)
elseif grade == 'template' or grade == 'temp' or grade == 'tpl' or grade == 'templ' then
ret = resolveFQSgrade('template', args)
elseif grade == 'fm' then
if (args.fm or args.FQS)=='yes' then
ret = 'FM'
else
ret = resolveFQSgrade('file', args)
end
else
-- Upper-case syntax
ret = args[grade:upper()]
 
-- Lower-case syntax
if not ret then
if args[grade:lower()] == 'yes' then
ret = mw.language.getContentLanguage():ucfirst(grade:lower())
end
end
 
-- Defaults
if not ret then
ret = resolveDefaultGrade(args, title)
end
end
return ret
end
 
p._main = function(args, title)
title = title or mw.title.getCurrentTitle()
local out = ''
if title.namespace == 10 and title.subpageText == 'class' then
out = mw.getCurrentFrame():expandTemplate{title = 'Class mask/doc warning'}
end
out = out .. (getGrade(args, title) or '')
return out
end
Line 155 ⟶ 91:
p.main = function(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {
removeBlanks = false,
wrappers = 'Template:Class mask'
})
return p._main(args)
end