Module:Class mask/sandbox: Difference between revisions

Content deleted Content added
all the code for the b-class checklist is not needed now
fix?
 
(11 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 getGradep._main = function(args, title)
title = title or mw.title.getCurrentTitle()
local out = ''
local grade = args[1]
if not grade or grade == '¬' then -- undefined
local ns = title.namespace
out = '¬'
if title.subjectPageTitle.isRedirect then
else
return resolveFQSgrade('redirect',args)
local ns = title.namespace
elseif ns==1 then -- Talk
grade = grade:match('^%s*(.-)%s*$'):lower()
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
if title.subjectPageTitle.isRedirect then
return resolveFQSgrade('disambig',args)
out = resolveFQSgrade('redirect', args)
else
elseif ns == 1 then -- Talk
grade = grade and grade:match('^%s*(.-)%s*$'):lower()
if require('Module:Disambiguation').isDisambiguation(title.subjectPageTitle:getContent()) then
if grade=='start' or grade=='stub' then -- Ucfirst
out = resolveFQSgrade('disambig', args)
if args[grade]~='no' then
else
return ucfirst(grade)
if grade == 'start' or grade == 'stub' then -- Ucfirst
end
if args[grade] ~= 'no' then
elseif grade=='b' or grade=='c' or grade=='fa' or grade=='fl' or grade=='a' or grade=='ga' then -- Upper-case
out = ucfirst(grade)
if args[grade]~='no' then
end
return grade:upper()
elseif grade == 'b' or grade == 'c' or grade == 'fa' or grade == 'fl' or grade == 'a' or grade == 'ga' then -- Upper-case
end
elseif if args[grade:upper()] then~= --'no' Upper-case syntaxthen
return out = args[grade:upper()]
end
elseif args[grade:lower()]=='yes' then -- Lower-case syntax
elseif args[grade:upper()] then -- Upper-case syntax
return mw.language.getContentLanguage():ucfirst(grade:lower())
out = args[grade:upper()]
elseif grade=='list' or grade=='sia' or grade=='si' or grade=='sl' then-- List
ifelseif args['list'grade:lower()]~ == 'noyes' then -- Lower-case syntax
out = mw.language.getContentLanguage():ucfirst(grade:lower())
return 'List'
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
end
if grade == 'fm' and (args.fm or args.FQS) == 'yes' then
elseif ns==7 or ns==711 then -- File talk
out = 'FM'
if grade=='fm' and (args.fm or args.FQS)=='yes' then
return 'FM'else
out = resolveFQSgrade('file', args)
end
elseif ns == 15 then -- Category talk
out = resolveFQSgrade('category', args)
elseif ns == 101 then -- Portal talk
out = resolveFQSgrade('portal', args)
elseif ns == 11 or ns == 829 then -- Template talk
out = resolveFQSgrade('template', args)
elseif ns == 5 then -- Wikipedia talk
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
out = 'NA'
return resolveFQSgrade('file', args)
end
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 and args['help']=='yes' then -- Help talk
return 'Help'
elseif ns==3 and args['user']=='yes' then -- User talk
return 'User'
else
return 'NA'
end
end
 
p._main = function(args, title)
title = title or mw.title.getCurrentTitle()
local out, warning = '', ''
if title.namespace == 10 and title.subpageText == 'class' then
warning = mw.getCurrentFrame():expandTemplate{title = 'Class mask/doc warning'}
end
if not args[1] or args[1]=='¬' then -- undefined
out = '¬'
else
out = (getGrade(args, title) or '')
end
return warning .. out
end
 
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 105 ⟶ 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 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