Editing Module:Namespace detect/data
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 18: | Line 18: | ||
-- values can be added as a string, or as an array of strings. | -- values can be added as a string, or as an array of strings. | ||
local | local argKeys = { | ||
'main', | main = {'main'}, | ||
'talk', | talk = {'talk'}, | ||
'other', | other = {'other'}, | ||
'subjectns', | subjectns = {'subjectns'}, | ||
'demospace', | demospace = {'demospace'}, | ||
' | page = {'page'} | ||
} | } | ||
for defaultKey, t in pairs(argKeys) do | for defaultKey, t in pairs(argKeys) do | ||
Line 57: | Line 52: | ||
-- } | -- } | ||
--]] | --]] | ||
local ustringLower = mw.ustring.lower | |||
local tinsert = table.insert | |||
local clone = mw.clone | |||
local subjectNamespaces = mw.site.subjectNamespaces | |||
local mappings = {} | local mappings = {} | ||
mappings[ustringLower(subjectNamespaces[0].name)] = clone(argKeys.main) | |||
mappings['talk'] = clone(argKeys.talk) | |||
for nsid, ns in pairs(subjectNamespaces) do | |||
mappings['talk'] = | |||
for nsid, ns in pairs( | |||
if nsid ~= 0 then -- Exclude main namespace. | if nsid ~= 0 then -- Exclude main namespace. | ||
local nsname = | local nsname = ustringLower(ns.name) | ||
local canonicalName = | local canonicalName = ustringLower(ns.canonicalName) | ||
mappings[nsname] = {nsname} | mappings[nsname] = {nsname} | ||
if canonicalName ~= nsname then | if canonicalName ~= nsname then | ||
tinsert(mappings[nsname], canonicalName) | |||
end | end | ||
for _, alias in ipairs(ns.aliases) do | for _, alias in ipairs(ns.aliases) do | ||
tinsert(mappings[nsname], ustringLower(alias)) | |||
end | end | ||
end | end |