Module:Navbar

From XenReference

Documentation for this module may be created at Module:Navbar/doc

local p = {}

-- Main function called by navigation box templates
function p._navbar(name, mode, text, namespace)
	mode = mode or ""
	text = (text == nil and "" or text .. " ")
	namespace = namespace or "Template"
	
	local p_name = string.format("%s:%s", namespace, name)
	local p_talk_name = string.format("%s talk:%s", namespace, name)
	local p_edit_name = "Special:EditPage/" .. p_name
	local s = " • "
	local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"})
	
	return "<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">"
		.. string.format("%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]",
			text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
		.. "</span>"
end

-- Wrapper function for [[Template:Navbar]]
function p.navbar(frame)
	local name = frame.args["name"]
	local namespace = frame.args["namespace"]
	local mode = frame.args["mode"]
	local text = frame.args["text"]
	local debugg = frame.args["debug"]
	local result = p._navbar(name, mode, text, namespace)
	
	-- Debugger option
	if debugg == true then
		result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
	end
	
	return frame:preprocess(result)
end

return p