Module:Class mask/sandbox: Difference between revisions

Content deleted Content added
Undid revision 1146127572 by MSGJ (talk)
sync with live
Line 1:
-- This module implements [[Template:Class mask]].
 
local p = {}
 
Line 45 ⟶ 44:
if args.ignorenamespace then
return nil
end
if title.isRedirect then
return resolveExtraGrade('bookredirect', args)
end
local ns = title.namespace
if ns == 10 then -- Talk
return talkDefault
elseif ns ==6 7or ns==710 then -- File talk
return resolveFQSgrade('file', args)
elseif ns == 1514 then -- Category talk
return resolveFQSgrade('category', args)
elseif ns == 101100 then -- Portal talk
return resolveFQSgrade('portal', args)
elseif ns ==10 11or ns==828 then -- Template talk
return resolveFQSgrade('template', args)
elseif ns == 54 then -- Wikipedia talk
return resolveFQSgrade('project', args)
elseif ns == 119118 then -- Draft talk
return resolveFQSgrade('draft', args)
elseif ns == 109 then -- Book talk
return resolveExtraGrade('book', args)
else
return 'NA'
Line 76:
local ret
 
if not grade or grade == '¬' then -- undefined
-- Undefined
if not grade or grade == '¬' then
ret = '¬'
elseif nsgrade == 109'' then -- Book talkblank
 
-- Blank or empty
elseif grade == '' then
ret = args['']
 
-- Ucfirst
Line 152 ⟶ 148:
elseif grade == 'template' or grade == 'temp' or grade == 'tpl' or grade == 'templ' then
ret = resolveFQSgrade('template', args)
 
-- Book
elseif grade == 'book' then
ret = resolveExtraGrade('book', args)
 
-- FM
Line 166 ⟶ 158:
 
else
-- We can't guarantee that we will only have Ascii grades any more, so
-- normalize the grade again using mw.ustring where necessary.
local trimmedGrade = trim(args[1])
 
-- Upper-case syntax
ret = args[mw.ustring.grade:upper(trimmedGrade)]
 
-- Lower-case syntax
if not ret then
elseif if args[grade:lower()] == 'yes' then
local normalizedGrade = mw.ustring.lower(grade)
ret = mw.language.getContentLanguage():ucfirst(normalizedGradegrade:lower())
if args[normalizedGrade] == 'yes' then
ret = mw.language.getContentLanguage():ucfirst(normalizedGrade)
end
end
end
 
-- Defaults
if not ret then
ret = resolveDefaultGrade(args, title)
end
end
 
Line 191 ⟶ 178:
 
function p._main(args, title)
title = title or mw.title.getCurrentTitle().subjectPageTitle
local docWarning = getDocWarning(title) or ''
local grade = getGrade(args, title) or ''
Line 198 ⟶ 185:
 
function p.main(frame)
returnlocal pargs = frame._main(args or frame:getParent().args)
return p._main(args)
end