Jump to content

Module:Is article

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ad Orientem (talk | contribs) at 02:33, 5 July 2020 (Protected "Module:Is article": Protecting sub template to a high visibility template per request at RfPP. ([Edit=Require autoconfirmed or confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

local disambiguationTemplates = {
	"[Dd]isambiguation",
	"[Dd]isambig",
	"[Dd]isamb",
	"[Dd]ab",
	"[Ss]urname"
	}

function p.main(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame)
	title = args[1]
	page = mw.title.new(title, 0)

	if (not page.exists) then
		return "empty"
	end

	if (page.isRedirect) then
		return "redirect"
	end

	local content = page:getContent()
	if (content) then
		for i, name in ipairs(disambiguationTemplates) do
			if (content:match('{{%s*' .. name .. '.*}}')) then
				return "dab"
			end
		end
	end

	return "article"
end

return p