Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
no list
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(60 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 parentTitlecurrentTitle = frame:getParent():getTitlemw.title.getCurrentTitle()
local target = getTarget(currentTitle)
if mw.title.getCurrentTitle().prefixedText == parentTitle then
if target then
-- we're not being transcluded, so show the content normally
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
return '== ' .. frame.args[1] .. ' =='
if currentNsText ~= targetNsText then
else
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
-- we're being transcluded, so show links to the sections
end
return '[[' .. parentTitle .. '#' .. frame.args[1] .. '|' .. frame.args[1] .. ']]'
end
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
end