Module:User:Mr. Stradivarius/portalCheck explained

-- This module checks subpages of .

-- We can't do all 1,412 portal aliases at once, as we run into the expensive -- function count limit. So here we define start and end numbers so that we-- can run this in multiple batches.

local tableTools = require('Module:TableTools')

local p =

local function getImageKeyArray -- Returns an array containing all image subpages (minus aliases) as loaded by mw.loadData. local keyTables = local subpages = for i, subpage in ipairs(subpages) do keyTables[#keyTables + 1] = mw.loadData('Module:Portal/images/' .. subpage) end local keys = for i, keyTable in ipairs(keyTables) do for key in pairs(keyTable) do keys[#keys + 1] = key end end local aliases = mw.loadData('Module:Portal/images/aliases') for k, aliasTable in pairs(aliases) do for i, alias in ipairs(aliasTable) do keys[#keys + 1] = alias end end table.sort(keys) return keysend

function p.main(frame) local startNum = frame.args[1] local endNum = frame.args[2] startNum = tonumber(startNum) endNum = tonumber(endNum) local lang = mw.language.getContentLanguage local keys = getImageKeyArray local flaggedKeys = for i = startNum, endNum do local key = keys[i] local firstUpper = lang:ucfirst(key) local upper = mw.ustring.upper(key) local wordFirstUpper = mw.ustring.gsub(key, '%w*', function (match) return lang:ucfirst(match) end) local permutations = permutations = tableTools.removeDuplicates(permutations) local matchExists = false for i, permutation in ipairs(permutations) do local title = mw.title.new('Portal:' .. permutation) if title.exists then matchExists = true end end if not matchExists then flaggedKeys[#flaggedKeys + 1] = key end end local ret = for i, flaggedKey in ipairs(flaggedKeys) do ret[#ret + 1] = '* ' end return table.concat(ret, '\n')end

return p