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

556 بائٹ کا اضافہ ،  3 سال پہلے
کوئی خلاصۂ ترمیم نہیں
(نیا صفحہ: -- 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...)
 
کوئی خلاصۂ ترمیم نہیں
(ٹیگ: ترمیم از موبائل موبائل ویب ترمیم)
 
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
-- 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.
local targetTitle = getTitle(target)
if targetTitle then
if fulltext then
return targetTitle.prefixedText
return targetTitle.fullText
else
return targetTitle.prefixedText
end
else
return nil
error(string.format(
'could not parse redirect on page "%s"',
fulltext and titleObj.fullText or titleObj.prefixedText
))
end
-- 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
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
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
85

ترامیم