Jump to content

Module:Sandbox/Jackmcbarn: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Jackmcbarn (talk | contribs)
test a possible link table bypass
Jackmcbarn (talk | contribs)
test cross-namespace redirects
Line 1: Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
local p = {}

local function pagetype(nsText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
end


function p.main(frame)
function p.main(frame)
local currentTitle = mw.title.getCurrentTitle()
return package.loaders[2]('Module:Sandbox/Jackmcbarn/2')().main()
local target = getTarget(currentTitle)
if target then
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]]'
end
end



Revision as of 01:25, 13 January 2016

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 target = getTarget(currentTitle)
	if target then
		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]]'
end

return p