Jump to content

Module:Is article: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}

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


function p.main(frame)
function p.main(frame)
Line 16: Line 24:


local content = page:getContent()
local content = page:getContent()
if content
if (content) then
for i, name in ipairs(disambiguationTemplates) do
and content:match('{{%s*[Dd]isambig%a*%s*}}')
or content:match('{{%s*[Dd]ab%s*}}')
if (content:match('{{%s*' .. name .. '.*}}')) then
return "dab"
or content:match('{{%s*[Ss]urname%s*}}')
end
then
end
return "dab"
end
end



Revision as of 08:08, 3 July 2020

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