Module:Navbar: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(37 intermediate revisions by 3 users not shown)
Line 1: Line 1:
local ordinal = require("Module:Ordinal")._ordinal
local getArgs = require("Module:Arguments").getArgs
local yesno = require("Module:Yesno")


local p = {}
local p = {}


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


-- Wrapper function for [[Template:Navbar]]
function p.navbar(frame)
function p.navbar(frame)
local args = getArgs(frame)
local name = frame.args["name"]
local name = frame.args["name"]
local namespace = frame.args["namespace"]
local namespace = frame.args["namespace"]
local mode = frame.args["mode"]
local mode = frame.args["mode"]
local text = frame.args["text"]
local text = frame.args["text"]
local wtext = yesno(frame.args["wtext"] or args["wtext"])
local result = p._navbar(name, mode, text, namespace)
return p._navbar(name, mode, text, namespace)
-- Debugger option
end
if wtext then
 
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
function p.lumatone_map(frame)
local root_page_name = frame:preprocess("{{ROOTPAGENAME}}")
local a = root_page_name:match("[Ll]umatone%s*[Mm]apping%s*[Ff]or%s*(%d+)%s*[Ee][Dd][2Oo]")
local x = tonumber(frame.args["edo"]) or tonumber(a)
local thresh = 5
local out_str = frame:preprocess("<br />{{Navbox"
.. "|name=Navbox Lumatone"
.. "|Title=[[Lumatone|Lumatone mappings]]"
.. "|Data 1={{center|"
.. ((x >= thresh + 4) and "'''&larr;''' " or "")
.. ((x >= thresh + 3) and "[[Lumatone mapping for " .. (x - 3) .. "edo|" .. (x - 3) .. "edo]] &bull; " or "")
.. ((x >= thresh + 2) and "[[Lumatone mapping for " .. (x - 2) .. "edo|" .. (x - 2) .. "edo]] &bull; " or "")
.. ((x >= thresh + 1) and "[[Lumatone mapping for " .. (x - 1) .. "edo|" .. (x - 1) .. "edo]] &bull; " or "")
.. "'''Lumatone mapping for " .. x .. "edo''' &bull; "
.. "[[Lumatone mapping for " .. (x + 1) .. "edo|" .. (x + 1) .. "edo]] &bull; "
.. "[[Lumatone mapping for " .. (x + 2) .. "edo|" .. (x + 2) .. "edo]] &bull; "
.. "[[Lumatone mapping for " .. (x + 3) .. "edo|" .. (x + 3) .. "edo]] '''&rarr;'''</div></div>}}"
.. "}}")
if string.lower(root_page_name) ~= "lumatone mapping navigation" then
out_str = out_str .. " [[Category:Lumatone mappings]] [[Category:" .. x .. "edo]]"
end
end
return out_str
end
function p.frac_octave(frame)
local root_page_name = frame:preprocess("{{ROOTPAGENAME}}")
local a = root_page_name:match("(%d+)%a+[%s%-]*[Oo]ctave%s*[Tt]emperament[s]?")
local x = tonumber(frame.args["f"]) or tonumber(a)
local out_str = frame:preprocess("<br />{{Navbox"
return frame:preprocess(result)
.. "|name=Navbox fractional-octave"
.. "|Title=[[Fractional-octave temperaments]]"
.. "|Data 1={{center|"
.. ((x >= 5) and "'''&larr;''' " or "")
.. ((x >= 4) and "[[" .. ordinal(x - 3) .. "-octave temperaments|" .. ordinal(x - 3) .. "]] &bull; " or "")
.. ((x >= 3) and "[[" .. ordinal(x - 2) .. "-octave temperaments|" .. ordinal(x - 2) .. "]] &bull; " or "")
.. ((x >= 2) and "[[" .. ordinal(x - 1) .. "-octave temperaments|" .. ordinal(x - 1) .. "]] &bull; " or "")
.. "'''" .. ordinal(x) .. "-octave''' &bull; "
.. "[[" .. ordinal(x + 1) .. "-octave temperaments|" .. ordinal(x + 1) .. "]] &bull; "
.. "[[" .. ordinal(x + 2) .. "-octave temperaments|" .. ordinal(x + 2) .. "]] &bull; "
.. "[[" .. ordinal(x + 3) .. "-octave temperaments|" .. ordinal(x + 3) .. "]] '''&rarr;'''</div></div>}}"
.. "}}")
return out_str
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