386
edits
m>Mr. Stradivarius (give the argKeys table global scope so that getParamMappings can access it without having to process the cfg table again) |
m (2 revisions imported from templatewiki:Module:Namespace_detect/data: see Topic:Vtixlm0q28eo6jtf) |
||
(21 intermediate revisions by 15 users not shown) | |||
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 defaultKeys = { | ||
'main', | |||
'talk', | |||
'other', | |||
'subjectns', | |||
'demospace', | |||
'demopage' | |||
} | } | ||
local argKeys = {} | |||
for i, defaultKey in ipairs(defaultKeys) do | |||
argKeys[defaultKey] = {defaultKey} | |||
end | |||
for defaultKey, t in pairs(argKeys) do | for defaultKey, t in pairs(argKeys) do | ||
Line 52: | Line 57: | ||
-- } | -- } | ||
--]] | --]] | ||
local mappings = {} | local mappings = {} | ||
local mainNsName = mw.site.subjectNamespaces[0].name | |||
mappings['talk'] = clone(argKeys.talk) | mainNsName = mw.ustring.lower(mainNsName) | ||
for nsid, ns in pairs(subjectNamespaces) do | mappings[mainNsName] = mw.clone(argKeys.main) | ||
mappings['talk'] = mw.clone(argKeys.talk) | |||
for nsid, ns in pairs(mw.site.subjectNamespaces) do | |||
if nsid ~= 0 then -- Exclude main namespace. | if nsid ~= 0 then -- Exclude main namespace. | ||
local nsname = | local nsname = mw.ustring.lower(ns.name) | ||
local canonicalName = | local canonicalName = mw.ustring.lower(ns.canonicalName) | ||
mappings[nsname] = {nsname} | mappings[nsname] = {nsname} | ||
if canonicalName ~= nsname then | if canonicalName ~= nsname then | ||
table.insert(mappings[nsname], canonicalName) | |||
end | end | ||
for _, alias in ipairs(ns.aliases) do | for _, alias in ipairs(ns.aliases) do | ||
table.insert(mappings[nsname], mw.ustring.lower(alias)) | |||
end | end | ||
end | end |