|
|
| (24 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 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 "" |
| Line 8: |
Line 10: |
| namespace = namespace or "Template" | | namespace = namespace or "Template" |
| | | |
| local p_name = namespace .. ":" .. name | | local p_name = string.format("%s:%s", namespace, name) |
| local p_talk_name = namespace .. " talk:" .. name | | local p_talk_name = string.format("%s talk:%s", namespace, name) |
| local p_edit_name = "Special:EditPage/" .. namespace .. ":".. name | | local p_edit_name = "Special:EditPage/" .. p_name |
| | local s = " • " |
| | 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>", |
| .. text
| | text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3]) |
| .. ((mode == "mini")
| |
| and "[[" .. p_name .. "|V]] • " .. "[[" .. p_talk_name .. "|T]] • " .. "[[" .. p_edit_name .. "|E]]"
| |
| or "[[" .. p_name .. "|View]] • " .. "[[" .. p_talk_name .. "|Talk]] • " .. "[[" .. p_edit_name .. "|Edit]]")
| |
| .. "</span>"
| |
| 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 talk_page_name = frame:preprocess("{{lc:{{TALKPAGENAME:{{FULLROOTPAGENAME}}}}}}") | |
| local a = talk_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 "'''←''' " 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(talk_page_name) ~= "navbox lumatone" 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("{{FULLROOTPAGENAME}}")
| |
| 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 >= 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 out_str
| |
| end | | end |
|
| |
|
| return p | | return p |