Module:Navbar: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Ganaram inukshuk (talk | contribs)
fractional-octave and lumatone functions (should be) no longer needed; numlinks+navbox modules/templates handle everything now
ArrowHead294 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local getArgs = require("Module:Arguments").getArgs
local yesno = require("Module:Yesno")
local p = {}
local p = {}
local ordinal = require("Module:Ordinal")._ordinal
local yesno = require("Module:Yesno")


-- Main function called by navigation box templates
-- Main function called by navigation box templates
Line 16: Line 16:
local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"})
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;\">"
return string.format("<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]</span>",
.. 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])
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
end
.. "</span>"
 
-- Wrapper function for [[Template:Navbar]]
function p.navbar(frame)
local args = getArgs(frame)
local name = frame.args["name"]
local namespace = frame.args["namespace"]
local mode = frame.args["mode"]
local text = frame.args["text"]
local wtext = yesno(frame.args["wtext"] or args["wtext"])
local result = p._navbar(name, mode, text, namespace)
-- Debugger option
if wtext then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p

Latest revision as of 19:12, 17 December 2025

Module documentation[view] [edit] [history] [purge]
This module implements a metatemplate, and may be invoked by templates using its corresponding template Template:Navbar, or used directly from other modules.

This module is used by Template:Navbar to generate View/Talk/Edit links on templates.

To include this module in other modules, use local navbar = require("Module:Navbar")._navbar.


Introspection summary for Module:Navbar 
Functions provided (2)
Line Function Params
7 _navbar (main) (name, mode, text, namespace)
23 navbar (invokable) (frame)
Lua modules required (2)
Variable Module Functions used
getArgs Module:Arguments getArgs
yesno Module:Yesno yesno

No function descriptions were provided. The Lua code may have further information.


local getArgs = require("Module:Arguments").getArgs
local yesno = require("Module:Yesno")

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 = " &bull; "
	local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"})
	
	return string.format("<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]</span>",
		text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
end

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

return p