Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
test bug in param order/parsing
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(34 intermediate revisions by 2 users not shown)
Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
 
local function p.expectedpagetype(framensText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
local retval = ''
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:preprocess('{{#switch:' .. v .. '|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}') .. '\n\n'
end
return retval
end
 
function p.equalsInValuemain(frame)
local retvalcurrentTitle = ''mw.title.getCurrentTitle()
local target = getTarget(currentTitle)
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
if target then
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
retval = retval .. frame:callParserFunction('#switch', {v, 'red', 'orange=1', 'yellow', 'green=2', 'blue', 'indigo=3', 'violet=4', '5'}) .. '\n\n'
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 retval
end
 
function p.associativeArray(frame)
local retval = ''
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:callParserFunction('#switch', {v, 'red', orange='1', 'yellow', green='2', 'blue', indigo='3', violet='4', '5'}) .. '\n\n'
end
return retval
end
 
function p.main(frame)
return p.expected(frame) .. '\n\n' .. p.equalsInValue(frame) .. '\n\n' .. p.associativeArray(frame)
end