Module:Navbar: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 30: | Line 30: | ||
function p.lumatone_map(frame) | function p.lumatone_map(frame) | ||
local page_name = frame:preprocess("{{ | local page_name = frame:preprocess("{{ARTICLEROOTPAGENAME}}") | ||
local debugg = yesno(frame.args["debug"]) | |||
local a = page_name:match("[Ll]umatone%s*[Mm]apping%s*[Ff]or%s*(%d+)%s*[Ee][Dd][2Oo]") | local a = 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 x = tonumber(frame.args["edo"]) or tonumber(a) | ||
local thresh = 5 | local thresh = 5 | ||
local out_str = | local out_str = "<br />{{Navbox" | ||
.. "|name=Navbox Lumatone" | .. "|name=Navbox Lumatone" | ||
.. "|Title=[[Lumatone|Lumatone mappings]]" | .. "|Title=[[Lumatone|Lumatone mappings]]" | ||
| Line 47: | Line 48: | ||
.. "[[Lumatone mapping for " .. (x + 2) .. "edo|" .. (x + 2) .. "edo]] • " | .. "[[Lumatone mapping for " .. (x + 2) .. "edo|" .. (x + 2) .. "edo]] • " | ||
.. "[[Lumatone mapping for " .. (x + 3) .. "edo|" .. (x + 3) .. "edo]] '''→'''}}" | .. "[[Lumatone mapping for " .. (x + 3) .. "edo|" .. (x + 3) .. "edo]] '''→'''}}" | ||
.. "}}" | .. "}}" | ||
if string.lower(page_name) ~= "template:navbox lumatone" then | if string.lower(page_name) ~= "template:navbox lumatone" then | ||
| Line 53: | Line 54: | ||
end | end | ||
return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str) | return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str) | ||
end | end | ||
| Line 59: | Line 59: | ||
function p.frac_octave(frame) | function p.frac_octave(frame) | ||
local root_page_name = frame:preprocess("{{FULLROOTPAGENAME}}") | local root_page_name = frame:preprocess("{{FULLROOTPAGENAME}}") | ||
local debugg = yesno(frame.args["debug"]) | |||
local a = root_page_name:match("(%d+)%a+[%s%-]*[Oo]ctave%s*[Tt]emperament[s]?") | 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 x = tonumber(frame.args["f"]) or tonumber(a) | ||
local out_str = | local out_str = "<br />{{Navbox" | ||
.. "|name=Navbox fractional-octave" | .. "|name=Navbox fractional-octave" | ||
.. "|Title=[[Fractional-octave temperaments]]" | .. "|Title=[[Fractional-octave temperaments]]" | ||
.. "|Data 1={{ | .. "|Data 1={{centre|" | ||
.. ((x >= 6) and "'''←''' " or "") | .. ((x >= 6) and "'''←''' " or "") | ||
.. ((x >= 5) and "[[" .. ordinal(x - 4) .. "-octave temperaments|" .. ordinal(x - 4) .. "]] • " or "") | .. ((x >= 5) and "[[" .. ordinal(x - 4) .. "-octave temperaments|" .. ordinal(x - 4) .. "]] • " or "") | ||
| Line 76: | Line 77: | ||
.. "[[" .. ordinal(x + 3) .. "-octave temperaments|" .. ordinal(x + 3) .. "]] • " | .. "[[" .. ordinal(x + 3) .. "-octave temperaments|" .. ordinal(x + 3) .. "]] • " | ||
.. "[[" .. ordinal(x + 4) .. "-octave temperaments|" .. ordinal(x + 4) .. "]] '''→'''}}" | .. "[[" .. ordinal(x + 4) .. "-octave temperaments|" .. ordinal(x + 4) .. "]] '''→'''}}" | ||
.. "}}" | .. "}}" | ||
return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str) | return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str) | ||
end | end | ||
return p | return p | ||
Revision as of 13:56, 4 March 2025
- 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 | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||||||||||||||
No function descriptions were provided. The Lua code may have further information.
local ordinal = require("Module:Ordinal")._ordinal
local yesno = require("Module:yesno")
local p = {}
function p._navbar(name, mode, text, namespace)
mode = mode or ""
text = (text == nil and "" or text .. " ")
namespace = namespace or "Template"
local p_name = namespace .. ":" .. name
local p_talk_name = namespace .. " talk:" .. name
local p_edit_name = "Special:EditPage/" .. namespace .. ":".. name
local s = ((mode == "v" or mode == "vmini") and "<br />" or " • ")
return "<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">"
.. text
.. string.format(((mode == "mini" or mode == "vmini") and "[[%s|V]]%s[[%s|T]]%s[[%s|E]]" or "[[%s|View]]%s[[%s|Talk]]%s[[%s|Edit]]"),
p_name, s, p_talk_name, s, p_edit_name)
.. "</span>"
end
function p.navbar(frame)
local name = frame.args["name"]
local namespace = frame.args["namespace"]
local mode = frame.args["mode"]
local text = frame.args["text"]
return p._navbar(name, mode, text, namespace)
end
function p.lumatone_map(frame)
local page_name = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local debugg = yesno(frame.args["debug"])
local a = 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 = "<br />{{Navbox"
.. "|name=Navbox Lumatone"
.. "|Title=[[Lumatone|Lumatone mappings]]"
.. "|Data 1={{center|"
.. ((x >= thresh + 4) and "'''←''' " or "")
.. ((x >= thresh + 3) and "[[Lumatone mapping for " .. (x - 3) .. "edo|" .. (x - 3) .. "edo]] • " or "")
.. ((x >= thresh + 2) and "[[Lumatone mapping for " .. (x - 2) .. "edo|" .. (x - 2) .. "edo]] • " or "")
.. ((x >= thresh + 1) and "[[Lumatone mapping for " .. (x - 1) .. "edo|" .. (x - 1) .. "edo]] • " or "")
.. "'''Lumatone mapping for " .. x .. "edo''' • "
.. "[[Lumatone mapping for " .. (x + 1) .. "edo|" .. (x + 1) .. "edo]] • "
.. "[[Lumatone mapping for " .. (x + 2) .. "edo|" .. (x + 2) .. "edo]] • "
.. "[[Lumatone mapping for " .. (x + 3) .. "edo|" .. (x + 3) .. "edo]] '''→'''}}"
.. "}}"
if string.lower(page_name) ~= "template:navbox lumatone" then
out_str = out_str .. " [[Category:Lumatone mappings]] [[Category:" .. x .. "edo]]"
end
return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str)
end
function p.frac_octave(frame)
local root_page_name = frame:preprocess("{{FULLROOTPAGENAME}}")
local debugg = yesno(frame.args["debug"])
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 = "<br />{{Navbox"
.. "|name=Navbox fractional-octave"
.. "|Title=[[Fractional-octave temperaments]]"
.. "|Data 1={{centre|"
.. ((x >= 6) and "'''←''' " or "")
.. ((x >= 5) and "[[" .. ordinal(x - 4) .. "-octave temperaments|" .. ordinal(x - 4) .. "]] • " or "")
.. ((x >= 4) and "[[" .. ordinal(x - 3) .. "-octave temperaments|" .. ordinal(x - 3) .. "]] • " or "")
.. ((x >= 3) and "[[" .. ordinal(x - 2) .. "-octave temperaments|" .. ordinal(x - 2) .. "]] • " or "")
.. ((x >= 2) and "[[" .. ordinal(x - 1) .. "-octave temperaments|" .. ordinal(x - 1) .. "]] • " or "")
.. "'''" .. ordinal(x) .. "-octave''' • "
.. "[[" .. ordinal(x + 1) .. "-octave temperaments|" .. ordinal(x + 1) .. "]] • "
.. "[[" .. ordinal(x + 2) .. "-octave temperaments|" .. ordinal(x + 2) .. "]] • "
.. "[[" .. ordinal(x + 3) .. "-octave temperaments|" .. ordinal(x + 3) .. "]] • "
.. "[[" .. ordinal(x + 4) .. "-octave temperaments|" .. ordinal(x + 4) .. "]] '''→'''}}"
.. "}}"
return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str)
end
return p