Module:Portal: Difference between revisions

Content deleted Content added
exclude wikipedia, also
auto-detect whether we're being called from a sandbox, per JohnUniq
Line 42:
local p = {}
 
-- determine whether we're being called from a sandbox
-- IMPORTANT: isSandbox should be different between Module:Portal and Module:Portal/sandbox
local sandbox = mw.getCurrentFrame():getTitle():find('sandbox', 1, true) and '/sandbox' or ''
-- That should be the only difference between the main and sandbox version
local isSandbox = false
 
local templatestyles = 'Module:Portal/'..(isSandbox and 'sandbox/' or '')..'/styles.css'
 
local getArgs = require('Module:Arguments').getArgs
Line 77 ⟶ 76:
local imagePage
if mw.ustring.find(firstLetter, '^[a-z]') then
imagePage = 'Module:Portal/images/' .. firstLetter .. (isSandbox and '/sandbox' or '')
else
imagePage = 'Module:Portal/images/other' .. (isSandbox and '/sandbox' or '')
end
return mw.loadData(imagePage)[s]
Line 86 ⟶ 85:
local function getAlias(s)
-- Gets an alias from the image alias data page.
local aliasData = mw.loadData('Module:Portal/images/aliases'..(isSandbox and '/sandbox' or ''))
for portal, aliases in pairs(aliasData) do
for _, alias in ipairs(aliases) do
Line 235 ⟶ 234:
local images = {}
for i, subpage in ipairs{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'other'} do
images[i] = mw.loadData('Module:Portal/images/' .. subpage .. (isSandbox and '/sandbox' or ''))
end
return images