Jump to content

Module:Is article

විකිපීඩියා වෙතින්
09:41, 1 නොවැම්බර් 2023 වන විට Lee (සාකච්ඡාව | දායකත්ව) (en:Module:Is_article වෙතින් එක් සංශෝධනයක්) විසින් සිදු කර ඇති සංශෝධන
(වෙනස) ← පැරණි සංශෝධනය | වත්මන් සංශෝධනය (වෙනස) | නව සංශෝධනය → (වෙනස)

local p = {}

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

function p.main(frame)
	local getArgs = require("Module: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
"https://si.wikipedia.org/w/index.php?title=Module:Is_article&oldid=601480" වෙතින් සම්ප්‍රවේශනය කෙරිණි