"ماڈیول:Redirect" کے نسخوں کے درمیان فرق

حذف شدہ مندرجات اضافہ شدہ مندرجات
نیا صفحہ: -- This module provides functions for getting the target of a redirect page. local p = {} -- Gets a mw.title object, using pcall to avoid generating script errors if we -- are...
 
کوئی خلاصۂ ترمیم نہیں
(ٹیگ: ترمیم از موبائل موبائل ویب ترمیم)
 
سطر 19:
return string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
) or string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
)
end
سطر 25 ⟵ 28:
-- Gets the target of a redirect. If the page specified is not a redirect,
-- returns nil.
function p.getTarget(page, fulltext)
-- Get the title object. Both page names and title objects are allowed
-- as input.
سطر 49 ⟵ 52:
local targetTitle = getTitle(target)
if targetTitle then
if fulltext then
return targetTitle.prefixedText
return targetTitle.fullText
else
return targetTitle.prefixedText
end
else
return nil
سطر 58 ⟵ 65:
error(string.format(
'could not parse redirect on page "%s"',
fulltext and titleObj.fullText or titleObj.prefixedText
))
end
سطر 72 ⟵ 79:
-- target cannot be determined for some reason.
--]]
function p.luaMain(rname, bracket, fulltext)
if type(rname) ~= "string" or not rname:find("%S") then
return nil
سطر 78 ⟵ 85:
bracket = bracket and "[[%s]]" or "%s"
rname = rname:match("%[%[(.+)%]%]") or rname
local target = p.getTarget(rname, fulltext)
local ret = target or rname
ret = getTitle(ret)
if ret then
if fulltext then
ret = ret.prefixedText
ret = ret.fullText
else
ret = ret.prefixedText
end
return bracket:format(ret)
else
سطر 92 ⟵ 103:
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
return p.luaMain(args[1], args.bracket, args.fulltext) or ''
end
 
-- Returns "yes"true if the specified page is a redirect, and the blankfalse stringotherwise.
function p.isRedirectluaIsRedirect(framepage)
-- otherwise.
local titleObj = getTitle(args[1]page)
function p.isRedirect(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
local titleObj = getTitle(args[1])
if not titleObj then
return ''false
end
if titleObj.isRedirect then
return true
else
return false
end
end
 
-- Provides access to the luaIsRedirect function from wikitext, returning 'yes'
-- if the specified page is a redirect, and the blank string otherwise.
function p.isRedirect(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
if p.luaIsRedirect(args[1]) then
return 'yes'
else