Module:Navbar: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
function p.navbar(name) | function p.navbar(name, mode) | ||
return | return "<span style=\"display: inline-block; float: left; text-align: left; font-size: 0.75em; font-weight: normal; font-style: normal; width: 5em;\">" | ||
.. | .. ((mode == "mini") | ||
.. | and "[[Template:" .. name .. "|V]] • " .. "[[Template talk:" .. name .. "|T]] • " .. "[[Special:EditPage/Template:" .. name .. "|E]]" | ||
or "[[Template:" .. name .. "|View]] • " .. "[[Template talk:" .. name .. "|Talk]] • " .. "[[Special:EditPage/Template:" .. name .. "|Edit]]") | |||
.. "</span>" | |||
end | end | ||
Revision as of 03:53, 4 December 2024
This module is used to store functions for templates that generate a navigation bar:
Template:Navbar also uses this module, even though it only generates View/Talk/Edit links.
To include this module in other modules, use local navbar = require("Module:Navbar")._navbar
.
See also
local ordinal = require("Module:Ordinal")._ordinal
local p = {}
function p.navbar(name, mode)
return "<span style=\"display: inline-block; float: left; text-align: left; font-size: 0.75em; font-weight: normal; font-style: normal; width: 5em;\">"
.. ((mode == "mini")
and "[[Template:" .. name .. "|V]] • " .. "[[Template talk:" .. name .. "|T]] • " .. "[[Special:EditPage/Template:" .. name .. "|E]]"
or "[[Template:" .. name .. "|View]] • " .. "[[Template talk:" .. name .. "|Talk]] • " .. "[[Special:EditPage/Template:" .. name .. "|Edit]]")
.. "</span>"
end
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("{{Navbox"
.. "|name=Lumatone mapping navigation"
.. "|Title=[[Lumatone|Lumatone mappings]]"
.. "|Data 1=<div style=\"text-align: center;\"><div style=\"margin: auto auto auto auto;\">"
.. ((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]] '''→'''</div></div>}}")
if string.lower(root_page_name) ~= "lumatone mapping navigation" then
out_str = out_str .. " [[Category:Lumatone mappings]] [[Category:" .. x .. "edo]]"
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"
.. "|name=Navbox fractional-octave"
.. "|Title=[[Fractional-octave temperaments]]"
.. "|Data 1=<div style=\"text-align: center;\"><div style=\"margin: auto auto auto auto;\">"
.. ((x >= 5) and "'''←''' " 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) .. "]] '''→'''</div></div>}}")
return out_str
end
return p