Modul:Is article

Iz Wikipedije, proste enciklopedije
local p = {}

local disambiguationTemplates = {
	"[Rr]azločitev",
	"[Rr]azločitev cest",
	"[Rr]azločitev ladij",
	"[Rr]azločitev osebnih imen",
	"[Rr]azločitev vojaške enote",	
    "[Dd]isambiguation",
	"[Dd]isambig",
	"[Dd]isambig-armada",
	"[Dd]isambig-brigada",
	"[Dd]isambig-divizija",
	"[Dd]isambig-korpus",
	"[Dd]isambig-polk",
	"[Rr]azločitev",
	"[Dd]isamb",
    "[Dd]ab",
	"[Gg]eoraz",
	"[Nn]umberdis",
	"[Pp]riimek",
	"[Rr]azločitev predloge",
}

function p.main(frame)
	local getArgs = require("Modul:Arguments").getArgs
	local args = getArgs(frame)
	local page = mw.title.new(args[1], 0)
	
	if not page then
		return "badtitle"
	end

	if not page.exists then
		return "empty"
	end

	if page.isRedirect then
		return "redirect"
	end

	local content = page:getContent()
	if content then
		content = string.gsub(content, "noinclude", "<!-- noinclude -->")
		for _, name in ipairs(disambiguationTemplates) do
			if content:match("{{%s?" .. name .. "%s?}}") and not content:match("{{{%s?" .. name .. "%s?}}}") then -- to disable false positives in parameter names {{{disamb}}}
				return "dab"
			end
		end
	end

	return "article"
end

return p