Jump to content

Module:Infobox television disambiguation check

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gonnym (talk | contribs) at 16:40, 4 May 2019 (Created page with '-- This module requires the use of Module:Arguments. local getArgs = require('Module:Arguments').getArgs local p = {} local validNameList = { "TV series", "T...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- This module requires the use of Module:Arguments.
local getArgs = require('Module:Arguments').getArgs

local p = {}

local validNameList = {
	"TV series",
	"TV program",
	"TV programme",
	"TV film",
	"film",
	"miniseries",
	"serial",
	"game show",
	"talk show"
}

local franchise = "franchise"

local categoryList = {
	["incorrect"] = "[[Category:Television articles with incorrect naming style]]",
	["franchise"] = "[[Category:Television articles using incorrect infobox|F]]"
}

local isValid = false
local category = ""

local function _main(args)
	if (args[1] == nil or args[1] == "") then
		return ""
	end
	
	local disambiguation = string.match(args[1], "%s%((.-)%)")
	
	if (not disambiguation) then
		-- Nothing to check.
		return ""
	end
	
	disambiguation = mw.ustring.lower(disambiguation)
	
	for _, v in ipairs(validNameList) do
		if (not string.match(disambiguation, mw.ustring.lower(v))) then
			-- Name not valid, do nothing.
		else
			-- Name valid, set isValid to true.
			isValid = true
			break
		end
	end
	
	if (string.match(disambiguation, mw.ustring.lower(franchise))) then
		isValid = true
		category = categoryList["franchise"]
	end
	
	if (not isValid) then
		category = categoryList["incorrect"]
	end
	
	return category
end

function p.main(frame)
	local args = getArgs(frame)
	return _main(args)
end

return p