Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Namespace detect/data

Permanently protected module
From Wikipedia, the free encyclopedia
<Module:Namespace detect
Module documentation[view] [edit] [history] [purge]
Thismodule is rated asready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned onhelp pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed throughsandbox testing rather than repeated trial-and-error editing.
Page protectedThis module is currentlyprotected from editing.
See theprotection policy andprotection log for more details. Please discuss any changes on thetalk page; you maysubmit an edit request to ask anadministrator to make an edit if it isuncontroversial or supported byconsensus. You may alsorequest that this page be unprotected.
WarningThis Lua module is used in system messages, and onapproximately 5,140,000 pages, or roughly 8% of all pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on thetalk page before implementing them.
This module depends on the following other modules:

This is a data page forModule:Namespace detect andModule:Category handler/shared. It is loaded by the main module usingmw.loadData, which means it is only processed once per page, rather than once per#invoke.

The abovedocumentation istranscluded fromModule:Namespace detect/data/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

----------------------------------------------------------------------------------                          Namespace detect data                             ---- This module holds data for [[Module:Namespace detect]] to be loaded per    ---- page, rather than per #invoke, for performance reasons.                    ----------------------------------------------------------------------------------localcfg=require('Module:Namespace detect/config')localfunctionaddKey(t,key,defaultKey)ifkey~=defaultKeythent[#t+1]=keyendend-- Get a table of parameters to query for each default parameter name.-- This allows wikis to customise parameter names in the cfg table while-- ensuring that default parameter names will always work. The cfg table-- values can be added as a string, or as an array of strings.localdefaultKeys={'main','talk','other','subjectns','demospace','demopage'}localargKeys={}fori,defaultKeyinipairs(defaultKeys)doargKeys[defaultKey]={defaultKey}endfordefaultKey,tinpairs(argKeys)dolocalcfgValue=cfg[defaultKey]localcfgValueType=type(cfgValue)ifcfgValueType=='string'thenaddKey(t,cfgValue,defaultKey)elseifcfgValueType=='table'thenfori,keyinipairs(cfgValue)doaddKey(t,key,defaultKey)endendcfg[defaultKey]=nil-- Free the cfg value as we don't need it any more.endlocalfunctiongetParamMappings()--[[-- 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'},--   ...-- }--]]localmappings={}localmainNsName=mw.site.subjectNamespaces[0].namemainNsName=mw.ustring.lower(mainNsName)mappings[mainNsName]=mw.clone(argKeys.main)mappings['talk']=mw.clone(argKeys.talk)fornsid,nsinpairs(mw.site.subjectNamespaces)doifnsid~=0then-- Exclude main namespace.localnsname=mw.ustring.lower(ns.name)localcanonicalName=mw.ustring.lower(ns.canonicalName)mappings[nsname]={nsname}ifcanonicalName~=nsnamethentable.insert(mappings[nsname],canonicalName)endfor_,aliasinipairs(ns.aliases)dotable.insert(mappings[nsname],mw.ustring.lower(alias))endendendreturnmappingsendreturn{argKeys=argKeys,cfg=cfg,mappings=getParamMappings()}
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Namespace_detect/data&oldid=948472520"
Category:
Hidden category:

[8]ページ先頭

©2009-2026 Movatter.jp