Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
Reverted to revision 623263051 by Jackmcbarn (talk). (TW)
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(29 intermediate revisions by 2 users not shown)
Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
 
local function pagetype(nsText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
end
 
function p.main(frame)
local currentTitle = mw.title.getCurrentTitle()
local args, args_mt = { '__pairs was not used' }, {}
local target = getTarget(currentTitle)
function args_mt.__pairs( t )
if target then
return pairs( { 'success' } )
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
if currentNsText ~= targetNsText then
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
end
end
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
return frame:expandTemplate{ title = 'Echo', args = setmetatable( args, args_mt ) }
end