Module:Namespacedata
Jump to navigation
Jump to search
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
Outputs a simple list of subject, content or talk namespaces . Useful for documentation or showcasing of these namespaces.
Usage
{{#invoke:Namespacedata|main|subject}}
{{#invoke:Namespacedata|main|talk}}
{{#invoke:Namespacedata|main|content}}
Example
(Main) (0) ·User (2) ·Special (-1) ·Media (-2) ·Template (10) ·Gadget (2300) ·Gadget definition (2302) ·File (6) ·Help (12) ·Summary (92) ·Module (828) ·MediaWiki (8) ·Category (14) ·Project (4) ·Data (486) ·Translations (1198) ·Thread (90) ·
-- Shows local namespace names
local p = {}
local mapping = {["content"] = "contentNamespaces", ["subject"] = "subjectNamespaces", ["talk"] = "talkNamespaces"}
function p.main(frame)
local workingFrame, namespaces = frame
if frame and frame:getParent() and workingFrame then
workingFrame = frame:getParent();
namespaces = workingFrame.args[1] or frame.args[1]
end
local output = ""
local queryNamespaces = mw.site[mapping[namespaces]]
if (not queryNamespaces ) then
return
end
for i, v in pairs (queryNamespaces) do
output = output .. (v.displayName or v.canonicalName) .." (".. i ..") ·"
end
mw.logObject(queryNamespaces)
return output
end
return p