|
|
| (6 intermediate revisions by 2 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 yesno = require("Module:Yesno") |
| | |
| local p = {} | | local p = {} |
|
| |
|
| function p._navbar(name, mode, text, namespace, debugg) | | -- Main function called by navigation box templates |
| | 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 .. " ") |
| Line 10: |
Line 12: |
| local p_name = string.format("%s:%s", namespace, name) | | local p_name = string.format("%s:%s", namespace, name) |
| local p_talk_name = string.format("%s talk:%s", namespace, name) | | local p_talk_name = string.format("%s talk:%s", namespace, name) |
| local p_edit_name = "special:editpage/" .. p_name | | local p_edit_name = "Special:EditPage/" .. p_name |
| local s = " • " | | local s = " • " |
| | local links = (mode == mini and {"V", "T", "E"} or {"View", "Talk", "Edit"}) |
| | | |
| local result = "<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(mode == "mini" and "%s[[%s|V]]%s[[%s|T]]%s[[%s|E]]" or "%s[[%s|View]]%s[[%s|Talk]]%s[[%s|Edit]]",
| | text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3]) |
| text, p_name, s, p_talk_name, s, p_edit_name)
| |
| .. "</span>"
| |
|
| |
| return (debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
| |
| 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 debugg = frame.args["debug"] | | local wtext = yesno(frame.args["wtext"] or args["wtext"]) |
|
| | local result = p._navbar(name, mode, text, namespace) |
| return p._navbar(name, mode, text, namespace, debugg)
| |
| end
| |
| | |
| function p.lumatone_map(frame)
| |
| local debugg = yesno(frame.args["debug"])
| |
| local x = tonumber(frame.args["edo"]:match("(%d+)"))
| |
| local thresh = 5 | |
|
| |
| local idxn1 = x - 1
| |
| local idxn2 = x - 2
| |
| local idxn3 = x - 3
| |
| local idx1 = x + 1
| |
| local idx2 = x + 2
| |
| local idx3 = x + 3
| |
|
| |
| local result = "<br />{{Navbox\n"
| |
| .. "| name = Navbox Lumatone\n"
| |
| .. "| Title = [[Lumatone|Lumatone mappings]]\n"
| |
| .. "| Data 1 = {{centre|"
| |
|
| |
| if x >= thresh + 4 then
| |
| result = result .. "'''←''' "
| |
| end
| |
|
| |
| if x >= thresh + 3 then
| |
| result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] • ", idxn3, idxn3)
| |
| end
| |
|
| |
| if x >= thresh + 2 then
| |
| result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] • ", idxn2, idxn2)
| |
| end
| |
|
| |
| if x >= thresh + 1 then
| |
| result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] • ", idxn1, idxn1)
| |
| end
| |
|
| |
| result = result
| |
| .. string.format("'''Lumatone mapping for %sedo''' • ", x)
| |
| .. string.format("[[Lumatone mapping for %sedo|%sedo]] • ", idx1, idx1)
| |
| .. string.format("[[Lumatone mapping for %sedo|%sedo]] • ", idx2, idx2)
| |
| .. string.format("[[Lumatone mapping for %sedo|%sedo]] '''→'''}}\n", idx3, idx3)
| |
| .. "}}"
| |
| | |
| return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
| |
| end
| |
| | |
| function p.frac_octave(frame)
| |
| local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
| |
| local debugg = yesno(frame.args["debug"])
| |
| local a = arpn:match("(%d+)%a+[%s%-]*")
| |
| local x = tonumber(frame.args["f"]) or tonumber(a)
| |
| local thresh = 2
| |
|
| |
| local idxn1 = ordinal(x - 1)
| |
| local idxn2 = ordinal(x - 2)
| |
| local idxn3 = ordinal(x - 3)
| |
| local idxn4 = ordinal(x - 4)
| |
| local idx1 = ordinal(x + 1)
| |
| local idx2 = ordinal(x + 2)
| |
| local idx3 = ordinal(x + 3)
| |
| local idx4 = ordinal(x + 4)
| |
|
| |
| local result = "<br />{{Navbox\n"
| |
| .. "| name = Navbox fractional-octave\n"
| |
| .. "| Title = [[Fractional-octave temperaments]]\n"
| |
| .. "| Data 1 = {{centre|"
| |
|
| |
| if x >= thresh + 4 then
| |
| result = result .. "'''←''' "
| |
| end
| |
|
| |
| if x >= thresh + 3 then
| |
| result = result .. string.format("[[%s-octave temperaments|%s]] • ", idxn4, idxn4)
| |
| end
| |
|
| |
| if x >= thresh + 2 then
| |
| result = result .. string.format("[[%s-octave temperaments|%s]] • ", idxn3, idxn3)
| |
| end
| |
| | | |
| if x >= thresh + 1 then | | -- Debugger option |
| result = result .. string.format("[[%s-octave temperaments|%s]] • ", idxn2, idxn2) | | if wtext then |
| | result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" |
| end | | end |
| | | |
| if x >= thresh then
| | return frame:preprocess(result) |
| result = result .. string.format("[[%s-octave temperaments|%s]] • ", idxn1, idxn1)
| |
| end
| |
|
| |
| result = result
| |
| .. string.format("'''%s-octave''' • ", ordinal(x))
| |
| .. string.format("[[%s-octave temperaments|%s]] • ", idx1, idx1)
| |
| .. string.format("[[%s-octave temperaments|%s]] • ", idx2, idx2)
| |
| .. string.format("[[%s-octave temperaments|%s]] • ", idx3, idx3)
| |
| .. string.format("[[%s-octave temperaments|%s]] '''→'''}}\n", idx4, idx4)
| |
| .. "}}"
| |
| | |
| return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result) | |
| end | | end |
|
| |
|
| return p | | return p |