Content deleted Content added
remove the getTitle function, as it is no longer necessary after changes to mw.title inside Scribunto; and use more standard _main and _isRedirect and deprecate luaMain and luaIsRedirect |
Update to live |
||
Line 2:
local p = {}
-- Gets a mw.title object, using pcall to avoid generating script errors if we
-- are over the expensive function count limit (among other possible causes).
local function getTitle(...)
local success, titleObj = pcall(mw.title.new, ...)
if success then
return titleObj
else
return nil
end
end
-- Gets the name of a page that a redirect leads to, or nil if it isn't a
Line 22 ⟶ 33:
local titleObj
if type(page) == 'string' or type(page) == 'number' then
titleObj =
elseif type(page) == 'table' and type(page.getContent) == 'function' then
titleObj = page
Line 39 ⟶ 50:
local target = p.getTargetFromText(titleObj:getContent() or "")
if target then
local targetTitle =
if targetTitle then
return targetTitle.prefixedText
Line 64 ⟶ 75:
-- target cannot be determined for some reason.
--]]
function p.
if type(rname) ~= "string" or not rname:find("%S") then
return nil
Line 72 ⟶ 83:
local target = p.getTarget(rname)
local ret = target or rname
ret =
if ret then
ret = ret.prefixedText
Line 88 ⟶ 99:
-- Returns true if the specified page is a redirect, and false otherwise.
function p.
local titleObj =
if not titleObj then
return false
Line 110 ⟶ 121:
end
end
return p
|