Module:Class mask/sandbox: Difference between revisions

Content deleted Content added
fix
fix?
 
(15 intermediate revisions by 2 users not shown)
Line 1:
local p = {}
 
local cfg = mw.loadData('Module:WikiProject banner/config')
 
local isarticle = function(class)
local nonarticleclasses = {'Template', 'File', 'Category', 'Disambig', 'Redirect', 'Portal', 'Project', 'Draft', 'Book', 'FM'} -- these classes will not be identified as conflicting with NA-class
local article = true
for _, v in ipairs(nonarticleclassescfg.quality.non_article_classes) do
if class == v then -- class matches one of the non-article classes
article = false
break
Line 20 ⟶ 21:
 
local resolveFQSgrade = function(grade, args)
if (args[grade] or args.FQS) == 'yes' then
return ucfirst(grade)
else
Line 27 ⟶ 28:
end
 
local resolveExtraGradep._main = function(gradeargs, argstitle)
title = title or mw.title.getCurrentTitle()
if args[grade]=='yes' then
local out = ''
return ucfirst(grade)
local grade = args[1]
if not grade or grade == '¬' then -- undefined
out = '¬'
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 resolveDefaultGrade = function(args, title, talkDefault)
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
local ns = title.namespace
out = resolveFQSgrade('disambig', args)
if title.subjectPageTitle.isRedirect then
else
return resolveFQSgrade('redirect',args)
if grade == 'start' or grade == 'stub' then -- Ucfirst
elseif ns==1 then -- Talk
if args[grade] ~= 'no' then
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
out = ucfirst(grade)
return resolveFQSgrade('disambig',args)
else end
elseif grade == 'b' or grade == 'c' or grade == 'fa' or grade == 'fl' or grade == 'a' or grade == 'ga' then -- Upper-case
return talkDefault
if args[grade] ~= 'no' then
end
out = grade:upper()
elseif ns==7 or ns==711 then -- File talk
end
return resolveFQSgrade('file', args)
elseif ns==15args[grade:upper()] then -- CategoryUpper-case talksyntax
out = args[grade:upper()]
return resolveFQSgrade('category', args)
elseif nsargs[grade:lower()] ==101 'yes' then -- PortalLower-case talksyntax
out = mw.language.getContentLanguage():ucfirst(grade:lower())
return resolveFQSgrade('portal', args)
elseif nsgrade ==11 'list' or nsgrade ==829 'sia' or grade == 'si' or grade == 'sl' then -- Template talkList
if args['list'] ~= 'no' then
return resolveFQSgrade('template', args)
out = 'List'
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 resolveExtraGrade('help', args)
elseif ns==3 then -- User talk
return resolveExtraGrade('user', args)
else
return 'NA'
end
end
 
local getGrade = function(args, title)
local grade = args[1]
grade = grade and grade:match('^%s*(.-)%s*$'):lower()
local ret
if not grade or grade=='¬' then -- undefined
ret = '¬'
elseif grade=='start' or grade=='stub' then -- Ucfirst
if args[grade]~='no' then
ret = ucfirst(grade)
end
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 some_fail, all_pass = false, 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
some_fail = true
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 some_fail and 'C' -- or return C if any of the criteria are marked failed
out = 'FM'
or grade:upper() -- otherwise defer to entered grade
else
elseif args[grade]~='no' then
ret out = grade:upperresolveFQSgrade('file', args)
end
elseif grade=='fa' orns grade=='fl' or grade=='a' or grade=='ga'15 then -- Upper-caseCategory talk
out = resolveFQSgrade('category', args)
if args[grade]~='no' then
elseif ns == 101 then -- Portal talk
ret = grade:upper()
out = resolveFQSgrade('portal', args)
end
elseif gradens =='na' 11 or ns == 829 then -- Template talk
out = resolveFQSgrade('template', args)
if args.forceNA=='yes' then
elseif ns == 5 then -- Wikipedia talk
ret = resolveDefaultGrade(args, title, 'NA')
out = resolveFQSgrade('project', args)
elseif ns == 119 then -- Draft talk
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=='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=='help' or grade=='user' then
ret = resolveExtraGrade(grade, args)
elseif grade=='fm' then
if (args.fm or args.FQS)=='yes' then
ret = 'FM'
else
ret = resolveFQSgrade('file', args)
end
elseif args[grade:upper()] then -- Upper-case syntax
ret = args[grade:upper()]
elseif args[grade:lower()]=='yes' then -- Lower-case syntax
ret = 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
ret = 'List'
end
end
if not ret then -- Defaults
ret = resolveDefaultGrade(args, title)
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 153 ⟶ 92:
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
Line 162 ⟶ 104:
class = args.class
elseif args.QUALITY_SCALE == 'subpage' then
iflocal classTemplate = mw.title.new(args.BANNER_NAME .. '/class').exists then
if mw.title.new(classTemplate).exists then
local frame = mw.getCurrentFrame()
class = frame:expandTemplate{title = args.BANNER_NAME..'/class'classTemplate, args = args}
end
else
Line 177 ⟶ 120:
page = page or mw.title.getCurrentTitle().prefixedText
local get_parameter_value = require("Module:Template parameter value").getValue
local success, result = get_parameter_value(page, cfg.WPBS_redirects, "class", options)
local WPBSredirects = {'WikiProject banner shell','WikiProject banner shell/sandbox','Bannershell','Multiple wikiprojects','Project shell','Scope shell','WPB','WPBS','WPBannerShell','WP Banner Shell','WP banner shell','WikiProjectBannerShell','WikiProjectBanner Shell','WikiProjectBanners','WikiProject BannerShell','WikiProject Banner Shell','WikiProject Banners','WikiProject Banners Shell','WikiProject Shell','WikiProject banner','WikiProject banner shell/redirect','WikiProject shell','WikiprojectBannerShell','Wikiproject banner holder','Wikiproject banner shell','Wikiprojectbanners','Wikiprojectbannershell','Wpb','Wpbannershell','Wpbsgclass'}
local success, result = get_parameter_value(page, WPBSredirects, "class", options)
return success and result
-- returns FALSE if banner shell template does not exist on page