Modul:RedirectData
Bu modul uchun Modul:RedirectData/doc nomli hujjat sahifasini yaratishingiz mumkin
local p = {}
function p.getRedirectToNamespace(frame)
local titleObject = mw.title.getCurrentTitle() -- check if this is a redirect
if titleObject.redirectTarget then
local targetNamespace = titleObject.redirectTarget.nsText
return targetNamespace
end
return "Notaredirect"
end
function p.getTalkPage(frame)
local titleObject = mw.title.getCurrentTitle()
if titleObject.redirectTarget then
if not titleObject.isTalkPage then
if titleObject.redirectTarget.isTalkPage then
return "Yes"
end
end
return "No"
end
return "Notaredirect"
end
function p.getSubpageStatus(frame)
local titleObject = mw.title.getCurrentTitle()
if titleObject.redirectTarget then
local pageIsSubpage = titleObject.isSubpage
local targetIsSubpage = titleObject.redirectTarget.isSubpage
if (pageIsSubpage or targetIsSubpage) then
if (pageIsSubpage and targetIsSubpage) then
return "Both"
elseif pageIsSubpage then
return "Onlypage"
else
return "Onlytarget"
end
else
return "Neither"
end
end
return "Notaredirect"
end
function p.toDisambig(frame)
local titleObject = mw.title.getCurrentTitle()
if titleObject.redirectTarget then
if string.match(titleObject.text, "%(disambiguation%)") then
if titleObject.isTalkPage then
return "Talk"
else
return "Article"
end
else
return "No"
end
end
return "Notaredirect"
end
return p