Module:Class mask

This module implements {{class mask}}. See the template page for documentation.

Module:Class mask

local p = {}
local ucfirst = function(s)
	return s:sub(1, 1):upper() .. s:sub(2, -1)
end

local inlist = function(string, list)
	for _, s in ipairs(list) do
		if s==string then
			return true
		end
	end
	return false
end

p._main = function(args, title)
	local resolveFQSgrade = function(grade)
		if (args[grade] or args.FQS)=='yes' then
			return ucfirst(grade)
		else
			return 'NA'
		end
	end
	local page = title and title.prefixedText
	local out = ''
	local grade = args[1]
	if not grade or grade == '¬' then -- undefined
		out = '¬'
	else
		local pagetype = require('Module:Pagetype')._main{
			dab = 'dab',
			sia = 'sia',
			portal = 'yes',
			wikipedia = 'yes',
			draft = 'yes',
			timedtext = 'yes',
			help = 'yes',
			user = 'yes',
			page = page
		}
		grade = grade:match('^%s*(.-)%s*$'):lower()
		if pagetype=='redirect' then
			out = resolveFQSgrade('redirect')
		elseif pagetype=='dab' then
			out = resolveFQSgrade('disambig')
		elseif pagetype=='article' then
			if inlist(grade, {'start', 'stub'}) and args[grade]~='no' then
				out = ucfirst(grade)
			elseif inlist(grade, {'b', 'c', 'fa', 'fl', 'a', 'ga'}) and args[grade]~='no' then
				out = grade:upper()
			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 inlist(grade, {'list', 'sia', 'si', 'sl'}) and args['list']~='no' then
				out = 'List'
			end
		elseif pagetype=='sia' then
			if args['SIA'] then -- upper-case syntax
				out = args['SIA']
			elseif args['sia']=='yes' then -- lower-case syntax
				out = 'SIA'
			elseif args['list']~='no' then
				out = 'List'
			end
		elseif inlist(pagetype, {'file', 'Timed Text page'}) then
			if grade=='fm' and (args.fm or args.FQS)=='yes' then
				out = 'FM'
			else
				out = resolveFQSgrade('file')
			end
		elseif pagetype=='category' then
			out = resolveFQSgrade('category')
		elseif pagetype=='portal' then
			out = resolveFQSgrade('portal')
		elseif pagetype=='template' or pagetype=='module' then
			out = resolveFQSgrade('template')
		elseif pagetype=='project page' then
			out = resolveFQSgrade('project')
		elseif pagetype=='draft' then
			out = resolveFQSgrade('draft')
		elseif pagetype=='help page' and args['help']=='yes' then
			out = 'Help'
		elseif pagetype=='user page' and args['user']=='yes' then
			out = 'User'
		else
			out = 'NA'
		end
	end
	return 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

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.