Content deleted Content added
m only check for dab page in main talk namespace |
add support for help-class, add functions from Module:WikiProject quality assessment Tag: Reverted |
||
Line 1:
local p = {}
local readarticleclass = function() -- look for article_class in page content
local function ucfirst(s)▼
local get_parameter_value = require("Module:Template parameter value").getValue
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 target = mw.title.getCurrentTitle().prefixedText
local success, result = get_parameter_value(target, WPBSredirects, "class", {ignoreSubtemplates=true})
return success and result
end
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(nonarticleclasses) do
if class==v then -- class matches one of the non-article classes
article = false
break
end
end
return article
end
-- Returns the given string with the first character in upper case.
-- Should not be used with non-ascii strings.
Line 7 ⟶ 27:
end
local
s = s and s:lower()
return not s or s == 'yes' or s == 'y' or s == '1' or s == 'pass' or s == 'na' or s == 'n/a' or s == '¬' or s == 'unused'
end
local
if (args[grade] or args.FQS) == 'yes' then
return ucfirst(grade)
Line 20 ⟶ 40:
end
local
if args[grade] == 'yes' then
return ucfirst(grade)
Line 28 ⟶ 48:
end
local
if args.ignorenamespace then
return nil
Line 54 ⟶ 74:
elseif ns==119 then -- Draft talk
return resolveFQSgrade('draft', args)
elseif ns==13 then -- Help talk
return resolveExtraGrade('help', args)
else
return 'NA'
Line 59 ⟶ 81:
end
local
local grade = args[1]
grade = grade and grade:match('^%s*(.-)%s*$'):lower()
Line 115 ⟶ 137:
elseif grade == 'redirect' or grade == 'red' or grade == 'redir' then
ret = resolveExtraGrade('redirect', args)
elseif grade == 'help' then
ret = resolveExtraGrade('help', args)
elseif grade == 'portal' or grade == 'project' or grade == 'draft' then
ret = resolveFQSgrade(grade, args)
Line 142 ⟶ 166:
end
end
return ret
end
title = title or mw.title.getCurrentTitle()
local out = ''
Line 156 ⟶ 179:
end
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame,{removeBlanks=false, wrappers='Template:Class mask'})
return p.
end
local getclass = function(args)
local class = '¬'
if args.QUALITY_SCALE == 'inline' then
class = args.class
elseif args.QUALITY_SCALE == 'subpage' then
if mw.title.new(args.BANNER_NAME..'/class').exists then
local frame = mw.getCurrentFrame()
class = frame:expandTemplate{title = args.BANNER_NAME..'/class', args = args}
end
else
args.FQS = (args.QUALITY_SCALE == 'extended') and 'yes' or 'no'
args[1] = args.class
class = p.class_mask(args)
end
return class
end
p.quality = function(frame) -- used by WPBM to check global quality and compare with local parameter
local local_class = getclass(frame.args)
local prefix, class = 'Y', local_class
if local_class=='¬' then
class = '¬'
elseif frame.args.QUALITY_CRITERIA ~= 'custom' then -- project uses standard scale and will inherit article class if needed
local article_class = frame.args.article_class or readarticleclass() -- checks parameter for testing purposes
article_class = article_class and p.class_mask{article_class, ignorenamespace=frame.args.ignorenamespace} or '¬' -- normalise if not false
if (article_class == '¬') or (article_class == '') then -- article class does not exist, display quality class in project banner as normal
elseif (local_class == '') or (local_class == article_class) then -- article class and local class are the same, or local is not specified
prefix = 'H' -- hide quality class in project banner
class = article_class
elseif (article_class == 'NA') and not isarticle(local_class) then -- article class and local class are both non-article classes
prefix = 'H'
else -- article class exists and differs from local class
prefix = 'X' -- X will indicate to meta banner that classes are different, so trigger a tracking category
end
end
return (frame.args.noprefix and '' or prefix) .. class
end
|