Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
figure out why this is so slow
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(72 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 given = frame.args[1]
local target = getTarget(currentTitle)
if given == nil or given == '' then
if target then
return ""
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
end
if currentNsText ~= targetNsText then
local args = {}
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
given = given .. "!"
end
for item in given:gmatch( "(.-)!") do
end
local p = item:find('=', 1, true)
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
if p then
args[item:sub(1, p-1)] = item:sub(p+1)
else
table.insert(args, item)
end
end
return frame:expandTemplate{ title = "convert/old", args = args }
end