Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
build name sorter
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(43 intermediate revisions by 2 users not shown)
Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
 
local function splitpagetype(str, delimnsText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
local retval, endpos = {}, 1
for elem, pos in str:gmatch('(.-)' .. delim .. '()') do
table.insert(retval, elem)
endpos = pos
end
table.insert(retval, str:sub(endpos))
return retval
end
 
function p.main(frame)
local listcurrentTitle = mw.texttitle.trimgetCurrentTitle(frame.args[1])
local listEntriestarget = splitgetTarget(list, '\n'currentTitle)
if target then
table.sort(listEntries, function(a,b)
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
return split(a, ' ')[2]< split(b, ' ')[2]
if currentNsText ~= targetNsText then
end)
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
return table.concat(listEntries, '\n')
end)
end
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
end