Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
for Iraq now
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(30 intermediate revisions by 2 users not shown)
Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
 
local function p.markpagetype(framensText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
local argsToReturn = {}
end
local extra = {}
 
local args = {}
forfunction k,v in pairsp.main(frame.args) do
local currentTitle = mw.title.getCurrentTitle()
args[k] = v
local target = getTarget(currentTitle)
end
if #extra > 0target then
for k,v in ipairs({'lat', 'long', 'mark', 'marksize', 'label', 'link', 'label_size', 'position'}) do
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
if args[v] then
if currentNsText ~= targetNsText then
table.insert(argsToReturn, string.format("%s = %q", v, mw.text.trim(args[v])))
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
args[v] = nil
end
end
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
if args[1] and mw.text.trim(args[1]) == 'Iraq' then args[1] = nil end
for k,v in pairs(args) do
table.insert(extra, 'EXTRA ' .. k .. ' = ' .. v)
end
if #extra > 0 then
error(table.concat(extra, ', '))
end
return '{ ' .. table.concat(argsToReturn, ', ') .. ' },'
end