Documentation for this module may be created at Module:Shortcut/doc
local p = {}
local get_args = require("Module:Arguments").getArgs
local function transclude(title_str)
local title = mw.title.new(title_str)
if title:inNamespace(0) then
if title.namespace == mw.title.new("Template" .. title_str).namespace then
return "Template:" .. title_str
else
return title.text
end
end
return title.fullText
end
function p.main(frame)
local args = get_args(frame)
local align = args["align"] or "right"
local margin = args["margin"] or "0 0 1em 1em"
local redirect = args["redirect"] ~= nil
local count = 0
for i, v in ipairs(args) do
count = count + 1
end
if count < 1 then
error("At least one shortcut must be provided")
end
local text = "<div class=\"toccolours shortcut-box\" style=\"clear: " .. align .. "; float: " .. align .. "; margin: " .. margin .. ";\">"
.. "<div class=\"shortcut-box-title\">" .. (redirect and "Redirect" or "Shortcut") .. (count == 1 and '' or 's') .. "</div>"
for i = 1, count, 1 do
local url = tostring(mw.uri.fullUrl(transclude(args[i]), "redirect=no"))
text = text .. "<div class=\"shortcut-box-row\">[" .. url .. ' ' .. args[i] .. "]</div>"
end
text = text .. "</div>"
return text
end
return p