Module:Navbar: Difference between revisions

ArrowHead294 (talk | contribs)
m Sort dependencies
ArrowHead294 (talk | contribs)
mNo edit summary
 
Line 4: Line 4:
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")


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 11: 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 "<span style=\"font-size: 0.75em; font-weight: normal; font-style: normal;\">"
.. string.format(mode == "mini" and "%s[[%s|V]]%s[[%s|T]]%s[[%s|E]]" or "%s[[%s|View]]%s[[%s|Talk]]%s[[%s|Edit]]",
.. string.format("%s[[%s|%s]]%s[[%s|%s]]%s[[%s|%s]]",
text, p_name, s, p_talk_name, s, p_edit_name)
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
.. "</span>"
.. "</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 name = frame.args["name"]
local name = frame.args["name"]
Line 28: Line 29:
local text = frame.args["text"]
local text = frame.args["text"]
local debugg = frame.args["debug"]
local debugg = frame.args["debug"]
local result = p._navbar(name, mode, text, namespace)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return p._navbar(name, mode, text, namespace, debugg)
return frame:preprocess(result)
end
end


-- Navbox for lumatone mappings
function p.lumatone_map(frame)
function p.lumatone_map(frame)
local debugg = yesno(frame.args["debug"])
local debugg = yesno(frame.args["debug"])
Line 72: Line 80:
.. "}}"
.. "}}"


return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


-- Navbox for fractional-octave temperaments
function p.frac_octave(frame)
function p.frac_octave(frame)
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
Line 124: Line 138:
.. "}}"
.. "}}"


return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p