Module:Namespacedata

From Habbox Wiki
Jump to navigation Jump to search

Template:Module rating 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) ·Gadget definition (2302) ·Module (828) ·Category (14) ·User (2) ·Project (4) ·MediaWiki (8) ·Campaign (460) ·Gadget (2300) ·Portal (500) ·Template (10) ·Special (-1) ·Media (-2) ·File (6) ·Help (12) ·Private (100) ·



-- 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