Changes

Jump to: navigation, search

Module:Namespace detect/data

212 bytes removed, 10:02, 5 April 2014
bug fix - use the demospace parameter as both key and value in the argKeys table
-------------------------------------------------------------------------------------------------- Namespace detect data ---- Configuration This module holds data for [[Module:Namespace detect]] to be loaded per ---- Language-specific parameter names can be set herepage, rather than per #invoke, for performance reasons. ------------------------------------------------------------------------------------------------------
local cfg = {}require('Module:Namespace detect/config')
-- This parameter displays content for the main namespace:local function addKey(t, key, defaultKey)cfg.main if key ~= 'main'defaultKey then t[#t + 1] = key endend
-- Get a table of parameters to query for each default parameter name.-- This allows wikis to customise parameter displays names in talk namespaces:the cfg table while-- ensuring that default parameter names will always work. The cfgtable-- values can be added as a string, or as an array of strings.talk = 'talk'
-- This parameter displays content for "local defaultKeys = { 'main', 'talk', 'other" namespaces (namespaces for which',-- parameters have not been specified 'subjectns', or for when cfg. 'demospace is set to cfg.other):',cfg.other = 'otherdemopage'}
-- This parameter makes talk pages behave as though they are the corresponding subject namespace.local argKeys = {}-- Note that this parameter is used with for i, defaultKey in ipairs(defaultKeys) do argKeys[[Module:YesnodefaultKey]]. Edit that module to change= {defaultKey}-- the default values of "yes", "no", etc.cfg.subjectns = 'subjectns'end
-- This parameter sets a demonstration namespace:for defaultKey, t in pairs(argKeys) do local cfgValue = cfg.demospace [defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'demospacestring'then addKey(t, cfgValue, defaultKey)-- This parameter sets a specific page to compare:cfg.page elseif cfgValueType == 'pagetable'then -- The header for the namespace column i, key in the wikitable containing the list of possible subject-space parameters.ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg.wikitableNamespaceHeader [defaultKey] = 'Namespace' nil -- The header for the wikitable containing Free the list of possible subject-space parameters.cfgvalue as we don't need it any more.wikitableAliasesHeader = 'Aliases' ------------------------------------------------------------------------------------------------------ End configuration data ------------------------------------------------------------------------------------------------------end
local function getParamMappings()
--[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]]
local mappings = {}
mappings[mw.ustring.lower(local mainNsName = mw.site.namespacessubjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = {cfgmw.clone(argKeys.main}) mappings[cfg.'talk'] = {cfgmw.clone(argKeys.talk})
for nsid, ns in pairs(mw.site.subjectNamespaces) do
if nsid ~= 0 then -- Exclude main namespace.
end
return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() }
Anonymous user

Navigation menu